Package org.igniterealtime.jbosh
Class StaticBody
- java.lang.Object
-
- org.igniterealtime.jbosh.AbstractBody
-
- org.igniterealtime.jbosh.StaticBody
-
final class StaticBody extends AbstractBody
Implementation of theAbstractBody
class which allows for the definition of messages from pre-existing message content. Instances of this class are based on the underlying data and therefore cannot be modified. In order to obtain the wrapper element namespace and attribute information, the body content is partially parsed. This class does only minimal syntactic and semantic checking with respect to what the generated XML will look like. It is up to the developer to protect against the definition of malformed XML messages when building instances of this class. Instances of this class are immutable and thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<BodyQName,java.lang.String>
attrs
Map of all attributes to their values.private static int
BUFFER_SIZE
Size of the internal buffer when copying from a stream.private static BodyParser
PARSER
Selected parser to be used to process raw XML messages.private java.lang.String
raw
This body message in raw XML form.
-
Constructor Summary
Constructors Modifier Constructor Description private
StaticBody(java.util.Map<BodyQName,java.lang.String> attrMap, java.lang.String rawXML)
Prevent direct construction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StaticBody
fromStream(java.io.InputStream inStream)
Creates an instance which is initialized by reading a body message from the provided stream.static StaticBody
fromString(java.lang.String rawXML)
Creates an instance which is initialized by reading a body message from the provided raw XML string.java.util.Map<BodyQName,java.lang.String>
getAttributes()
Get a map of all defined attribute names with their corresponding values.java.lang.String
toXML()
Get an XML String representation of this message.-
Methods inherited from class org.igniterealtime.jbosh.AbstractBody
getAttribute, getAttributeNames, getBodyQName
-
-
-
-
Field Detail
-
PARSER
private static final BodyParser PARSER
Selected parser to be used to process raw XML messages.
-
BUFFER_SIZE
private static final int BUFFER_SIZE
Size of the internal buffer when copying from a stream.- See Also:
- Constant Field Values
-
attrs
private final java.util.Map<BodyQName,java.lang.String> attrs
Map of all attributes to their values.
-
raw
private final java.lang.String raw
This body message in raw XML form.
-
-
Constructor Detail
-
StaticBody
private StaticBody(java.util.Map<BodyQName,java.lang.String> attrMap, java.lang.String rawXML)
Prevent direct construction.
-
-
Method Detail
-
fromStream
public static StaticBody fromStream(java.io.InputStream inStream) throws BOSHException
Creates an instance which is initialized by reading a body message from the provided stream.- Parameters:
inStream
- stream to read message XML from- Returns:
- body instance
- Throws:
BOSHException
- on parse error
-
fromString
public static StaticBody fromString(java.lang.String rawXML) throws BOSHException
Creates an instance which is initialized by reading a body message from the provided raw XML string.- Parameters:
rawXML
- raw message XML in string form- Returns:
- body instance
- Throws:
BOSHException
- on parse error
-
getAttributes
public java.util.Map<BodyQName,java.lang.String> getAttributes()
Get a map of all defined attribute names with their corresponding values.- Specified by:
getAttributes
in classAbstractBody
- Returns:
- map of qualified attributes
-
toXML
public java.lang.String toXML()
Get an XML String representation of this message.- Specified by:
toXML
in classAbstractBody
- Returns:
- XML string representing the body message
-
-