/** * Constructor. * * @param pipe The parser input. * @throws IOException */ public ParserReader(ParserPipe pipe) throws IOException { this.unbuffered = pipe.unbuffered; if (pipe.isString()) { String in = pipe.getInputAsString(); this.r = new CharSequenceReader(in); this.buff = new char[in.length() < 1024 ? in.length() : 1024]; } else { Reader _r = pipe.getReader(); if (_r instanceof ParserReader) this.r = ((ParserReader)_r).r; else this.r = _r; this.buff = new char[1024]; } pipe.setPositionable(this); }
/** * Constructor. * * @param pipe The parser input. * @throws Exception */ protected ParserInputStream(ParserPipe pipe) throws Exception { this.is = pipe.getInputStream(); pipe.setPositionable(this); }
/** * Marks the current position. */ protected void mark() { if (pipe != null) { Position p = pipe.getPosition(); mark.line = p.line; mark.column = p.column; mark.position = p.position; } }
/** * Constructor. * * @param pipe The parser input. * @param decodeChars Whether the input is URL-encoded. * @throws Exception */ public UonReader(ParserPipe pipe, boolean decodeChars) throws Exception { super(pipe); this.decodeChars = decodeChars; if (pipe.isString()) { String in = pipe.getInputAsString(); this.buff = new char[in.length() < 1024 ? in.length() : 1024]; } else { this.buff = new char[1024]; } }
/** * Returns the contents of this pipe as a buffered reader. * * <p> * If the reader passed into this pipe is already a buffered reader, that reader will be returned. * * @return The contents of this pipe as a buffered reader. * @throws Exception */ public Reader getBufferedReader() throws Exception { return IOUtils.getBufferedReader(getReader()); }
private ParserReader createParserReader(Object in) throws Exception { return new ParserReader(new ParserPipe(in)); } }
try { @SuppressWarnings("resource") Reader r = pipe.getBufferedReader(); XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.IS_VALIDATING, validating); sr = factory.createXMLStreamReader(r); sr.nextTag(); pipe.setPositionable(this); } catch (Error e) { throw new ParseException(e.getLocalizedMessage());
@Override /* ParserSession */ protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception { try (ParserReader r = pipe.getParserReader()) { if (r == null) return null; return parseAnything(type, r, getOuter(), null); } }
@Override /* ParserSession */ @SuppressWarnings("unchecked") protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception { return (T)ImageIO.read(pipe.getInputStream()); } };
r.read(model, pipe.getBufferedReader(), null);
/** * Returns the input as a string. * * <p> * This always returns a value for input of type {@link CharSequence}. * <br>For other input types, use {@link BeanContext#BEAN_debug} setting to enable caching to a string * before parsing so that this method returns the input. * * @return The input as a string, or <jk>null</jk> if no pipe has been created or we're reading from an uncached reader or input stream source. */ public String getInputAsString() { return pipe == null ? null : pipe.getInputAsString(); }
} else if (input instanceof String) { inputString = (String)input; inputStream = new ByteArrayInputStream(convertFromString((String)input)); doClose = false; } else if (input instanceof File) {
/** * Returns the contents of this pipe as a buffered reader. * * <p> * If the reader passed into this pipe is already a buffered reader, that reader will be returned. * * @return The contents of this pipe as a buffered reader. * @throws Exception */ public Reader getBufferedReader() throws Exception { return IOUtils.getBufferedReader(getReader()); }
private UonReader r(String in, boolean decodeChars) throws Exception { return new UonReader(new ParserPipe(in), decodeChars); }
try { @SuppressWarnings("resource") Reader r = pipe.getBufferedReader(); XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.IS_VALIDATING, validating); sr = factory.createXMLStreamReader(r); sr.nextTag(); pipe.setPositionable(this); } catch (Error e) { throw new ParseException(e.getLocalizedMessage());
@Override /* ParserSession */ protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception { try (ParserReader r = pipe.getParserReader()) { if (r == null) return null; return parseAnything(type, r, getOuter(), null); } }
/** * Constructor. * * @param pipe The parser input. * @param decodeChars Whether the input is URL-encoded. * @throws Exception */ public UonReader(ParserPipe pipe, boolean decodeChars) throws Exception { super(pipe); this.decodeChars = decodeChars; if (pipe.isString()) { String in = pipe.getInputAsString(); this.buff = new char[in.length() < 1024 ? in.length() : 1024]; } else { this.buff = new char[1024]; } }
@Override /* ParserSession */ @SuppressWarnings("unchecked") protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception { return (T)ImageIO.read(pipe.getInputStream()); } };
r.read(model, pipe.getBufferedReader(), null);
/** * Returns the input as a string. * * <p> * This always returns a value for input of type {@link CharSequence}. * <br>For other input types, use {@link BeanContext#BEAN_debug} setting to enable caching to a string * before parsing so that this method returns the input. * * @return The input as a string, or <jk>null</jk> if no pipe has been created or we're reading from an uncached reader or input stream source. */ public String getInputAsString() { return pipe == null ? null : pipe.getInputAsString(); }