|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.confluence.content.render.xhtml.StaxUtils
public final class StaxUtils
Constructor Summary | |
---|---|
StaxUtils()
|
Method Summary | |
---|---|
static void |
closeQuietly(javax.xml.stream.XMLEventReader xmlEventReader)
|
static void |
closeQuietly(javax.xml.stream.XMLEventWriter xmlEventWriter)
|
static void |
closeQuietly(javax.xml.stream.XMLStreamReader xmlStreamReader)
|
static void |
closeQuietly(javax.xml.stream.XMLStreamWriter xmlStreamWriter)
|
static java.lang.StringBuilder |
collectWhitespace(java.lang.StringBuilder builder,
javax.xml.stream.XMLEventReader reader)
Collect whitespace from the given reader, into the given builder. |
static java.lang.String |
collectWhitespace(javax.xml.stream.XMLEventReader reader)
Collect whitespace from the given reader. |
static XhtmlException |
convertToXhtmlException(com.ctc.wstx.exc.WstxLazyException ex)
Take a WstxLazyException as a parameter and return the appropriate XhtmlException for the Woodstox exception supplied. |
static void |
flushEventWriter(javax.xml.stream.XMLEventWriter eventWriter)
Ensure all xml events that have been added to the event buffer of the writer are flushed. |
static java.lang.String |
getAttributeValue(javax.xml.stream.events.StartElement startElement,
javax.xml.namespace.QName attributeQName)
|
static java.lang.String |
getAttributeValue(javax.xml.stream.events.StartElement startElement,
javax.xml.namespace.QName attributeQName,
java.lang.String defaultValue)
Retrieves the value of the specified attribute name on the specified start element. |
static java.lang.String |
getAttributeValue(javax.xml.stream.events.StartElement startElement,
java.lang.String attributeName)
|
static java.lang.String |
getAttributeValue(javax.xml.stream.events.StartElement startElement,
java.lang.String attributeName,
java.lang.String defaultValue)
Retrieves the value of the specified attribute name on the specified start element. |
static boolean |
hasAttributes(javax.xml.stream.events.StartElement startElement,
java.lang.String... attributeNames)
Returns true if start element has all the specified attributes. |
static boolean |
hasClass(javax.xml.stream.events.StartElement startElement,
java.lang.String className)
|
static java.lang.String |
readCharactersAndEntities(javax.xml.stream.XMLEventReader reader)
Read all characters and entities from the supplied reader until a non-character or non-entity event is read. |
static void |
skipWhitespace(javax.xml.stream.XMLEventReader reader)
Skip whitespace from the given reader. |
static java.util.List<java.lang.String> |
splitCData(java.lang.String data)
Take a String and split into multiple substrings where each substring is suitable to be written as CData. |
static java.lang.CharSequence |
stripIllegalControlChars(java.lang.CharSequence unclean)
Removes control characters from a CharSequence so that it can be parsed by a Stax parser. |
static java.lang.String |
toString(javax.xml.stream.XMLEventReader reader)
Deprecated. since 5.2. Use toXmlString(javax.xml.stream.XMLEventReader, XmlOutputFactory) |
static java.lang.String |
toXmlString(javax.xml.stream.XMLEventReader reader,
XmlOutputFactory confluenceXmlOutputFactory)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StaxUtils()
Method Detail |
---|
public static void closeQuietly(javax.xml.stream.XMLEventReader xmlEventReader)
public static void closeQuietly(javax.xml.stream.XMLStreamReader xmlStreamReader)
public static void closeQuietly(javax.xml.stream.XMLEventWriter xmlEventWriter)
public static void closeQuietly(javax.xml.stream.XMLStreamWriter xmlStreamWriter)
public static java.lang.String getAttributeValue(javax.xml.stream.events.StartElement startElement, java.lang.String attributeName)
public static java.lang.String getAttributeValue(javax.xml.stream.events.StartElement startElement, javax.xml.namespace.QName attributeQName)
public static java.lang.String getAttributeValue(javax.xml.stream.events.StartElement startElement, java.lang.String attributeName, java.lang.String defaultValue)
startElement
- start elementattributeName
- attribute name
public static java.lang.String getAttributeValue(javax.xml.stream.events.StartElement startElement, javax.xml.namespace.QName attributeQName, java.lang.String defaultValue)
startElement
- start elementattributeQName
- attribute QName
public static boolean hasAttributes(javax.xml.stream.events.StartElement startElement, java.lang.String... attributeNames)
startElement
- start elementattributeNames
- attribute names
public static boolean hasClass(javax.xml.stream.events.StartElement startElement, java.lang.String className)
startElement
- className
-
public static java.lang.String collectWhitespace(javax.xml.stream.XMLEventReader reader) throws javax.xml.stream.XMLStreamException
reader
- the reader
javax.xml.stream.XMLStreamException
- if there are problems reading from the supplied readerpublic static java.lang.StringBuilder collectWhitespace(java.lang.StringBuilder builder, javax.xml.stream.XMLEventReader reader) throws javax.xml.stream.XMLStreamException
builder
- the builderreader
- the reader
javax.xml.stream.XMLStreamException
- if there are problems reading from the supplied readerpublic static void skipWhitespace(javax.xml.stream.XMLEventReader reader) throws javax.xml.stream.XMLStreamException
reader
- the reader
javax.xml.stream.XMLStreamException
- if there are problems reading from the supplied readerpublic static java.lang.String readCharactersAndEntities(javax.xml.stream.XMLEventReader reader) throws javax.xml.stream.XMLStreamException
reader
- the reader to read from, with the current event being either a character or an entity
javax.xml.stream.XMLStreamException
- if there are problems reading from the supplied reader@Deprecated public static java.lang.String toString(javax.xml.stream.XMLEventReader reader)
toXmlString(javax.xml.stream.XMLEventReader, XmlOutputFactory)
public static java.lang.String toXmlString(javax.xml.stream.XMLEventReader reader, XmlOutputFactory confluenceXmlOutputFactory)
public static void flushEventWriter(javax.xml.stream.XMLEventWriter eventWriter) throws javax.xml.stream.XMLStreamException
You want to be using this instead of XMLEventWriter.flush()
when:
eventWriter
- the event writer
javax.xml.stream.XMLStreamException
public static java.util.List<java.lang.String> splitCData(java.lang.String data)
Take a String and split into multiple substrings where each substring is suitable to be written as CData.
You would use this method when you want to write CDATA to an XML document and you need to be sure that the content you are writing doesn't contain a CDATA closing triad (]]>) which would cause a premature closing of the CDATA.
So as an example if you supply a String like <![CDATA[stuff]]> then the returned Strings would be
If the supplied String is already safe for writing to a CDATA section then a single item List will be returned containing the supplied String.
data
- the data to be made safe for writing to a CDATA section.
public static XhtmlException convertToXhtmlException(com.ctc.wstx.exc.WstxLazyException ex)
ex
- the Woodstox exception to be converted to an XhtmlException.
public static java.lang.CharSequence stripIllegalControlChars(java.lang.CharSequence unclean)
Legal characters are tab, carriage return, line feed, and the legal characters of Unicode and ISO/IEC 10646XML Charsets. This method only removes illegal control chars, and doesn't attempt to remove illegal Unicode characters.
unclean
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |