private String calculateRawEncoding(final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final InputStream is) throws IOException {
        String encoding;
        if (bomEnc == null) {
            if (xmlGuessEnc == null || xmlEnc == null) {
                if (defaultEncoding == null) {
                    encoding = UTF_8;
                } else {
                    encoding = defaultEncoding;
                }
            } else if (xmlEnc.equals(UTF_16) && (xmlGuessEnc.equals(UTF_16BE) || xmlGuessEnc.equals(UTF_16LE))) {
                encoding = xmlGuessEnc;
            } else {
                encoding = xmlEnc;
            }
        } else if (bomEnc.equals(UTF_8)) {
            if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) {
                throw new XmlReaderException(RAW_EX_1.format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, xmlEnc, is);
            }
            if (xmlEnc != null && !xmlEnc.equals(UTF_8)) {
                throw new XmlReaderException(RAW_EX_1.format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, xmlEnc, is);
            }
            encoding = UTF_8;
        } else if (bomEnc.equals(UTF_16BE) || bomEnc.equals(UTF_16LE)) {
            if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) {
                throw new IOException(RAW_EX_1.format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }));
            }
            if (xmlEnc != null && !xmlEnc.equals(UTF_16) && !xmlEnc.equals(bomEnc)) {
                throw new XmlReaderException(RAW_EX_1.format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, xmlEnc, is);
            }
            encoding = bomEnc;
        } else {
            throw new XmlReaderException(RAW_EX_2.format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, xmlEnc, is);
        }
        return encoding;
    }
private String calculateRawEncoding ( final String bomEnc , final String xmlGuessEnc , final String xmlEnc , final InputStream is ) throws IOException { String encoding ; if ( bomEnc == null ) { if ( xmlGuessEnc == null || xmlEnc == null ) { if ( defaultEncoding == null ) { encoding = UTF_8 ; } else { encoding = defaultEncoding ; } } else if ( xmlEnc . equals ( UTF_16 ) && ( xmlGuessEnc . equals ( UTF_16BE ) || xmlGuessEnc . equals ( UTF_16LE ) ) ) { encoding = xmlGuessEnc ; } else { encoding = xmlEnc ; } } else if ( bomEnc . equals ( UTF_8 ) ) { if ( xmlGuessEnc != null && ! xmlGuessEnc . equals ( UTF_8 ) ) { throw new XmlReaderException ( RAW_EX_1 . format ( new Object [ ] { bomEnc , xmlGuessEnc , xmlEnc } ) , bomEnc , xmlGuessEnc , xmlEnc , is ) ; } if ( xmlEnc != null && ! xmlEnc . equals ( UTF_8 ) ) { throw new XmlReaderException ( RAW_EX_1 . format ( new Object [ ] { bomEnc , xmlGuessEnc , xmlEnc } ) , bomEnc , xmlGuessEnc , xmlEnc , is ) ; } encoding = UTF_8 ; } else if ( bomEnc . equals ( UTF_16BE ) || bomEnc . equals ( UTF_16LE ) ) { if ( xmlGuessEnc != null && ! xmlGuessEnc . equals ( bomEnc ) ) { throw new IOException ( RAW_EX_1 . format ( new Object [ ] { bomEnc , xmlGuessEnc , xmlEnc } ) ) ; } if ( xmlEnc != null && ! xmlEnc . equals ( UTF_16 ) && ! xmlEnc . equals ( bomEnc ) ) { throw new XmlReaderException ( RAW_EX_1 . format ( new Object [ ] { bomEnc , xmlGuessEnc , xmlEnc } ) , bomEnc , xmlGuessEnc , xmlEnc , is ) ; } encoding = bomEnc ; } else { throw new XmlReaderException ( RAW_EX_2 . format ( new Object [ ] { bomEnc , xmlGuessEnc , xmlEnc } ) , bomEnc , xmlGuessEnc , xmlEnc , is ) ; } return encoding ; }
InputStream is passed for XmlReaderException creation only