Package org.jivesoftware.openfire.nio
Class XMLLightweightParser
- java.lang.Object
-
- org.jivesoftware.openfire.nio.XMLLightweightParser
-
public class XMLLightweightParser extends Object
This is a Light-Weight XML Parser. It read data from a channel and collect data until data are available in the channel. When a message is complete you can retrieve messages invoking the method getMsgs() and you can invoke the method areThereMsgs() to know if at least an message is presents.- Author:
- Daniele Piras, Gaston Dombiak
-
-
Field Summary
Fields Modifier and Type Field Description protected StringBuilderbufferprotected static char[]CDATA_ENDprotected static char[]CDATA_STARTprotected intcdataOffsetprotected StringBuilderheadprotected static intHEADprotected static intINITprotected static intINSIDEprotected static intINSIDE_CDATAprotected static intINSIDE_PARAM_VALUEprotected booleaninsideChildrenTagprotected booleaninsideRootTagprotected List<String>msgsprotected static intOUTSIDEprotected static intPRETAILprotected intstartLastMsgprotected intstatusprotected static intTAILprotected inttailCountprotected static intVERIFY_CLOSE_TAGstatic SystemProperty<Long>XMPP_PARSER_BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description XMLLightweightParser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanareThereMsgs()protected voidfoundMsg(String msg)String[]getMsgs()static booleanhasIllegalCharacterReferences(String string)This method verifies if the provided argument contains at least one numeric character reference (CharRef ::= '' [0-9]+ ';' | '' [0-9a-fA-F]+ ';) for which the decimal or hexidecimal character value refers to an invalid XML 1.0 character.protected voidinvalidateBuffer()static booleanisLegalXmlCharacter(int value)Verifies if the codepoint value represents a valid character as defined in paragraph 2.2 of "Extensible Markup Language (XML) 1.0 (Fifth Edition)"booleanisMaxBufferSizeExceeded()voidread(io.netty.buffer.ByteBuf in)
-
-
-
Field Detail
-
XMPP_PARSER_BUFFER_SIZE
public static final SystemProperty<Long> XMPP_PARSER_BUFFER_SIZE
-
CDATA_START
protected static char[] CDATA_START
-
CDATA_END
protected static char[] CDATA_END
-
buffer
protected StringBuilder buffer
-
INIT
protected static final int INIT
- See Also:
- Constant Field Values
-
HEAD
protected static final int HEAD
- See Also:
- Constant Field Values
-
INSIDE
protected static final int INSIDE
- See Also:
- Constant Field Values
-
PRETAIL
protected static final int PRETAIL
- See Also:
- Constant Field Values
-
TAIL
protected static final int TAIL
- See Also:
- Constant Field Values
-
VERIFY_CLOSE_TAG
protected static final int VERIFY_CLOSE_TAG
- See Also:
- Constant Field Values
-
INSIDE_PARAM_VALUE
protected static final int INSIDE_PARAM_VALUE
- See Also:
- Constant Field Values
-
INSIDE_CDATA
protected static final int INSIDE_CDATA
- See Also:
- Constant Field Values
-
OUTSIDE
protected static final int OUTSIDE
- See Also:
- Constant Field Values
-
status
protected int status
-
cdataOffset
protected int cdataOffset
-
tailCount
protected int tailCount
-
startLastMsg
protected int startLastMsg
-
insideRootTag
protected boolean insideRootTag
-
head
protected StringBuilder head
-
insideChildrenTag
protected boolean insideChildrenTag
-
-
Method Detail
-
areThereMsgs
public boolean areThereMsgs()
-
getMsgs
public String[] getMsgs()
-
invalidateBuffer
protected void invalidateBuffer()
-
foundMsg
protected void foundMsg(String msg) throws XMLNotWellFormedException
- Throws:
XMLNotWellFormedException
-
isMaxBufferSizeExceeded
public boolean isMaxBufferSizeExceeded()
-
hasIllegalCharacterReferences
public static boolean hasIllegalCharacterReferences(String string)
This method verifies if the provided argument contains at least one numeric character reference (CharRef ::= '' [0-9]+ ';' | '' [0-9a-fA-F]+ ';) for which the decimal or hexidecimal character value refers to an invalid XML 1.0 character.- Parameters:
string- The input string- Returns:
trueif the input string contains an invalid numeric character reference,falseotherwise.- See Also:
- Definition of a character reference
-
isLegalXmlCharacter
public static boolean isLegalXmlCharacter(int value)
Verifies if the codepoint value represents a valid character as defined in paragraph 2.2 of "Extensible Markup Language (XML) 1.0 (Fifth Edition)"- Parameters:
value- the codepoint- Returns:
trueif the codepoint is a valid character per XML 1.0 definition,falseotherwise.- See Also:
- Definition of a characters range
-
-