|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ctc.wstx.sw.BaseStreamWriter
public abstract class BaseStreamWriter
Base class for XMLStreamWriter
implementations Woodstox has.
Contains partial stream writer implementation, plus utility methods
shared by concrete implementation classes. Main reason for such
abstract base class is to allow other parts of Woodstox core to refer
to any of stream writer implementations in general way.
Field Summary | |
---|---|
protected static int |
ATTR_MIN_ARRAYCOPY
|
protected static char |
CHAR_SPACE
|
protected static int |
DEFAULT_COPYBUFFER_LEN
|
protected boolean |
mAnyOutput
Flag that is set to true first time something has been output. |
protected AttributeCollector |
mAttrCollector
|
protected boolean |
mCfgAutomaticEmptyElems
|
protected boolean |
mCfgCDataAsText
|
protected boolean |
mCfgCopyDefaultAttrs
|
protected boolean |
mCheckAttrs
|
protected boolean |
mCheckStructure
|
protected WriterConfig |
mConfig
|
protected char[] |
mCopyBuffer
Intermediate buffer into which characters of a String can be copied, in cases where such a copy followed by array access is faster than calling String.charAt() (which
perhaps surprisingly is often case, and especially significant
for longer buffers). |
protected java.lang.String |
mDtdRootElem
Value passed as the expected root element, when using the multiple argument writeDTD(java.lang.String) method. |
protected boolean |
mEmptyElement
Flag that indicates that current element is an empty element (one that is explicitly defined as one, by calling a method -- NOT one that just happens to be empty). |
protected java.lang.String |
mEncoding
Encoding to use; may be passed from the factory (when a method that defines encoding is used), updated by a call to writeStartDocument() , or null if
neither. |
protected static int |
MIN_ARRAYCOPY
This constant defines minimum length of a String, for which it is beneficial to do an intermediate copy (using String.getChars()), and iterate over intermediate array, instead of iterating using String.charAt(). |
protected InputElementStack |
mInputElemStack
|
protected XMLStreamReader2 |
mLastReader
Reader that was last used for copy-through operation; used in conjunction with the other copy-through state variables. |
protected StreamReaderImpl |
mLastReaderImpl
|
protected boolean |
mStartElementOpen
Flag that is set during time that a start element is "open", ie. |
protected int |
mState
|
protected XMLValidator |
mValidator
Optional validator to use for validating output against one or more schemas, and/or for safe pretty-printing (indentation). |
protected int |
mVldContent
State value used with validation, to track types of content that is allowed at this point in output stream. |
protected ValidationProblemHandler |
mVldProbHandler
Custom validation problem handler, if any. |
protected XmlWriter |
mWriter
Actual physical writer to output serialized XML content to |
protected boolean |
mXml11
Since XML 1.1 has some differences to 1.0, we need to keep a flag to indicate if we were to output XML 1.1 document. |
protected static java.lang.String |
NO_NS_URI
|
protected static java.lang.String |
NO_PREFIX
|
protected static int |
STATE_EPILOG
|
protected static int |
STATE_PROLOG
|
protected static int |
STATE_TREE
|
Fields inherited from interface javax.xml.stream.XMLStreamConstants |
---|
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT |
Fields inherited from interface com.ctc.wstx.cfg.OutputConfigFlags |
---|
CFG_AUTOMATIC_EMPTY_ELEMS, CFG_AUTOMATIC_NS, CFG_COPY_DEFAULT_ATTRS, CFG_ENABLE_NS, CFG_ESCAPE_CR, CFG_FIX_CONTENT, CFG_OUTPUT_CDATA_AS_TEXT, CFG_VALIDATE_ATTR, CFG_VALIDATE_CONTENT, CFG_VALIDATE_NAMES, CFG_VALIDATE_STRUCTURE |
Constructor Summary | |
---|---|
protected |
BaseStreamWriter(XmlWriter xw,
java.lang.String enc,
WriterConfig cfg)
|
Method Summary | |
---|---|
int |
addDefaultAttribute(java.lang.String localName,
java.lang.String uri,
java.lang.String prefix,
java.lang.String value)
Adding default attribute values does not usually make sense on output side, so the implementation is a NOP for now. |
void |
close()
|
protected abstract void |
closeStartElement(boolean emptyElem)
Method called to close an open start element, when another main-level element (not namespace declaration or attribute) is being output; except for end element which is handled differently. |
void |
copyEventFromReader(XMLStreamReader2 sr,
boolean preserveEventData)
Method that essentially copies event that the specified reader has just read. |
abstract void |
copyStartElement(InputElementStack elemStack,
AttributeCollector attrCollector)
Implementation-dependant method called to fully copy START_ELEMENT event that the passed-in stream reader points to |
protected void |
doReportProblem(javax.xml.stream.XMLReporter rep,
java.lang.String probType,
java.lang.String msg,
javax.xml.stream.Location loc)
|
protected void |
doWriteStartDocument(java.lang.String version,
java.lang.String encoding,
java.lang.String standAlone)
|
int |
findAttributeIndex(java.lang.String nsURI,
java.lang.String localName)
|
void |
flush()
|
int |
getAttributeCount()
This method returns number of attributes accessible from within currently active start element. |
java.lang.String |
getAttributeLocalName(int index)
|
java.lang.String |
getAttributeNamespace(int index)
|
java.lang.String |
getAttributePrefix(int index)
|
java.lang.String |
getAttributeValue(int index)
|
java.lang.String |
getAttributeValue(java.lang.String nsURI,
java.lang.String localName)
|
java.lang.String |
getBaseUri()
As of now, there is no way to specify the base URI. |
abstract javax.xml.namespace.QName |
getCurrentElementName()
Method that can be used to access name information of the innermost (top) element in the element stack. |
java.lang.String |
getEncoding()
Method that can be called to get information about encoding that this writer is using (or at least claims is using). |
XMLStreamLocation2 |
getLocation()
Method that should return current output location, if the writer keeps track of it; null if it does not. |
abstract javax.xml.namespace.NamespaceContext |
getNamespaceContext()
|
abstract java.lang.String |
getNamespaceURI(java.lang.String prefix)
Method that can be called by the validator to resolve a namespace prefix of the currently active top-level element. |
abstract java.lang.String |
getPrefix(java.lang.String uri)
|
java.lang.Object |
getProperty(java.lang.String name)
|
protected abstract java.lang.String |
getTopElementDesc()
|
javax.xml.stream.Location |
getValidationLocation()
Method that will return the location that best represents current location within document to be validated, if such information is available. |
java.lang.String |
getXmlVersion()
Method that validator can call to figure out which xml version document being validated declared (if none, "1.0" is assumed as per xml specifications 1.0 and 1.1). |
protected boolean |
inPrologOrEpilog()
|
boolean |
isNotationDeclared(java.lang.String name)
|
boolean |
isPropertySupported(java.lang.String name)
Method similar to XMLOutputFactory.isPropertySupported(java.lang.String) , used
to determine whether a property is supported by the Writer
instance. |
boolean |
isUnparsedEntityDeclared(java.lang.String name)
|
protected boolean |
isValidating()
Method that is used by output classes to determine whether we are in validating mode. |
protected static void |
reportIllegalArg(java.lang.String msg)
|
protected static void |
reportIllegalMethod(java.lang.String msg)
Method called when an illegal method (namespace-specific method on non-ns writer) is called by the application. |
protected void |
reportInvalidContent(int evtType)
|
protected static void |
reportNwfAttr(java.lang.String msg)
This is the method called when an output method call violates attribute well-formedness checks (trying to output dup attrs) and WstxOutputProperties.P_OUTPUT_VALIDATE_NAMES is
is enabled. |
protected static void |
reportNwfAttr(java.lang.String msg,
java.lang.Object arg)
|
protected static void |
reportNwfContent(java.lang.String msg)
This is the method called when an output method call violates content well-formedness checks and WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT is
is enabled. |
protected static void |
reportNwfContent(java.lang.String msg,
java.lang.Object arg)
|
protected static void |
reportNwfStructure(java.lang.String msg)
This is the method called when an output method call violates structural well-formedness checks and WstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE is
is enabled. |
protected static void |
reportNwfStructure(java.lang.String msg,
java.lang.Object arg)
|
void |
reportProblem(XMLValidationProblem prob)
Method called by the validator, upon encountering a validation problem. |
void |
reportValidationProblem(javax.xml.stream.Location loc,
java.lang.String msg)
|
void |
reportValidationProblem(java.lang.String msg)
|
void |
reportValidationProblem(java.lang.String msg,
int severity)
|
void |
reportValidationProblem(java.lang.String msg,
javax.xml.stream.Location loc,
int severity)
|
void |
reportValidationProblem(java.lang.String format,
java.lang.Object arg)
|
void |
reportValidationProblem(java.lang.String format,
java.lang.Object arg,
java.lang.Object arg2)
|
abstract void |
setDefaultNamespace(java.lang.String uri)
|
abstract void |
setNamespaceContext(javax.xml.namespace.NamespaceContext context)
|
abstract void |
setPrefix(java.lang.String prefix,
java.lang.String uri)
|
boolean |
setProperty(java.lang.String name,
java.lang.Object value)
Method that can be used to set per-writer properties; a subset of properties one can set via matching XMLOutputFactory2
instance. |
ValidationProblemHandler |
setValidationProblemHandler(ValidationProblemHandler h)
Method that application can call to define a custom handler for validation problems encountered during validation process. |
XMLValidator |
stopValidatingAgainst(XMLValidationSchema schema)
Method that can be called by application to stop validating output against a schema, for which Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
was called earlier. |
XMLValidator |
stopValidatingAgainst(XMLValidator validator)
Method that can be called by application to stop validating output using specified validator. |
protected static void |
throwFromIOE(java.io.IOException ioe)
|
protected static void |
throwOutputError(java.lang.String msg)
|
protected static void |
throwOutputError(java.lang.String format,
java.lang.Object arg)
|
java.lang.String |
toString()
Helper method used for ensuring that each type of a problem is only reported once per instance. |
XMLValidator |
validateAgainst(XMLValidationSchema schema)
Method that will construct a XMLValidator instance from the
given schema (unless a validator for that schema has already been
added),
initialize it if necessary, and make validatable object (reader,
writer)
call appropriate validation methods from this point on until the
end of the document (that is, it's not scoped with sub-trees), or until
validator is removed by an explicit call to
Validatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema) . |
protected void |
verifyRootElement(java.lang.String localName,
java.lang.String prefix)
|
protected void |
verifyWriteCData()
|
protected void |
verifyWriteDTD()
|
java.io.Writer |
wrapAsRawWriter()
Method that can be called to get a wrapper instance that can be used to essentially call the writeRaw
method via regular Writer interface. |
java.io.Writer |
wrapAsTextWriter()
Method that can be called to get a wrapper instance that can be used to essentially call the writeCharacters
method via regular Writer interface. |
abstract void |
writeAttribute(java.lang.String localName,
java.lang.String value)
|
abstract void |
writeAttribute(java.lang.String nsURI,
java.lang.String localName,
java.lang.String value)
|
abstract void |
writeAttribute(java.lang.String prefix,
java.lang.String nsURI,
java.lang.String localName,
java.lang.String value)
|
void |
writeCData(char[] cbuf,
int start,
int len)
|
void |
writeCData(java.lang.String data)
|
void |
writeCharacters(char[] text,
int start,
int len)
|
void |
writeCharacters(javax.xml.stream.events.Characters ch)
Method called by WstxEventWriter (instead of
more generic
text output methods), so that we can verify (if necessary) that
this character output type is legal in this context. |
void |
writeCharacters(java.lang.String text)
|
void |
writeComment(java.lang.String data)
|
abstract void |
writeDefaultNamespace(java.lang.String nsURI)
|
void |
writeDTD(DTDInfo info)
|
void |
writeDTD(java.lang.String dtd)
|
void |
writeDTD(java.lang.String rootName,
java.lang.String systemId,
java.lang.String publicId,
java.lang.String internalSubset)
|
abstract void |
writeEmptyElement(java.lang.String localName)
|
abstract void |
writeEmptyElement(java.lang.String nsURI,
java.lang.String localName)
|
abstract void |
writeEmptyElement(java.lang.String prefix,
java.lang.String localName,
java.lang.String nsURI)
|
void |
writeEndDocument()
|
abstract void |
writeEndElement()
|
abstract void |
writeEndElement(javax.xml.namespace.QName name)
Method called by WstxEventWriter (instead of the version
that takes no argument), so that we can verify it does match the
start element, if necessary |
void |
writeEntityRef(java.lang.String name)
|
abstract void |
writeFullEndElement()
Method similar to XMLStreamWriter.writeEndElement() , but that will always
write the full end element, instead of empty element. |
abstract void |
writeNamespace(java.lang.String prefix,
java.lang.String nsURI)
|
void |
writeProcessingInstruction(java.lang.String target)
|
void |
writeProcessingInstruction(java.lang.String target,
java.lang.String data)
|
void |
writeRaw(char[] text,
int offset,
int length)
Method that writes specified content as is, without encoding or deciphering it in any way. |
void |
writeRaw(java.lang.String text)
Method that writes specified content as is, without encoding or deciphering it in any way. |
void |
writeRaw(java.lang.String text,
int start,
int offset)
|
void |
writeStartDocument()
|
void |
writeStartDocument(java.lang.String version)
|
void |
writeStartDocument(java.lang.String encoding,
java.lang.String version)
|
void |
writeStartDocument(java.lang.String version,
java.lang.String encoding,
boolean standAlone)
|
abstract void |
writeStartElement(javax.xml.stream.events.StartElement elem)
Convenience method needed by WstxEventWriter , to use when
writing a start element, and possibly its attributes and namespace
declarations. |
abstract void |
writeStartElement(java.lang.String localName)
|
abstract void |
writeStartElement(java.lang.String nsURI,
java.lang.String localName)
|
abstract void |
writeStartElement(java.lang.String prefix,
java.lang.String localName,
java.lang.String nsURI)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final int STATE_PROLOG
protected static final int STATE_TREE
protected static final int STATE_EPILOG
protected static final char CHAR_SPACE
protected static final java.lang.String NO_NS_URI
protected static final java.lang.String NO_PREFIX
protected static final int MIN_ARRAYCOPY
protected static final int ATTR_MIN_ARRAYCOPY
protected static final int DEFAULT_COPYBUFFER_LEN
protected final XmlWriter mWriter
protected char[] mCopyBuffer
String.charAt()
(which
perhaps surprisingly is often case, and especially significant
for longer buffers).
protected final WriterConfig mConfig
protected final boolean mCfgCDataAsText
protected final boolean mCfgCopyDefaultAttrs
protected final boolean mCfgAutomaticEmptyElems
protected boolean mCheckStructure
protected boolean mCheckAttrs
protected java.lang.String mEncoding
writeStartDocument()
, or null if
neither. Is passed to the escaping writer factory to
allow escaping writers to do additional escaping if
necessary (like encapsulating non-ascii chars in a doc
encoded usig ascii).
protected XMLValidator mValidator
protected boolean mXml11
protected ValidationProblemHandler mVldProbHandler
protected int mState
protected boolean mAnyOutput
protected boolean mStartElementOpen
protected boolean mEmptyElement
protected int mVldContent
protected java.lang.String mDtdRootElem
writeDTD(java.lang.String)
method. Will be used in structurally
validating mode (and in dtd-validating mode, since that automatically
enables structural validation as well, to pre-filter well-formedness
errors that validators might have trouble dealing with).
protected XMLStreamReader2 mLastReader
protected StreamReaderImpl mLastReaderImpl
protected AttributeCollector mAttrCollector
protected InputElementStack mInputElemStack
Constructor Detail |
---|
protected BaseStreamWriter(XmlWriter xw, java.lang.String enc, WriterConfig cfg)
Method Detail |
---|
public void close() throws javax.xml.stream.XMLStreamException
close
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void flush() throws javax.xml.stream.XMLStreamException
flush
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract javax.xml.namespace.NamespaceContext getNamespaceContext()
getNamespaceContext
in interface javax.xml.stream.XMLStreamWriter
public abstract java.lang.String getPrefix(java.lang.String uri)
getPrefix
in interface javax.xml.stream.XMLStreamWriter
public java.lang.Object getProperty(java.lang.String name)
getProperty
in interface javax.xml.stream.XMLStreamWriter
public abstract void setDefaultNamespace(java.lang.String uri) throws javax.xml.stream.XMLStreamException
setDefaultNamespace
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void setNamespaceContext(javax.xml.namespace.NamespaceContext context) throws javax.xml.stream.XMLStreamException
setNamespaceContext
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void setPrefix(java.lang.String prefix, java.lang.String uri) throws javax.xml.stream.XMLStreamException
setPrefix
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeAttribute(java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException
writeAttribute
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeAttribute(java.lang.String nsURI, java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException
writeAttribute
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException
writeAttribute
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeCData(java.lang.String data) throws javax.xml.stream.XMLStreamException
writeCData
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeCharacters(char[] text, int start, int len) throws javax.xml.stream.XMLStreamException
writeCharacters
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeCharacters(java.lang.String text) throws javax.xml.stream.XMLStreamException
writeCharacters
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeComment(java.lang.String data) throws javax.xml.stream.XMLStreamException
writeComment
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeDefaultNamespace(java.lang.String nsURI) throws javax.xml.stream.XMLStreamException
writeDefaultNamespace
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeDTD(java.lang.String dtd) throws javax.xml.stream.XMLStreamException
writeDTD
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeEmptyElement(java.lang.String localName) throws javax.xml.stream.XMLStreamException
writeEmptyElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeEmptyElement(java.lang.String nsURI, java.lang.String localName) throws javax.xml.stream.XMLStreamException
writeEmptyElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeEmptyElement(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI) throws javax.xml.stream.XMLStreamException
writeEmptyElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeEndDocument() throws javax.xml.stream.XMLStreamException
writeEndDocument
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeEndElement() throws javax.xml.stream.XMLStreamException
writeEndElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeEntityRef(java.lang.String name) throws javax.xml.stream.XMLStreamException
writeEntityRef
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeNamespace(java.lang.String prefix, java.lang.String nsURI) throws javax.xml.stream.XMLStreamException
writeNamespace
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeProcessingInstruction(java.lang.String target) throws javax.xml.stream.XMLStreamException
writeProcessingInstruction
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeProcessingInstruction(java.lang.String target, java.lang.String data) throws javax.xml.stream.XMLStreamException
writeProcessingInstruction
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeStartDocument() throws javax.xml.stream.XMLStreamException
writeStartDocument
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeStartDocument(java.lang.String version) throws javax.xml.stream.XMLStreamException
writeStartDocument
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void writeStartDocument(java.lang.String encoding, java.lang.String version) throws javax.xml.stream.XMLStreamException
writeStartDocument
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
protected void doWriteStartDocument(java.lang.String version, java.lang.String encoding, java.lang.String standAlone) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public abstract void writeStartElement(java.lang.String localName) throws javax.xml.stream.XMLStreamException
writeStartElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeStartElement(java.lang.String nsURI, java.lang.String localName) throws javax.xml.stream.XMLStreamException
writeStartElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public abstract void writeStartElement(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI) throws javax.xml.stream.XMLStreamException
writeStartElement
in interface javax.xml.stream.XMLStreamWriter
javax.xml.stream.XMLStreamException
public void copyEventFromReader(XMLStreamReader2 sr, boolean preserveEventData) throws javax.xml.stream.XMLStreamException
copyEventFromReader
in interface XMLStreamWriter2
sr
- Stream reader to use for accessing event to copypreserveEventData
- If true, writer is not allowed to change
the state of the reader (so that all the data associated with the
current event has to be preserved); if false, writer is allowed
to use methods that may cause some data to be discarded. Setting
this to false may improve the performance, since it may allow
full no-copy streaming of data, especially textual contents.
javax.xml.stream.XMLStreamException
public boolean isPropertySupported(java.lang.String name)
XMLStreamWriter2
XMLOutputFactory.isPropertySupported(java.lang.String)
, used
to determine whether a property is supported by the Writer
instance. This means that this method may return false
for some properties that the output factory does support: specifically,
it should only return true if the value is mutable on per-instance
basis. False means that either the property is not recognized, or
is not mutable via writer instance.
isPropertySupported
in interface XMLStreamWriter2
public boolean setProperty(java.lang.String name, java.lang.Object value)
XMLStreamWriter2
XMLOutputFactory2
instance. Exactly which methods are mutable is implementation
specific.
setProperty
in interface XMLStreamWriter2
name
- Name of the property to setvalue
- Value to set property to.
public XMLValidator validateAgainst(XMLValidationSchema schema) throws javax.xml.stream.XMLStreamException
Validatable
XMLValidator
instance from the
given schema (unless a validator for that schema has already been
added),
initialize it if necessary, and make validatable object (reader,
writer)
call appropriate validation methods from this point on until the
end of the document (that is, it's not scoped with sub-trees), or until
validator is removed by an explicit call to
Validatable.stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
.
Note that while this method can be called at any point in output processing, validator instances are not required to be able to handle addition at other points than right before outputting the root element.
validateAgainst
in interface Validatable
javax.xml.stream.XMLStreamException
public XMLValidator stopValidatingAgainst(XMLValidationSchema schema) throws javax.xml.stream.XMLStreamException
Validatable
Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
was called earlier.
stopValidatingAgainst
in interface Validatable
javax.xml.stream.XMLStreamException
public XMLValidator stopValidatingAgainst(XMLValidator validator) throws javax.xml.stream.XMLStreamException
Validatable
Validatable.validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema)
.
Note: the specified validator is compared for identity with validators in use, not for equality.
stopValidatingAgainst
in interface Validatable
validator
)
if it was being used for validating current document; null if not.
javax.xml.stream.XMLStreamException
public ValidationProblemHandler setValidationProblemHandler(ValidationProblemHandler h)
Validatable
setValidationProblemHandler
in interface Validatable
h
- Handler to install, if non null; if null, indicates that
the default (implementation-specific) handling should be used
public XMLStreamLocation2 getLocation()
XMLStreamWriter2
getLocation
in interface XMLStreamWriter2
public java.lang.String getEncoding()
XMLStreamWriter2
XMLOutputFactory
writeStartDocument
method (explicitly
or implicity; latter in cases where defaults are imposed
by Stax specification)
getEncoding
in interface XMLStreamWriter2
public void writeCData(char[] cbuf, int start, int len) throws javax.xml.stream.XMLStreamException
writeCData
in interface XMLStreamWriter2
javax.xml.stream.XMLStreamException
public void writeDTD(DTDInfo info) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeDTD(java.lang.String rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset) throws javax.xml.stream.XMLStreamException
writeDTD
in interface XMLStreamWriter2
javax.xml.stream.XMLStreamException
public abstract void writeFullEndElement() throws javax.xml.stream.XMLStreamException
XMLStreamWriter2
XMLStreamWriter.writeEndElement()
, but that will always
write the full end element, instead of empty element. This only
matters for cases where the element itself has no content, and
if writer is allowed to write empty elements when it encounters
such start/end element write pairs.
writeFullEndElement
in interface XMLStreamWriter2
javax.xml.stream.XMLStreamException
public void writeStartDocument(java.lang.String version, java.lang.String encoding, boolean standAlone) throws javax.xml.stream.XMLStreamException
writeStartDocument
in interface XMLStreamWriter2
javax.xml.stream.XMLStreamException
public void writeRaw(java.lang.String text) throws javax.xml.stream.XMLStreamException
XMLStreamWriter2
Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.
writeRaw
in interface XMLStreamWriter2
javax.xml.stream.XMLStreamException
public void writeRaw(java.lang.String text, int start, int offset) throws javax.xml.stream.XMLStreamException
writeRaw
in interface XMLStreamWriter2
javax.xml.stream.XMLStreamException
public void writeRaw(char[] text, int offset, int length) throws javax.xml.stream.XMLStreamException
XMLStreamWriter2
Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.
writeRaw
in interface XMLStreamWriter2
javax.xml.stream.XMLStreamException
public java.lang.String getXmlVersion()
ValidationContext
getXmlVersion
in interface ValidationContext
public abstract javax.xml.namespace.QName getCurrentElementName()
ValidationContext
getCurrentElementName
in interface ValidationContext
public abstract java.lang.String getNamespaceURI(java.lang.String prefix)
ValidationContext
getNamespaceURI
in interface ValidationContext
public java.lang.String getBaseUri()
getBaseUri
in interface ValidationContext
public javax.xml.stream.Location getValidationLocation()
ValidationContext
Note: it is likely that even when a location is known, it may not be very accurate; for example, when attributes are validated, it is possible that they all would point to a single location that may point to the start of the element that contains attributes.
getValidationLocation
in interface ValidationContext
public void reportProblem(XMLValidationProblem prob) throws XMLValidationException
ValidationContext
ValidationProblemHandler
be set by the application,
to define handling.
reportProblem
in interface ValidationContext
XMLValidationException
public int addDefaultAttribute(java.lang.String localName, java.lang.String uri, java.lang.String prefix, java.lang.String value)
addDefaultAttribute
in interface ValidationContext
public boolean isNotationDeclared(java.lang.String name)
isNotationDeclared
in interface ValidationContext
public boolean isUnparsedEntityDeclared(java.lang.String name)
isUnparsedEntityDeclared
in interface ValidationContext
public int getAttributeCount()
ValidationContext
Note: this method is only guaranteed to be callable during execution
of XMLValidator
methods
XMLValidator.validateElementStart(java.lang.String, java.lang.String, java.lang.String)
,
XMLValidator.validateAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
and
XMLValidator.validateElementAndAttributes()
. At other times
implementations may choose to allow it to be called (for example,
with information regarding last start element processed), to throw
a IllegalArgumentException
, or to return 0 to indicate no
attribute information is available.
Also note that whether defaulted attributes (attributes for which values are only available via attribute defaulting) are accessible depends on exact time when this method is called, and in general can not be assumed to function reliably.
getAttributeCount
in interface ValidationContext
public java.lang.String getAttributeLocalName(int index)
getAttributeLocalName
in interface ValidationContext
public java.lang.String getAttributeNamespace(int index)
getAttributeNamespace
in interface ValidationContext
public java.lang.String getAttributePrefix(int index)
getAttributePrefix
in interface ValidationContext
public java.lang.String getAttributeValue(int index)
getAttributeValue
in interface ValidationContext
public java.lang.String getAttributeValue(java.lang.String nsURI, java.lang.String localName)
getAttributeValue
in interface ValidationContext
public int findAttributeIndex(java.lang.String nsURI, java.lang.String localName)
findAttributeIndex
in interface ValidationContext
public final java.io.Writer wrapAsRawWriter()
writeRaw
method via regular Writer
interface.
public final java.io.Writer wrapAsTextWriter()
writeCharacters
method via regular Writer
interface.
protected boolean isValidating()
Note: current implementation of this method is not perfect; it may be possible it can return true even if we are only using a DTD to get some limited info, without validating?
public abstract void writeStartElement(javax.xml.stream.events.StartElement elem) throws javax.xml.stream.XMLStreamException
WstxEventWriter
, to use when
writing a start element, and possibly its attributes and namespace
declarations.
javax.xml.stream.XMLStreamException
public abstract void writeEndElement(javax.xml.namespace.QName name) throws javax.xml.stream.XMLStreamException
WstxEventWriter
(instead of the version
that takes no argument), so that we can verify it does match the
start element, if necessary
javax.xml.stream.XMLStreamException
public void writeCharacters(javax.xml.stream.events.Characters ch) throws javax.xml.stream.XMLStreamException
WstxEventWriter
(instead of
more generic
text output methods), so that we can verify (if necessary) that
this character output type is legal in this context. Specifically,
it's not acceptable to add non-whitespace content outside root
element (in prolog/epilog).
Note: cut'n pasted from the main writeCharacters
; not
good... but done to optimize white-space cases.
javax.xml.stream.XMLStreamException
protected abstract void closeStartElement(boolean emptyElem) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final boolean inPrologOrEpilog()
public abstract void copyStartElement(InputElementStack elemStack, AttributeCollector attrCollector) throws java.io.IOException, javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected final void verifyWriteCData() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected final void verifyWriteDTD() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected void verifyRootElement(java.lang.String localName, java.lang.String prefix) throws XMLValidationException
XMLValidationException
protected static void throwOutputError(java.lang.String msg) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected static void throwOutputError(java.lang.String format, java.lang.Object arg) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected static void reportIllegalMethod(java.lang.String msg) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected static void reportNwfStructure(java.lang.String msg) throws javax.xml.stream.XMLStreamException
WstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE
is
is enabled.
javax.xml.stream.XMLStreamException
protected static void reportNwfStructure(java.lang.String msg, java.lang.Object arg) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected static void reportNwfContent(java.lang.String msg) throws javax.xml.stream.XMLStreamException
WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT
is
is enabled.
javax.xml.stream.XMLStreamException
protected static void reportNwfContent(java.lang.String msg, java.lang.Object arg) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected static void reportNwfAttr(java.lang.String msg) throws javax.xml.stream.XMLStreamException
WstxOutputProperties.P_OUTPUT_VALIDATE_NAMES
is
is enabled.
javax.xml.stream.XMLStreamException
protected static void reportNwfAttr(java.lang.String msg, java.lang.Object arg) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected static void throwFromIOE(java.io.IOException ioe) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected static void reportIllegalArg(java.lang.String msg) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
protected void reportInvalidContent(int evtType) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void reportValidationProblem(java.lang.String msg, javax.xml.stream.Location loc, int severity) throws XMLValidationException
XMLValidationException
public void reportValidationProblem(java.lang.String msg, int severity) throws XMLValidationException
XMLValidationException
public void reportValidationProblem(java.lang.String msg) throws XMLValidationException
XMLValidationException
public void reportValidationProblem(javax.xml.stream.Location loc, java.lang.String msg) throws XMLValidationException
XMLValidationException
public void reportValidationProblem(java.lang.String format, java.lang.Object arg) throws XMLValidationException
XMLValidationException
public void reportValidationProblem(java.lang.String format, java.lang.Object arg, java.lang.Object arg2) throws XMLValidationException
XMLValidationException
protected final void doReportProblem(javax.xml.stream.XMLReporter rep, java.lang.String probType, java.lang.String msg, javax.xml.stream.Location loc)
protected abstract java.lang.String getTopElementDesc()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |