@Override public CSSInputStream getInput(Object source, String encoding) throws IOException { return CSSInputStream.urlStream((URL) source, encoding); }
/** * Sets a new encoding for the input stream. <b>Warning:</b> this resets the stream * i.e. a new connection is opened and all the data is read again. * @param enc The new encoding name. * @throws IOException */ public void setEncoding(String enc) throws IOException { if (source != null) //applicapble to URL streams only { String current = encoding; if (current == null) current = Charset.defaultCharset().name(); if (!current.equalsIgnoreCase(enc)) { source.close(); encoding = enc; CSSInputStream newstream = urlStream(url, encoding); input = newstream.input; } } }
/** * Sets a new encoding for the input stream. <b>Warning:</b> this resets the stream * i.e. a new connection is opened and all the data is read again. * @param enc The new encoding name. * @throws IOException */ public void setEncoding(String enc) throws IOException { if (source != null) //applicapble to URL streams only { String current = encoding; if (current == null) current = Charset.defaultCharset().name(); if (!current.equalsIgnoreCase(enc)) { source.close(); encoding = enc; CSSInputStream newstream = urlStream(url, network, encoding); input = newstream.input; } } }
/** * Creates input for CSSLexer * * @param source * Source, either raw data (String) or URL * @return Created stream * @throws IOException * When file is not found or other IO exception occurs */ protected static CSSInputStream getInput(Object source, NetworkProcessor network, String encoding, SourceType type) throws IOException { switch (type) { case INLINE: case EMBEDDED: return CSSInputStream.stringStream((String) source); case URL: return CSSInputStream.urlStream((URL) source, network, encoding); default: throw new RuntimeException("Coding error"); } }
setCharStream(CSSInputStream.urlStream(url, enc)); reset();