|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.betwixt.strategy.MixedContentEncodingStrategy org.apache.commons.betwixt.strategy.BaseMixedContentEncodingStrategy
public abstract class BaseMixedContentEncodingStrategy
Basic implementation for MixedContentEncodingStrategy
supports variations of most common use case.
This supports subclasses that choose to encode body content
either as a CDATA
section or by escaping the characters.
Implementations should override encodeAsCDATA(org.apache.commons.betwixt.ElementDescriptor)
with an appropriate decision algorithm.
Field Summary |
---|
Fields inherited from class org.apache.commons.betwixt.strategy.MixedContentEncodingStrategy |
---|
CDATA, CDATA_ENCODING, DEFAULT, ENCODING_OPTION_NAME, ESCAPED_CHARACTERS |
Constructor Summary | |
---|---|
BaseMixedContentEncodingStrategy()
|
Method Summary | |
---|---|
java.lang.String |
encode(java.lang.String bodyContent,
ElementDescriptor element)
Encodes the given body content by either escaping the character data or by encoding within a CDATA section. |
protected abstract boolean |
encodeAsCDATA(ElementDescriptor element)
Should the element described by the given ElementDescriptor be encoded as a CDATA
section? |
protected java.lang.String |
encodeInCDATA(java.lang.String bodyContent)
Wraps the given content into a CDATA section. |
protected java.lang.String |
escapeCharacters(java.lang.String bodyContent)
Escapes a sequence of body content. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BaseMixedContentEncodingStrategy()
Method Detail |
---|
protected java.lang.String escapeCharacters(java.lang.String bodyContent)
bodyContent
- the content whose character data should be escaped,
not null
protected java.lang.String encodeInCDATA(java.lang.String bodyContent)
bodyContent
- the content to be encoded into a CDATA
section
public java.lang.String encode(java.lang.String bodyContent, ElementDescriptor element)
CDATA
section.
The algorithm used to decide whether a particular element's mixed
should be escaped is delegated to the concrete subclass through
encodeAsCDATA(org.apache.commons.betwixt.ElementDescriptor)
encode
in class MixedContentEncodingStrategy
bodyContent
- the raw (unescaped) character data, not nullelement
- the ElementDescriptor
describing the element
whose content is being encoded.
MixedContentEncodingStrategy.encode(java.lang.String, org.apache.commons.betwixt.ElementDescriptor)
protected abstract boolean encodeAsCDATA(ElementDescriptor element)
Should the element described by the given
ElementDescriptor
be encoded as a CDATA
section?
Usage: subclasses should provide a strategy
to determine whether an element should be encoded using a
CDATA
section.
element
- ElementDescriptor
, not null
CDATA
section
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |