/** * Factory method for constructing readers. * * @param owner "Owner" of this reader, factory that created the reader; * needed for returning updated symbol table information after parsing. * @param input Input source used to read the XML document. * @param cfg Object that contains reader configuration info. */ public static TypedStreamReader createStreamReader (BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputBootstrapper bs, boolean forER) throws XMLStreamException { TypedStreamReader sr = new TypedStreamReader (bs, input, owner, cfg, createElementStack(cfg), forER); return sr; }
final CharArrayBase64Decoder dec = _base64Decoder(); int type = mCurrToken; throwNotTextualOrElem(type); type = next(); if (type == END_ELEMENT) { finishToken(false); _initBinaryChunks(v, dec, type, true); break; } 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; finishToken(false); _initBinaryChunks(v, dec, type, false); break;
throwNotTextualOrElem(type); type = next(); if (type == END_ELEMENT) { throw _constructUnexpectedInTyped(type); readCoalescedText(type, false); type = next(); continue; } else { throw _constructUnexpectedInTyped(type); break; type = next();
public QName getElementAsQName() throws XMLStreamException { ValueDecoderFactory.QNameDecoder dec = _decoderFactory().getQNameDecoder(getNamespaceContext()); getElementAs(dec); return _verifyQName(dec.getValue()); }
public QName getAttributeAsQName(int index) throws XMLStreamException { ValueDecoderFactory.QNameDecoder dec = _decoderFactory().getQNameDecoder(getNamespaceContext()); getAttributeAs(index, dec); return _verifyQName(dec.getValue()); }
throwParseError(ErrorConsts.ERR_STATE_NOT_STELEM); _handleEmptyValue(tvd); return; int type = next(); if (type == END_ELEMENT) { _handleEmptyValue(tvd); return; throwParseError("Expected a text token, got "+tokenTypeDesc(type)+"."); readCoalescedText(mCurrToken, false); mTextBuffer.decode(tvd); } catch (IllegalArgumentException iae) { throw _constructTypeException(iae, mTextBuffer.contentsAsString()); readEndElem(); return; while ((type = next()) != END_ELEMENT) { if (((1 << type) & MASK_GET_ELEMENT_TEXT) != 0) { if (mTokenState < TOKEN_FULL_SINGLE) { readCoalescedText(type, false); throwParseError("Expected a text token, got "+tokenTypeDesc(type)+"."); String tstr = Stax2Util.trimSpaces(str);
private final void _initBinaryChunks(Base64Variant v, CharArrayBase64Decoder dec, int type, boolean isFirst) throws XMLStreamException { if (type == CHARACTERS) { if (mTokenState < mStTextThreshold) { mTokenState = readTextSecondary(MIN_BINARY_CHUNK, false) ? TOKEN_FULL_SINGLE : TOKEN_PARTIAL_SINGLE; } } else if (type == CDATA) { if (mTokenState < mStTextThreshold) { mTokenState = readCDataSecondary(MIN_BINARY_CHUNK) ? TOKEN_FULL_SINGLE : TOKEN_PARTIAL_SINGLE; } } else { throw _constructUnexpectedInTyped(type); } mTextBuffer.initBinaryChunks(v, dec, isFirst); }
public boolean getElementAsBoolean() throws XMLStreamException { ValueDecoderFactory.BooleanDecoder dec = _decoderFactory().getBooleanDecoder(); getElementAs(dec); return dec.getValue(); }
public long getAttributeAsLong(int index) throws XMLStreamException { ValueDecoderFactory.LongDecoder dec = _decoderFactory().getLongDecoder(); getAttributeAs(index, dec); return dec.getValue(); }
public double[] getAttributeAsDoubleArray(int index) throws XMLStreamException { ValueDecoderFactory.DoubleArrayDecoder dec = _decoderFactory().getDoubleArrayDecoder(); getAttributeAsArray(index, dec); return dec.getValues(); }
public int readElementAsLongArray(long[] value, int from, int length) throws XMLStreamException { return readElementAsArray(_decoderFactory().getLongArrayDecoder(value, from, length)); }
public 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); } }
/** * Method called to handle value that has empty String * as representation. This will usually either lead to an * exception, or parsing to the default value for the * type in question (null for nullable types and so on). */ private void _handleEmptyValue(TypedValueDecoder dec) throws XMLStreamException { try { // default action is to throw an exception dec.handleEmptyValue(); } catch (IllegalArgumentException iae) { throw _constructTypeException(iae, ""); } }
public byte[] getAttributeAsBinary(int index, Base64Variant v) throws XMLStreamException { return mAttrCollector.decodeBinary(index, v, _base64Decoder(), this); }
super.finishDTD(copyContents); return;
throwParseError(ErrorConsts.ERR_STATE_NOT_STELEM); _handleEmptyValue(tvd); return; int type = next(); if (type == END_ELEMENT) { _handleEmptyValue(tvd); return; throwParseError("Expected a text token, got "+tokenTypeDesc(type)+"."); readCoalescedText(mCurrToken, false); mTextBuffer.decode(tvd); } catch (IllegalArgumentException iae) { throw _constructTypeException(iae, mTextBuffer.contentsAsString()); readEndElem(); return; while ((type = next()) != END_ELEMENT) { if (((1 << type) & MASK_GET_ELEMENT_TEXT) != 0) { if (mTokenState < TOKEN_FULL_SINGLE) { readCoalescedText(type, false); throwParseError("Expected a text token, got "+tokenTypeDesc(type)+"."); String tstr = Stax2Util.trimSpaces(str);
public QName getElementAsQName() throws XMLStreamException { ValueDecoderFactory.QNameDecoder dec = _decoderFactory().getQNameDecoder(getNamespaceContext()); getElementAs(dec); return _verifyQName(dec.getValue()); }
@Override public QName getAttributeAsQName(int index) throws XMLStreamException { ValueDecoderFactory.QNameDecoder dec = _decoderFactory().getQNameDecoder(getNamespaceContext()); getAttributeAs(index, dec); return _verifyQName(dec.getValue()); }
private final void _initBinaryChunks(Base64Variant v, CharArrayBase64Decoder dec, int type, boolean isFirst) throws XMLStreamException { if (type == CHARACTERS) { if (mTokenState < mStTextThreshold) { mTokenState = readTextSecondary(MIN_BINARY_CHUNK, false) ? TOKEN_FULL_SINGLE : TOKEN_PARTIAL_SINGLE; } } else if (type == CDATA) { if (mTokenState < mStTextThreshold) { mTokenState = readCDataSecondary(MIN_BINARY_CHUNK) ? TOKEN_FULL_SINGLE : TOKEN_PARTIAL_SINGLE; } } else { throw _constructUnexpectedInTyped(type); } mTextBuffer.initBinaryChunks(v, dec, isFirst); }
public float getElementAsFloat() throws XMLStreamException { ValueDecoderFactory.FloatDecoder dec = _decoderFactory().getFloatDecoder(); getElementAs(dec); return dec.getValue(); }