Refine search
public XMLEventReader createXMLEventReader(XMLStreamReader sr) throws XMLStreamException { return new WstxEventReader(createEventAllocator(), Stax2ReaderAdapter.wrapIfNecessary(sr)); }
/** * Method that should be used to add dynamic support for * {@link XMLStreamReader2}. Method will check whether the * stream reader passed happens to be a {@link XMLStreamReader2}; * and if it is, return it properly cast. If not, it will create * necessary wrapper to support features needed by StaxMate, * using vanilla Stax 1.0 interface. */ public static XMLStreamReader2 wrapIfNecessary(XMLStreamReader sr) { if (sr instanceof XMLStreamReader2) { return (XMLStreamReader2) sr; } return new Stax2ReaderAdapter(sr); }
public void closeCompletely() throws XMLStreamException { /* As usual, Stax 1.0 offers no generic way of doing just this. * But let's at least call the lame basic close() */ close(); }
public AttributeInfo getAttributeInfo() throws XMLStreamException { if (getEventType() != START_ELEMENT) { throwNotStartElem(getEventType()); } return this; }
/** * @return Internal subset portion of the DOCTYPE declaration, if any; * empty String if none */ public String getDTDInternalSubset() { /* According to basic Stax API, getText() <b>should</b> return * the internal subset. Not all implementations agree, so * this may or may not work. */ if (getEventType() == XMLStreamConstants.DTD) { return getText(); } return null; }
public void skipElement() throws XMLStreamException { if (getEventType() != START_ELEMENT) { throwNotStartElem(); } int nesting = 1; // need one more end elements than start elements while (true) { int type = next(); if (type == START_ELEMENT) { ++nesting; } else if (type == END_ELEMENT) { if (--nesting == 0) { break; } } } }
public String getPrefixedName() { switch (getEventType()) { case START_ELEMENT: case END_ELEMENT: { String prefix = getPrefix(); String ln = getLocalName(); if (prefix == null || prefix.length() == 0) { return ln; } StringBuffer sb = new StringBuffer(ln.length() + 1 + prefix.length()); sb.append(prefix); sb.append(':'); sb.append(ln); return sb.toString(); } case ENTITY_REFERENCE: return getLocalName(); case PROCESSING_INSTRUCTION: return getPITarget(); case DTD: return getDTDRootName(); } throw new IllegalStateException("Current state not START_ELEMENT, END_ELEMENT, ENTITY_REFERENCE, PROCESSING_INSTRUCTION or DTD"); }
public int findAttributeIndex(String nsURI, String localName) { if ("".equals(nsURI)) { nsURI = null; } for (int i = 0, len = getAttributeCount(); i < len; ++i) { if (getAttributeLocalName(i).equals(localName)) { String otherUri = getAttributeNamespace(i); if (nsURI == null) { if (otherUri == null || otherUri.length() == 0) { return i; } } else { if (nsURI.equals(otherUri)) { return i; } } } } return -1; }
public int getIdAttributeIndex() { for (int i = 0, len = getAttributeCount(); i < len; ++i) { if ("ID".equals(getAttributeType(i))) { return i; } } return -1; }
final StringBase64Decoder dec = _base64Decoder(); int type = getEventType(); throwNotStartElemOrTextual(type); type = next(); if (type == END_ELEMENT) { throwNotStartElemOrTextual(type); dec.init(v, true, getText()); break; count = dec.decode(resultBuffer, offset, maxLength); } catch (IllegalArgumentException iae) { throw _constructTypeException(iae, ""); if (maxLength < 1 || getEventType() == END_ELEMENT) { break; 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; throwNotStartElemOrTextual(type);
int type = getEventType(); if (type == END_ELEMENT) { // already done return -1; throw new IllegalStateException("First call to readElementAsArray() must be for a START_ELEMENT"); _typedContent = getElementText(); Location loc = getLocation(); throw new TypedXMLStreamException(value, iae.getMessage(), loc, iae); } finally {
public DTDInfo getDTDInfo() throws XMLStreamException { if (getEventType() != DTD) { return null; } return this; }
public final XMLStreamLocation2 getEndLocation() throws XMLStreamException { /* We don't really know whether location given is current, * start or end, but it's the best approximation we have * without knowing more about impl: */ return getCurrentLocation(); }
public String getPrefixedName() { switch (getEventType()) { case START_ELEMENT: case END_ELEMENT: { String prefix = getPrefix(); String ln = getLocalName(); if (prefix == null || prefix.length() == 0) { return ln; } StringBuffer sb = new StringBuffer(ln.length() + 1 + prefix.length()); sb.append(prefix); sb.append(':'); sb.append(ln); return sb.toString(); } case ENTITY_REFERENCE: return getLocalName(); case PROCESSING_INSTRUCTION: return getPITarget(); case DTD: return getDTDRootName(); } throw new IllegalStateException("Current state not START_ELEMENT, END_ELEMENT, ENTITY_REFERENCE, PROCESSING_INSTRUCTION or DTD"); }
public void skipElement() throws XMLStreamException { if (getEventType() != START_ELEMENT) { throwNotStartElem(); } int nesting = 1; // need one more end elements than start elements while (true) { int type = next(); if (type == START_ELEMENT) { ++nesting; } else if (type == END_ELEMENT) { if (--nesting == 0) { break; } } } }
public int findAttributeIndex(String nsURI, String localName) { if ("".equals(nsURI)) { nsURI = null; } for (int i = 0, len = getAttributeCount(); i < len; ++i) { if (getAttributeLocalName(i).equals(localName)) { String otherUri = getAttributeNamespace(i); if (nsURI == null) { if (otherUri == null || otherUri.length() == 0) { return i; } } else { if (nsURI.equals(otherUri)) { return i; } } } } return -1; }
public int getIdAttributeIndex() { for (int i = 0, len = getAttributeCount(); i < len; ++i) { if ("ID".equals(getAttributeType(i))) { return i; } } return -1; }
public AttributeInfo getAttributeInfo() throws XMLStreamException { if (getEventType() != START_ELEMENT) { throwNotStartElem(); } return this; }
/** * @return Internal subset portion of the DOCTYPE declaration, if any; * empty String if none */ public String getDTDInternalSubset() { /* According to basic Stax API, getText() <b>should</b> return * the internal subset. Not all implementations agree, so * this may or may not work. */ if (getEventType() == XMLStreamConstants.DTD) { return getText(); } return null; }
public DTDInfo getDTDInfo() throws XMLStreamException { if (getEventType() != DTD) { return null; } return this; }