public void startDocument(InputSource source) throws CSSException { // Unfortunately flute doesn't call parseCharset() method when it reaches a charset // declaration. The only place to get the charset is in this method. Flute use ASCII by // default to read the file except if it detects a valid charset definition. if (source.getEncoding() != null && !"ASCII".equals(source.getEncoding())) { // valid charset at-rule is defined in this file. CssCharset charset = new CssCharset(source.getEncoding()); addNode(charset); } }
public void startDocument(InputSource source) throws CSSException { // Unfortunately flute doesn't call parseCharset() method when it reaches a charset // declaration. The only place to get the charset is in this method. Flute use ASCII by // default to read the file except if it detects a valid charset definition. if (source.getEncoding() != null && !"ASCII".equals(source.getEncoding())) { // valid charset at-rule is defined in this file. CssCharset charset = new CssCharset(source.getEncoding()); addNode(charset); } }
/** * Convert the source into a Reader. Used only by DOM Level 2 parser methods. */ private Reader getReader(InputSource source) throws IOException { if (source.getCharacterStream() != null) { return source.getCharacterStream(); } else if (source.getByteStream() != null) { // My DOM level 2 implementation doesn't use this case. if (source.getEncoding() == null) { // unknown encoding, use ASCII as default. return new InputStreamReader(source.getByteStream(), "ASCII"); } else { return new InputStreamReader(source.getByteStream(), source.getEncoding()); } } else { // systemId // @@TODO throw new CSSException("not yet implemented"); } }
/** * Convert the source into a Reader. Used only by DOM Level 2 parser methods. */ private Reader getReader(InputSource source) throws IOException { if (source.getCharacterStream() != null) { return source.getCharacterStream(); } else if (source.getByteStream() != null) { // My DOM level 2 implementation doesn't use this case. if (source.getEncoding() == null) { // unknown encoding, use ASCII as default. return new InputStreamReader(source.getByteStream(), "ASCII"); } else { return new InputStreamReader(source.getByteStream(), source.getEncoding()); } } else { // systemId // @@TODO throw new CSSException("not yet implemented"); } }
/** * Convert the source into a Reader. Used only by DOM Level 2 parser methods. */ private Reader getReader( InputSource source ) throws IOException { if ( source.getCharacterStream() != null ) { return source.getCharacterStream(); } else if ( source.getByteStream() != null ) { // My DOM level 2 implementation doesn't use this case. if ( source.getEncoding() == null ) { // unknown encoding, use ASCII as default. return new InputStreamReader( source.getByteStream(), "ASCII" ); } else { return new InputStreamReader( source.getByteStream(), source.getEncoding() ); } } else { // systemId // @@TODO throw new CSSException( "not yet implemented" ); } }
private CharStream getCharStream(final InputSource source) throws IOException { if (source.getCharacterStream() != null) { return new CssCharStream(source.getCharacterStream(), 1, 1); } if (source.getByteStream() != null) { final InputStreamReader reader; final String encoding = source.getEncoding(); if (encoding == null || encoding.length() < 1) { reader = new InputStreamReader(source.getByteStream(), Charset.defaultCharset()); } else { reader = new InputStreamReader(source.getByteStream(), encoding); } return new CssCharStream(reader, 1, 1); } if (source.getURI() != null) { final InputStreamReader reader = new InputStreamReader(new URL(source.getURI()).openStream()); return new CssCharStream(reader, 1, 1); } return null; }
String encoding = source.getEncoding(); InputStream input = source.getByteStream(); if (!input.markSupported()) { if (source.getEncoding() != null) { if (!encoding.equals(source.getEncoding())) { throw new CSSException("invalid encoding information.");
if (source.getEncoding() != null) { if (!encoding.equals(source.getEncoding())) { throw new CSSException("invalid encoding information.");
if ( source.getEncoding() != null ) { if ( !encoding.equals( source.getEncoding() ) ) { throw new CSSException( "invalid encoding information." );
/** * Creates a scanner, given an InputSource. */ protected Scanner createScanner(InputSource source) { documentURI = source.getURI(); if (documentURI == null) { documentURI = ""; } Reader r = source.getCharacterStream(); if (r != null) { return new Scanner(r); } InputStream is = source.getByteStream(); if (is != null) { return new Scanner(is, source.getEncoding()); } String uri = source.getURI(); if (uri == null) { throw new CSSException(formatMessage("empty.source", null)); } try { ParsedURL purl = new ParsedURL(uri); is = purl.openStreamRaw(CSSConstants.CSS_MIME_TYPE); return new Scanner(is, source.getEncoding()); } catch (IOException e) { throw new CSSException(e); } }
/** * Creates a scanner, given an InputSource. */ protected Scanner createScanner(InputSource source) { documentURI = source.getURI(); if (documentURI == null) { documentURI = ""; } Reader r = source.getCharacterStream(); if (r != null) { return new Scanner(r); } InputStream is = source.getByteStream(); if (is != null) { return new Scanner(is, source.getEncoding()); } String uri = source.getURI(); if (uri == null) { throw new CSSException(formatMessage("empty.source", null)); } try { ParsedURL purl = new ParsedURL(uri); is = purl.openStreamRaw(CSSConstants.CSS_MIME_TYPE); return new Scanner(is, source.getEncoding()); } catch (IOException e) { throw new CSSException(e); } }
return new Scanner(is, source.getEncoding()); return new Scanner(is, source.getEncoding()); } catch (IOException e) { throw new CSSException(e);
/** * Creates a scanner, given an InputSource. */ protected Scanner createScanner(InputSource source) { documentURI = source.getURI(); if (documentURI == null) { documentURI = ""; } Reader r = source.getCharacterStream(); if (r != null) { return new Scanner(r); } InputStream is = source.getByteStream(); if (is != null) { return new Scanner(is, source.getEncoding()); } String uri = source.getURI(); if (uri == null) { throw new CSSException(formatMessage("empty.source", null)); } try { ParsedURL purl = new ParsedURL(uri); is = purl.openStreamRaw(CSSConstants.CSS_MIME_TYPE); return new Scanner(is, source.getEncoding()); } catch (IOException e) { throw new CSSException(e); } }
stylesheet.setCharset(parser.getInputSource().getEncoding()); return stylesheet;
return new Scanner(is, source.getEncoding());