/** * Returns the contents of the specified input source, ignoring any {@link IOException}s. * @param source the input source from which to read * @return the contents of the specified input source, or an empty string if an {@link IOException} occurs */ private static String toString(final InputSource source) { try { return IOUtils.toString(source.getCharacterStream()); } catch (final IOException e) { return ""; } }
/** * Returns the contents of the specified input source, ignoring any {@link IOException}s. * @param source the input source from which to read * @return the contents of the specified input source, or an empty string if an {@link IOException} occurs */ private static String toString(final InputSource source) { try { return IOUtils.toString(source.getCharacterStream()); } catch (final IOException e) { return ""; } }
/** * Returns the contents of the specified input source, ignoring any {@link IOException}s. * @param source the input source from which to read * @return the contents of the specified input source, or an empty string if an {@link IOException} occurs */ private static String toString(final InputSource source) { try { return IOUtils.toString(source.getCharacterStream()); } catch (final IOException e) { return ""; } }
/** * Return true if <code>source</code> is valid and false otherwise. * * @param source * @throws IOException */ private void checkInputSource(InputSource source) throws IOException { Reader reader = source.getCharacterStream(); InputStream stream = source.getByteStream(); if (reader == null && stream == null) throw new IOException( "CharacterStream or ByteStream cannot be null for the InputSource."); }
/** * 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; }
/** * 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" ); } }
if (source.getCharacterStream() != null) { return new Generic_CharStream(source.getCharacterStream(), 1, 1); } else if (source.getByteStream() == null) { return new Generic_CharStream(source.getCharacterStream(), 1, 1);
if (source.getCharacterStream() != null) { return new Generic_CharStream(source.getCharacterStream(), 1, 1); } else if (source.getByteStream() == null) { return new Generic_CharStream(source.getCharacterStream(), 1, 1);
if ( source.getCharacterStream() != null ) { return new Generic_CharStream( source.getCharacterStream(), 1, 1 ); } else if ( source.getByteStream() == null ) { return new Generic_CharStream( source.getCharacterStream(), 1, 1 );
Reader r = source.getCharacterStream(); if (r != null) { return new Scanner(r);
Reader r = source.getCharacterStream(); if (r != null) { return new Scanner(r);
/** * 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); } }
/** * 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); } }