public <T extends Element> Document<T> parse(ReadableByteChannel buf, String base, ParserOptions options) throws ParseException { String charset = options.getCharset(); return parse(Channels.newReader(buf, charset != null ? charset : "utf-8"), base, options); }
public synchronized Parser setDefaultParserOptions(ParserOptions options) { // Ok, we need to make a defensive copy of the options, since otherwise // the caller still has access to the object, which means our access to // it isn't certain to be thread safe. try { this.options = (options != null) ? (ParserOptions)options.clone() : initDefaultParserOptions(); return this; } catch (CloneNotSupportedException cnse) { // This shouldn't actually happen throw new RuntimeException(cnse); } }
private FOMFactory getFomFactory(ParserOptions options) { FOMFactory factory = (options != null && options.getFactory() != null) ? (FOMFactory)options.getFactory() : null; if (factory == null) { Factory f = getFactory(); factory = (f instanceof FOMFactory) ? (FOMFactory)f : new FOMFactory(); } return factory; }
if (options == null) options = getDefaultParserOptions(); if (options.getCompressionCodecs() != null) { in = CompressionUtil.getDecodingInputStream(in, options.getCompressionCodecs()); String charset = options.getCharset(); if (charset == null && options.getAutodetectCharset()) { FOMSniffingInputStream sin = (in instanceof FOMSniffingInputStream) ? (FOMSniffingInputStream)in charset = sin.getEncoding(); if (charset != null) options.setCharset(charset); in = sin; if (options.getFilterRestrictedCharacters()) { Reader rdr = (charset == null) ? new FOMXmlRestrictedCharReader(in, options.getFilterRestrictedCharacterReplacement()) : new FOMXmlRestrictedCharReader(in, charset, options.getFilterRestrictedCharacterReplacement()); return parse(StAXUtils.createXMLStreamReader(rdr), base, options); } else {
private <T extends Element> Document<T> getDocument(FOMBuilder builder, IRI base, ParserOptions options) throws ParseException { Document<T> document = builder.getFomDocument(); try { if (base != null) document.setBaseUri(base.toString()); if (options != null && options.getCharset() != null) ((OMDocument)document).setCharsetEncoding(options.getCharset()); if (options != null) document.setMustPreserveWhitespace(options.getMustPreserveWhitespace()); } catch (Exception e) { if (!(e instanceof ParseException)) e = new ParseException(e); throw (ParseException)e; } return document; }
public T readFrom(Class<T> clazz, Type t, Annotation[] a, MediaType mt, MultivaluedMap<String, String> headers, InputStream is) throws IOException { Parser parser = ATOM_ENGINE.getParser(); synchronized (parser) { ParserOptions options = parser.getDefaultParserOptions(); if (options != null) { options.setAutodetectCharset(autodetectCharset); } } Document<T> doc = parser.parse(is); return doc.getRoot(); }
public <T extends Element> Document<T> parse(Reader in, String base, ParserOptions options) throws ParseException { if (in == null) throw new IllegalArgumentException(Localizer.get("READER.NOT.NULL")); try { if (options == null) options = getDefaultParserOptions(); if (options.getFilterRestrictedCharacters() && !(in instanceof FOMXmlRestrictedCharReader)) { in = new FOMXmlRestrictedCharReader(in, options.getFilterRestrictedCharacterReplacement()); } // return parse(StAXUtils.createXMLStreamReader(in), base, options); return parse(createXMLStreamReader(in), base, options); } catch (Exception e) { if (!(e instanceof ParseException)) e = new ParseException(e); throw (ParseException)e; } }
String charset = getCharacterEncoding(); if (charset != null) options.setCharset(charset); IRI cl = getContentLocation(); if (cl != null && !cl.isAbsolute()) {
public T readFrom(Class<T> clazz, Type t, Annotation[] a, MediaType mt, MultivaluedMap<String, String> headers, InputStream is) throws IOException { Parser parser = ATOM_ENGINE.getParser(); synchronized (parser) { ParserOptions options = parser.getDefaultParserOptions(); if (options != null) { options.setAutodetectCharset(autodetectCharset); } } XMLStreamReader reader = StaxUtils.createXMLStreamReader(is); Document<T> doc = parser.parse(reader); return doc.getRoot(); }
public <T extends Element> Document<T> parse( ReadableByteChannel buf, String base, ParserOptions options) throws ParseException { String charset = options.getCharset(); return parse( Channels.newReader( buf, charset!=null? charset:"utf-8"), base,options); }
public synchronized ParserOptions getDefaultParserOptions() { if (options == null) options = initDefaultParserOptions(); // Make a copy of the options, so that changes to it don't result in // changes to the Parser's defaults. Also, this allows us to remain // thread safe without having to make ParseOptions implementations // synchronized. try { return (ParserOptions)options.clone(); } catch (CloneNotSupportedException cnse) { // This shouldn't actually happen throw new RuntimeException(cnse); } }
public T readFrom(Class<T> clazz, Type t, Annotation[] a, MediaType mt, MultivaluedMap<String, String> headers, InputStream is) throws IOException { Parser parser = ATOM_ENGINE.getParser(); synchronized (parser) { ParserOptions options = parser.getDefaultParserOptions(); if (options != null) { options.setAutodetectCharset(autodetectCharset); } } XMLStreamReader reader = StaxUtils.createXMLStreamReader(is); Document<T> doc = parser.parse(reader); return doc.getRoot(); }
public synchronized ParserOptions getDefaultParserOptions() { if (options == null) options = initDefaultParserOptions(); // Make a copy of the options, so that changes to it don't result in // changes to the Parser's defaults. Also, this allows us to remain // thread safe without having to make ParseOptions implementations // synchronized. try { return (ParserOptions) options.clone(); } catch (CloneNotSupportedException cnse) { // This shouldn't actually happen throw new RuntimeException(cnse); } }
public synchronized Parser setDefaultParserOptions(ParserOptions options) { // Ok, we need to make a defensive copy of the options, since otherwise // the caller still has access to the object, which means our access to // it isn't certain to be thread safe. try { this.options = (options != null) ? (ParserOptions) options.clone() : initDefaultParserOptions(); return this; } catch (CloneNotSupportedException cnse) { // This shouldn't actually happen throw new RuntimeException(cnse); } }