/** * Method for appending specified processing instruction within this output container. * * <p>Note: for buffered (and not-yet-released) containers, will hold contents buffered until * release of container. */ public void addProcessingInstruction(String target, String data) throws XMLStreamException { if (_canOutputNewChild()) { _context.writeProcessingInstruction(target, data); } else { _linkNewChild(_context.createProcessingInstruction(target, data)); } }
/** * Typed output method for outputting double value as (textual) xml content. Equivalent to calling * <code>addCharacters(String.valueOf(value))</code> but likely more efficient (with streams that * support Typed Access API) as well as more explicit semantically. */ public void addValue(double value) throws XMLStreamException { if (_canOutputNewChild()) { _context.writeValue(value); } else { _linkNewChild(_context.createValue(value)); } }
/** * Method for appending specified entity reference this output container. * * <p>Note: for buffered (and not-yet-released) containers, will hold contents buffered until * release of container. * * @param name Name of the entity to reference: should <b>not</b> contain the leading '&' * character (which will get properly prepended by the stream writer) */ public void addEntityRef(String name) throws XMLStreamException { if (_canOutputNewChild()) { _context.writeEntityRef(name); } else { _linkNewChild(_context.createEntityRef(name)); } }
/** * Method for appending specified comment within this output container. * * <p>Note: for buffered (and not-yet-released) containers, will hold contents buffered until * release of container. */ public void addComment(String text) throws XMLStreamException { if (_canOutputNewChild()) { _context.writeComment(text); } else { _linkNewChild(_context.createComment(text)); } }
/** * Method for appending specified text as CDATA within this output container. * * <p>Note: for buffered (and not-yet-released) containers, will hold contents buffered until * release of container. */ public void addCData(char[] buf, int offset, int len) throws XMLStreamException { if (_canOutputNewChild()) { _context.writeCData(buf, offset, len); } else { _linkNewChild(_context.createCData(buf, offset, len)); } }
/** * Typed output method for outputting binary value (encoded using default Base64 encoding variant) * as (textual) xml content. * * @since 2.2 */ @SuppressWarnings("unchecked") public <T extends SMOutputContainer> T addValue(byte[] value, int offset, int length) throws XMLStreamException { if (_canOutputNewChild()) { _context.writeValue(value, offset, length); } else { _linkNewChild(_context.createValue(value, offset, length)); } return (T) this; }
/** * Method called to ensure that the passed-in namespace can be used for actual output operation. * It converts nulls to the proper "no namespace" instance, and ensures that (so far) unbound * namespaces are properly bound (including declaring them as needed). */ protected final SMNamespace _verifyNamespaceArg(SMNamespace ns) { if (ns == null) { return SMOutputContext.getEmptyNamespace(); } if (ns.isValidIn(_context)) { // hunky dory return ns; } /* Hmmh. Callers should know better than to share namespace * instances... but then again, we can easily fix the problem * even if they are shared: */ return getNamespace(ns.getURI()); }
/** * This method can be called to enable or disable heuristic indentation for the output done using * this output context. * * <p>Here are some example calls: * * <blockquote> * * context.setIndentation("\n ", 1, 2); // indent by lf and 2 spaces per level * context.setIndentation(null, 0, 0); // disable indentation * context.setIndentation("\r\n\t\t\t\t\t\t\t\t", 2, 1); // indent by windows lf and 1 tab per * level * * </blockquote> * * @param indentStr String to use for indentation; if non-null, will enable indentation, if null, * will disable it. Used in conjunction with the other arguments * @param startOffset Initial character offset for the first level of indentation (current * context; usually root context): basically, number of leading characters from <code> * indentStr</code> to output. * @param step Number of characters to add from the indentation String for each new level (and to * subtract when closing levels). */ public void setIndentation(String indentStr, int startOffset, int step) { _context.setIndentation(indentStr, startOffset, step); }
/** * Method for getting namespace instance that represents the specified URI, and if it is not yet * bound, tries to bind it to given prefix. Note however that actual prefix used may be different * due to conflicts: most important thing is that the specified URI will be bound to a valid * prefix. Actual prefix can be checked by looking at returned namespace object * * @return Namespace object which is bound to given namespace URI for scope of this container */ public final SMNamespace getNamespace(String uri, String prefPrefix) { return _context.getNamespace(uri, prefPrefix); }
/** * Convenience method for getting namespace instance that uniquely represents the specified URI * (uniquely meaning that for a given output context there are never more than one instances for a * given URI; which means that identity comparison is enough to check for equality of two * namespaces). Calls {@link SMOutputContext} to find the actual namespace instance. * * @return Namespace object which is bound to given namespace URI for scope of this container */ public final SMNamespace getNamespace(String uri) { return _context.getNamespace(uri); }