public static StreamReaderImpl construct(InputBootstrapper bs) throws XMLStreamException { return new StreamReaderImpl(bs.bootstrap()); }
@Override public final byte[] getAttributeAsBinary(int index, Base64Variant v) throws XMLStreamException { if (_currToken != START_ELEMENT) { throw new IllegalStateException(ErrorConsts.ERR_STATE_NOT_STELEM); } return _scanner.decodeAttrBinaryValue(index, v, _base64Decoder()); }
/** *<p> * Note: as per StAX 1.0 specs, this method does NOT close the underlying * input reader. (that is, unless the new StAX2 property * <code>org.codehaus.stax2.XMLInputFactory2#P_AUTO_CLOSE_INPUT</code> is * set to true). */ @Override public final void close() throws XMLStreamException { _closeScanner(false); }
protected int handlePrologEoi(boolean isProlog) throws XMLStreamException { // Either way, we can now close the reader close(); // It's ok to get EOF from epilog but not from prolog if (isProlog) { throwUnexpectedEOI(ErrorConsts.SUFFIX_IN_PROLOG); } return END_DOCUMENT; }
@Override public final int readElementAsIntArray(int[] value, int from, int length) throws XMLStreamException { return readElementAsArray(_decoderFactory().getIntArrayDecoder(value, from, length)); }
@Override public final QName getAttributeAsQName(int index) throws XMLStreamException { ValueDecoderFactory.QNameDecoder dec = _decoderFactory().getQNameDecoder(getNamespaceContext()); getAttributeAs(index, dec); return verifyQName(dec.getValue()); }
@Override public final int getElementAsInt() throws XMLStreamException { ValueDecoderFactory.IntDecoder dec = _decoderFactory().getIntDecoder(); getElementAs(dec); return dec.getValue(); }
@Override public final int getAttributeAsInt(int index) throws XMLStreamException { ValueDecoderFactory.IntDecoder dec = _decoderFactory().getIntDecoder(); getAttributeAs(index, dec); return dec.getValue(); }
@Override public final long[] getAttributeAsLongArray(int index) throws XMLStreamException { ValueDecoderFactory.LongArrayDecoder dec = _decoderFactory().getLongArrayDecoder(); getAttributeAsArray(index, dec); return dec.getValues(); }
@Override public final QName getElementAsQName() throws XMLStreamException { ValueDecoderFactory.QNameDecoder dec = _decoderFactory().getQNameDecoder(getNamespaceContext()); getElementAs(dec); return verifyQName(dec.getValue()); }
throwWfe(ErrorConsts.ERR_STATE_NOT_STELEM); int type = next(); if (type == END_ELEMENT) { return ""; _reportNonTextEvent(type); int type; while ((type = next()) != END_ELEMENT) { if (((1 << type) & MASK_GET_ELEMENT_TEXT) != 0) { if (acc == null) { acc.addText(text); acc.addText(getText()); continue; _reportNonTextEvent(type);
final CharArrayBase64Decoder dec = _base64Decoder(); int type = _currToken; if (_scanner.isEmptyTag()) { next(); return -1; type = next(); if (type == END_ELEMENT) { // Simple, no textual content return -1; throw _constructUnexpectedInTyped(type); } catch (IllegalArgumentException iae) { throw _constructTypeException(iae.getMessage(), ""); type = next(); if (type == COMMENT || type == PROCESSING_INSTRUCTION throw _constructTypeException("Incomplete base64 triplet at the end of decoded content", ""); } else if (left > 0) { // 1 or 2 more bytes of data, loop some more continue main_loop;
@Override public final void getElementAs(TypedValueDecoder tvd) throws XMLStreamException { // !!! TODO: optimize String value = getElementText(); value = value.trim(); if (value.length() == 0) { _handleEmptyValue(tvd); return; } try { tvd.decode(value); } catch (IllegalArgumentException iae) { throw _constructTypeException(iae, value); } }
protected XMLStreamReader2 constructSR(String systemId, Reader r, boolean forEventReader) throws XMLStreamException { ReaderConfig cfg = getNonSharedConfig(null, systemId, null, forEventReader, false); return StreamReaderImpl.construct(CharSourceBootstrapper.construct(cfg, r)); }
@Override public final void getAttributeAs(int index, TypedValueDecoder tvd) throws XMLStreamException { if (_currToken != START_ELEMENT) { throw new IllegalStateException(ErrorConsts.ERR_STATE_NOT_STELEM); } try { _scanner.decodeAttrValue(index, tvd); } catch (IllegalArgumentException iae) { throw _constructTypeException(iae, getAttributeValue(index)); } }
@Override public final byte[] getElementAsBinary(Base64Variant v) throws XMLStreamException { // note: code here is similar to Base64DecoderBase.aggregateAll(), see comments there Stax2Util.ByteAggregator aggr = _base64Decoder().getByteAggregator(); byte[] buffer = aggr.startAggregation(); while (true) { int offset = 0; int len = buffer.length; do { int readCount = readElementAsBinary(buffer, offset, len, v); if (readCount < 1) { // all done! return aggr.aggregateAll(buffer, offset); } offset += readCount; len -= readCount; } while (len > 0); buffer = aggr.addFullBlock(buffer); } }
next(); return -1; type = next(); if (type == END_ELEMENT) { // Simple, no textual content return -1; throw _constructUnexpectedInTyped(type); throw _constructUnexpectedInTyped(type); type = next();
protected XMLStreamException _constructUnexpectedInTyped(int nextToken) { if (nextToken == START_ELEMENT) { return _constructTypeException("Element content can not contain child START_ELEMENT when using Typed Access methods", null); } return _constructTypeException("Expected a text token, got "+ErrorConsts.tokenTypeDesc(nextToken), null); }
@Override protected void _reportNonTextEvent(int type) throws XMLStreamException { // for Async parser if (type == EVENT_INCOMPLETE) { throwWfe("Can not use text-aggregating methods with non-blocking parser, as they (may) require blocking"); } super._reportNonTextEvent(type); } }
@Override public final float getElementAsFloat() throws XMLStreamException { ValueDecoderFactory.FloatDecoder dec = _decoderFactory().getFloatDecoder(); getElementAs(dec); return dec.getValue(); }