/** * Return an Iterable containing all the Namespaces introduced to the * current-level's scope. * @see #push(Element) for the details on the data order. * @return A read-only Iterable containing added Namespaces (may be empty); */ public Iterable<Namespace> addedForward() { if (added[depth].length == 0) { return EMPTYITER; } return new NamespaceIterable(added[depth], true); }
@Override public Iterator<Namespace> iterator() { return forward ? new ForwardWalker(namespaces) : new BackwardWalker(namespaces); } }
/** * Get all the Namespaces in-scope at the current level of the stack. * @see #push(Element) for the details on the data order. * @return A read-only Iterator containing added Namespaces (may be empty); */ @Override public Iterator<Namespace> iterator() { return new ForwardWalker(scope[depth]); }
@Override public void process(final Writer out, final Format format, final Document doc) throws IOException { printDocument(out, new FormatStack(format), new NamespaceStack(), doc); out.flush(); }
/** * Create a new in-scope level for the Stack based on an Attribute. * * @param att The attribute to contribute to the namespace scope. */ public void push(Attribute att) { final List<Namespace> toadd = new ArrayList<Namespace>(1); final Namespace mns = att.getNamespace(); // check to see whether the Namespace is new-to-scope. Namespace[] newscope = checkNamespace(toadd, mns, scope[depth]); pushStack(mns, newscope, toadd); }
/** * Inspect the current scope and return true if the specified namespace is * in scope. * @param ns The Namespace to check * @return true if the current scope contains that Namespace. */ public boolean isInScope(Namespace ns) { if (ns == scope[depth][0]) { return true; } final int ip = binarySearch(scope[depth], 1, scope[depth].length, ns); if (ip >= 0) { // we have the same prefix. return ns == scope[depth][ip]; } return false; }
@Override public void process(final XMLEventConsumer out, final Format format, final XMLEventFactory eventfactory, final Document doc) throws XMLStreamException { printDocument(out, new FormatStack(format), new NamespaceStack(), eventfactory, doc); }
/** * Return an Iterable containing all the Namespaces introduced to the * current-level's scope but in reverse order to {@link #addedForward()}. * @see #push(Element) for the details on the data order. * @return A read-only Iterable containing added Namespaces (may be empty); */ public Iterable<Namespace> addedReverse() { if (added[depth].length == 0) { return EMPTYITER; } return new NamespaceIterable(added[depth], false); }
@Override public void process(final XMLEventConsumer out, final Format format, final XMLEventFactory eventfactory, final Element element) throws XMLStreamException { // If this is the root element we could pre-initialize the // namespace stack with the namespaces printElement(out, new FormatStack(format), new NamespaceStack(), eventfactory, element); }
@Override public void process(final Writer out, final Format format, final Element element) throws IOException { // If this is the root element we could pre-initialize the // namespace stack with the namespaces printElement(out, new FormatStack(format), new NamespaceStack(), element); out.flush(); }
@Override public void process(final XMLStreamWriter out, final Format format, final Document doc) throws XMLStreamException { printDocument(out, new FormatStack(format), new NamespaceStack(), doc); out.flush(); }
@Override public org.w3c.dom.Document process(org.w3c.dom.Document basedoc, Format format, Document doc) { return printDocument(new FormatStack(format), new NamespaceStack(), basedoc, doc); }
@Override public org.w3c.dom.Element process(org.w3c.dom.Document basedoc, Format format, Element element) { return printElement(new FormatStack(format), new NamespaceStack(), basedoc, element); }
@Override public void process(final XMLStreamWriter out, final Format format, final Element element) throws XMLStreamException { // If this is the root element we could pre-initialize the // namespace stack with the namespaces printElement(out, new FormatStack(format), new NamespaceStack(), element); out.flush(); }
@Override public void process(final XMLStreamWriter out, final Format format, final List<? extends Content> list) throws XMLStreamException { final FormatStack fstack = new FormatStack(format); final Walker walker = buildWalker(fstack, list, false); printContent(out, fstack, new NamespaceStack(), walker); out.flush(); }
@Override public void process(final Writer out, final Format format, final List<? extends Content> list) throws IOException { FormatStack fstack = new FormatStack(format); Walker walker = buildWalker(fstack, list, true); printContent(out, fstack, new NamespaceStack(), walker); out.flush(); }
@Override public void process(final XMLEventConsumer out, final Format format, final XMLEventFactory eventfactory, final List<? extends Content> list) throws XMLStreamException { final FormatStack fstack = new FormatStack(format); final Walker walker = buildWalker(fstack, list, false); printContent(out, new FormatStack(format), new NamespaceStack(), eventfactory, walker); }
@Override public void process(SAXTarget out, Format format, Document doc) throws JDOMException { try { locate(out); printDocument(out, new FormatStack(format), new NamespaceStack(), doc); } catch (SAXException se) { throw new JDOMException( "Encountered a SAX exception processing the Document: ", se); } }
@Override public void process(SAXTarget out, Format format, Element element) throws JDOMException { try { locate(out); printElement(out, new FormatStack(format), new NamespaceStack(), element); } catch (SAXException se) { throw new JDOMException( "Encountered a SAX exception processing the Element: ", se); } }
@Override public void process(SAXTarget out, Format format, List<? extends Content> list) throws JDOMException { try { locate(out); final FormatStack fstack = new FormatStack(format); final Walker walker = buildWalker(fstack, list, false); printContent(out, fstack, new NamespaceStack(), walker); } catch (SAXException se) { throw new JDOMException( "Encountered a SAX exception processing the List: ", se); } }