private Object[] getEncoding(InputStream in, ErrorDispatcher err) throws IOException, JasperException { this.stream = in; this.err=err; createInitialReader(); scanXMLDecl(); return new Object[] { this.encoding, Boolean.valueOf(this.isEncodingSetInProlog), this.hasBom }; }
/** * Returns the next character on the input. * <p> * <strong>Note:</strong> The character is <em>not</em> consumed. * * @throws IOException Thrown if i/o error occurs. * @throws EOFException Thrown on end of file. */ public int peekChar() throws IOException { // load more characters, if needed if (fCurrentEntity.position == fCurrentEntity.count) { load(0, true); } // peek at character int c = fCurrentEntity.ch[fCurrentEntity.position]; // return peeked character if (fCurrentEntity.isExternal()) { return c != '\r' ? c : '\n'; } else { return c; } } // peekChar():int
private void scanXMLDecl() throws IOException, JasperException { if (skipString("<?xml")) { // NOTE: special case where document starts with a PI // whose name starts with "xml" (e.g. "xmlfoo") if (XMLChar.isName(peekChar())) { fStringBuffer.clear(); fStringBuffer.append("xml"); while (XMLChar.isName(peekChar())) { fStringBuffer.append((char)scanChar()); } String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length); scanPIData(target, fString); } // standard XML declaration else { scanXMLDeclOrTextDecl(false); } } }
/** * Autodetects the encoding of the XML document supplied by the given * input stream. * * Encoding autodetection is done according to the XML 1.0 specification, * Appendix F.1: Detection Without External Encoding Information. * * @return Two-element array, where the first element (of type * java.lang.String) contains the name of the (auto)detected encoding, and * the second element (of type java.lang.Boolean) specifies whether the * encoding was specified using the 'encoding' attribute of an XML prolog * (TRUE) or autodetected (FALSE). */ public static Object[] getEncoding(String fname, Jar jar, JspCompilationContext ctxt, ErrorDispatcher err) throws IOException, JasperException { InputStream inStream = JspUtil.getInputStream(fname, jar, ctxt); XMLEncodingDetector detector = new XMLEncodingDetector(); Object[] ret = detector.getEncoding(inStream, err); inStream.close(); return ret; }
Object [] encodingDesc = getEncodingName(b4, count); encoding = (String)(encodingDesc[0]); isBigEndian = (Boolean)(encodingDesc[1]); reader = createReader(stream, encoding, isBigEndian); } else { reader = createReader(stream, encoding, isBigEndian);
} else { Object[] ret = XMLEncodingDetector.getEncoding(absFileName, jarFile, ctxt, err); sourceEnc = (String) ret[0];
private void scanXMLDecl() throws IOException, JasperException { if (skipString("<?xml")) { // NOTE: special case where document starts with a PI // whose name starts with "xml" (e.g. "xmlfoo") if (XMLChar.isName(peekChar())) { fStringBuffer.clear(); fStringBuffer.append("xml"); while (XMLChar.isName(peekChar())) { fStringBuffer.append((char)scanChar()); } String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length); scanPIData(target, fString); } // standard XML declaration else { scanXMLDeclOrTextDecl(false); } } }
/** * Autodetects the encoding of the XML document supplied by the given * input stream. * * Encoding autodetection is done according to the XML 1.0 specification, * Appendix F.1: Detection Without External Encoding Information. * * @return Two-element array, where the first element (of type * java.lang.String) contains the name of the (auto)detected encoding, and * the second element (of type java.lang.Boolean) specifies whether the * encoding was specified using the 'encoding' attribute of an XML prolog * (TRUE) or autodetected (FALSE). */ public static Object[] getEncoding(String fname, JarFile jarFile, JspCompilationContext ctxt, ErrorDispatcher err) throws IOException, JasperException { InputStream inStream = JspUtil.getInputStream(fname, jarFile, ctxt, err); XMLEncodingDetector detector = new XMLEncodingDetector(); Object[] ret = detector.getEncoding(inStream, err); inStream.close(); return ret; }
Object [] encodingDesc = getEncodingName(b4, count); encoding = (String)(encodingDesc[0]); isBigEndian = (Boolean)(encodingDesc[1]); reader = createReader(stream, encoding, isBigEndian); } else { reader = createReader(stream, encoding, isBigEndian);
} else { Object[] ret = XMLEncodingDetector.getEncoding(absFileName, jarFile, ctxt, err); sourceEnc = (String) ret[0];
private void scanXMLDecl() throws IOException, JasperException { if (skipString("<?xml")) { fMarkupDepth++; // NOTE: special case where document starts with a PI // whose name starts with "xml" (e.g. "xmlfoo") if (XMLChar.isName(peekChar())) { fStringBuffer.clear(); fStringBuffer.append("xml"); while (XMLChar.isName(peekChar())) { fStringBuffer.append((char)scanChar()); } String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length); scanPIData(target, fString); } // standard XML declaration else { scanXMLDeclOrTextDecl(false); } } }
/** * Returns the next character on the input. * <p> * <strong>Note:</strong> The character is <em>not</em> consumed. * * @throws IOException Thrown if i/o error occurs. * @throws EOFException Thrown on end of file. */ public int peekChar() throws IOException { // load more characters, if needed if (fCurrentEntity.position == fCurrentEntity.count) { load(0, true); } // peek at character int c = fCurrentEntity.ch[fCurrentEntity.position]; // return peeked character if (fCurrentEntity.isExternal()) { return c != '\r' ? c : '\n'; } else { return c; } } // peekChar():int
private Object[] getEncoding(InputStream in, ErrorDispatcher err) throws IOException, JasperException { this.stream = in; this.err=err; createInitialReader(); scanXMLDecl(); return new Object[] { this.encoding, Boolean.valueOf(this.isEncodingSetInProlog), this.hasBom }; }
/** * Autodetects the encoding of the XML document supplied by the given * input stream. * * Encoding autodetection is done according to the XML 1.0 specification, * Appendix F.1: Detection Without External Encoding Information. * * @return Two-element array, where the first element (of type * java.lang.String) contains the name of the (auto)detected encoding, and * the second element (of type java.lang.Boolean) specifies whether the * encoding was specified using the 'encoding' attribute of an XML prolog * (TRUE) or autodetected (FALSE). */ public static Object[] getEncoding(String fname, JarFile jarFile, JspCompilationContext ctxt, ErrorDispatcher err) throws IOException, JasperException { InputStream inStream = JspUtil.getInputStream(fname, jarFile, ctxt, err); XMLEncodingDetector detector = new XMLEncodingDetector(); Object[] ret = detector.getEncoding(inStream, err); inStream.close(); return ret; }
Object [] encodingDesc = getEncodingName(b4, count); encoding = (String)(encodingDesc[0]); isBigEndian = (Boolean)(encodingDesc[1]); reader = createReader(stream, encoding, isBigEndian); } else { reader = createReader(stream, encoding, isBigEndian);