public static WriterConfig createJ2MEDefaults() { return new WriterConfig(null, true, DEFAULT_FLAGS_J2ME, null); }
public EncodingXmlWriter(OutputStream out, WriterConfig cfg, String encoding, boolean autoclose) throws IOException { super(cfg, encoding, autoclose); mOut = out; mOutputBuffer = cfg.allocFullBBuffer(DEFAULT_BUFFER_SIZE); mOutputPtr = 0; }
/** * @param outs Underlying OutputStream that the writer * (<code>out</code>) is using, if known. Needed to support * (optional) access to the underlying stream */ public BufferingXmlWriter(Writer out, WriterConfig cfg, String enc, boolean autoclose, OutputStream outs, int bitsize) throws IOException { super(cfg, enc, autoclose); mOut = out; mOutputBuffer = cfg.allocFullCBuffer(DEFAULT_BUFFER_SIZE); mOutputBufLen = mOutputBuffer.length; mSmallWriteSize = DEFAULT_SMALL_SIZE; mOutputPtr = 0; mUnderlyingStream = outs; // Let's use double-quotes, as usual; alternative is apostrophe mEncQuoteChar = '"'; mEncQuoteEntity = """; /* Note: let's actually exclude couple of illegal chars for * unicode-based encoders. But we do not have to worry about * surrogates quite here, fortunately. */ if (bitsize < 1) { bitsize = guessEncodingBitSize(enc); } mEncHighChar = ((bitsize < 16) ? (1 << bitsize) : 0xFFFE); }
return automaticNamespacesEnabled() ? Boolean.TRUE : Boolean.FALSE; return willSupportNamespaces() ? Boolean.TRUE : Boolean.FALSE; case PROP_PROBLEM_REPORTER: return getProblemReporter(); return automaticEmptyElementsEnabled() ? Boolean.TRUE : Boolean.FALSE; case PROP_AUTO_CLOSE_OUTPUT: return willAutoCloseOutput() ? Boolean.TRUE : Boolean.FALSE; case PROP_AUTOMATIC_NS_PREFIX: return getAutomaticNsPrefix(); case PROP_TEXT_ESCAPER: return getTextEscaperFactory(); case PROP_ATTR_VALUE_ESCAPER: return getAttrValueEscaperFactory(); return willUseDoubleQuotesInXmlDecl() ? Boolean.TRUE : Boolean.FALSE; case PROP_OUTPUT_CDATA_AS_TEXT: return willOutputCDataAsText() ? Boolean.TRUE : Boolean.FALSE; case PROP_COPY_DEFAULT_ATTRS: return willCopyDefaultAttrs() ? Boolean.TRUE : Boolean.FALSE; case PROP_ESCAPE_CR: return willEscapeCr() ? Boolean.TRUE : Boolean.FALSE; case PROP_ADD_SPACE_AFTER_EMPTY_ELEM: return willAddSpaceAfterEmptyElem() ? Boolean.TRUE : Boolean.FALSE; case PROP_AUTOMATIC_END_ELEMENTS: return automaticEndElementsEnabled() ? Boolean.TRUE : Boolean.FALSE; return willValidateStructure() ? Boolean.TRUE : Boolean.FALSE;
/** * Called by {@link #createSW(OutputStream, Writer, String, boolean)} after all of the nessesary configuration * logic is complete. */ protected XMLStreamWriter2 createSW(String enc, WriterConfig cfg, XmlWriter xw) { if (cfg.willSupportNamespaces()) { if (cfg.automaticNamespacesEnabled()) { return new RepairingNsStreamWriter(xw, enc, cfg); } return new SimpleNsStreamWriter(xw, enc, cfg); } return new NonNsStreamWriter(xw, enc, cfg); }
private WstxDOMWrappingWriter(WriterConfig cfg, Node treeRoot) throws XMLStreamException { super(treeRoot, cfg.willSupportNamespaces(), cfg.automaticNamespacesEnabled()); mConfig = cfg; mAutoNsSeq = null; mAutomaticNsPrefix = mNsRepairing ? mConfig.getAutomaticNsPrefix() : null; /* Ok; we need a document node; or an element node; or a document * fragment node. */ switch (treeRoot.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: // both are ok, but no current element mCurrElem = DOMOutputElement.createRoot(treeRoot); mOpenElement = null; break; case Node.ELEMENT_NODE: // can make sub-tree... ok { // still need a virtual root node as parent DOMOutputElement root = DOMOutputElement.createRoot(treeRoot); Element elem = (Element) treeRoot; mOpenElement = mCurrElem = root.createChild(elem); } break; default: // other Nodes not usable throw new XMLStreamException("Can not create an XMLStreamWriter for a DOM node of type "+treeRoot.getClass()); } }
return automaticNamespacesEnabled() ? Boolean.TRUE : Boolean.FALSE; return willSupportNamespaces() ? Boolean.TRUE : Boolean.FALSE; case PROP_PROBLEM_REPORTER: return getProblemReporter(); return automaticEmptyElementsEnabled() ? Boolean.TRUE : Boolean.FALSE; case PROP_AUTOMATIC_NS_PREFIX: return getAutomaticNsPrefix(); case PROP_TEXT_ESCAPER: return getTextEscaperFactory(); case PROP_ATTR_VALUE_ESCAPER: return getAttrValueEscaperFactory(); return willOutputCDataAsText() ? Boolean.TRUE : Boolean.FALSE; case PROP_COPY_DEFAULT_ATTRS: return willCopyDefaultAttrs() ? Boolean.TRUE : Boolean.FALSE; case PROP_ESCAPE_CR: return willEscapeCr() ? Boolean.TRUE : Boolean.FALSE; return willValidateStructure() ? Boolean.TRUE : Boolean.FALSE; case PROP_VALIDATE_CONTENT: return willValidateContent() ? Boolean.TRUE : Boolean.FALSE; case PROP_VALIDATE_ATTR: return willValidateAttributes() ? Boolean.TRUE : Boolean.FALSE; case PROP_VALIDATE_NAMES: return willValidateNames() ? Boolean.TRUE : Boolean.FALSE; case PROP_FIX_CONTENT: return willFixContent() ? Boolean.TRUE : Boolean.FALSE;
protected final char[] getCopyBuffer() { char[] buf = mCopyBuffer; if (buf == null) { mCopyBuffer = buf = mConfig.allocMediumCBuffer(DEFAULT_COPYBUFFER_LEN); } return buf; }
public void configureForXmlConformance() { mConfig.configureForXmlConformance(); }
public void configureForSpeed() { mConfig.configureForSpeed(); }
public void configureForRobustness() { mConfig.configureForRobustness(); }
public WstxOutputFactory() { mConfig = WriterConfig.createFullDefaults(); }
return automaticNamespacesEnabled() ? Boolean.TRUE : Boolean.FALSE; return willSupportNamespaces() ? Boolean.TRUE : Boolean.FALSE; case PROP_PROBLEM_REPORTER: return getProblemReporter(); return automaticEmptyElementsEnabled() ? Boolean.TRUE : Boolean.FALSE; case PROP_AUTO_CLOSE_OUTPUT: return willAutoCloseOutput() ? Boolean.TRUE : Boolean.FALSE; case PROP_AUTOMATIC_NS_PREFIX: return getAutomaticNsPrefix(); case PROP_TEXT_ESCAPER: return getTextEscaperFactory(); case PROP_ATTR_VALUE_ESCAPER: return getAttrValueEscaperFactory(); return willUseDoubleQuotesInXmlDecl() ? Boolean.TRUE : Boolean.FALSE; case PROP_OUTPUT_CDATA_AS_TEXT: return willOutputCDataAsText() ? Boolean.TRUE : Boolean.FALSE; case PROP_COPY_DEFAULT_ATTRS: return willCopyDefaultAttrs() ? Boolean.TRUE : Boolean.FALSE; case PROP_ESCAPE_CR: return willEscapeCr() ? Boolean.TRUE : Boolean.FALSE; case PROP_ADD_SPACE_AFTER_EMPTY_ELEM: return willAddSpaceAfterEmptyElem() ? Boolean.TRUE : Boolean.FALSE; case PROP_AUTOMATIC_END_ELEMENTS: return automaticEndElementsEnabled() ? Boolean.TRUE : Boolean.FALSE; return willValidateStructure() ? Boolean.TRUE : Boolean.FALSE;
return automaticNamespacesEnabled() ? Boolean.TRUE : Boolean.FALSE; return willSupportNamespaces() ? Boolean.TRUE : Boolean.FALSE; case PROP_PROBLEM_REPORTER: return getProblemReporter(); return automaticEmptyElementsEnabled() ? Boolean.TRUE : Boolean.FALSE; case PROP_AUTOMATIC_NS_PREFIX: return getAutomaticNsPrefix(); case PROP_TEXT_ESCAPER: return getTextEscaperFactory(); case PROP_ATTR_VALUE_ESCAPER: return getAttrValueEscaperFactory(); return willOutputCDataAsText() ? Boolean.TRUE : Boolean.FALSE; case PROP_COPY_DEFAULT_ATTRS: return willCopyDefaultAttrs() ? Boolean.TRUE : Boolean.FALSE; case PROP_ESCAPE_CR: return willEscapeCr() ? Boolean.TRUE : Boolean.FALSE; return willValidateStructure() ? Boolean.TRUE : Boolean.FALSE; case PROP_VALIDATE_CONTENT: return willValidateContent() ? Boolean.TRUE : Boolean.FALSE; case PROP_VALIDATE_ATTR: return willValidateAttributes() ? Boolean.TRUE : Boolean.FALSE; case PROP_VALIDATE_NAMES: return willValidateNames() ? Boolean.TRUE : Boolean.FALSE; case PROP_FIX_CONTENT: return willFixContent() ? Boolean.TRUE : Boolean.FALSE;
private WstxDOMWrappingWriter(WriterConfig cfg, Node treeRoot) throws XMLStreamException { super(treeRoot, cfg.willSupportNamespaces(), cfg.automaticNamespacesEnabled()); mConfig = cfg; mAutoNsSeq = null; mAutomaticNsPrefix = mNsRepairing ? mConfig.getAutomaticNsPrefix() : null; /* Ok; we need a document node; or an element node; or a document * fragment node. */ switch (treeRoot.getNodeType()) { case Node.DOCUMENT_NODE: case Node.DOCUMENT_FRAGMENT_NODE: // both are ok, but no current element mCurrElem = DOMOutputElement.createRoot(treeRoot); mOpenElement = null; break; case Node.ELEMENT_NODE: // can make sub-tree... ok { // still need a virtual root node as parent DOMOutputElement root = DOMOutputElement.createRoot(treeRoot); Element elem = (Element) treeRoot; mOpenElement = mCurrElem = root.createChild(elem); } break; default: // other Nodes not usable throw new XMLStreamException("Can not create an XMLStreamWriter for a DOM node of type "+treeRoot.getClass()); } }
/** * Called by {@link #createSW(OutputStream, Writer, String, boolean)} after all of the nessesary configuration * logic is complete. */ protected XMLStreamWriter2 createSW(String enc, WriterConfig cfg, XmlWriter xw) { if (cfg.willSupportNamespaces()) { if (cfg.automaticNamespacesEnabled()) { return new RepairingNsStreamWriter(xw, enc, cfg); } return new SimpleNsStreamWriter(xw, enc, cfg); } return new NonNsStreamWriter(xw, enc, cfg); }
protected final char[] getCopyBuffer(int minLen) { char[] buf = mCopyBuffer; if (buf == null || minLen > buf.length) { mCopyBuffer = buf = mConfig.allocMediumCBuffer(Math.max(DEFAULT_COPYBUFFER_LEN, minLen)); } return buf; }
@Override public void configureForXmlConformance() { mConfig.configureForXmlConformance(); }
@Override public void configureForSpeed() { mConfig.configureForSpeed(); }
@Override public void configureForRobustness() { mConfig.configureForRobustness(); }