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 a message is presents.
Author:
Daniele Piras, Gaston Dombiak
  • Field Details

    • 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:
    • INSIDE

      protected static final int INSIDE
      See Also:
    • PRETAIL

      protected static final int PRETAIL
      See Also:
    • TAIL

      protected static final int TAIL
      See Also:
    • VERIFY_CLOSE_TAG

      protected static final int VERIFY_CLOSE_TAG
      See Also:
    • INSIDE_PARAM_VALUE

      protected static final int INSIDE_PARAM_VALUE
      See Also:
    • INSIDE_CDATA

      protected static final int INSIDE_CDATA
      See Also:
    • OUTSIDE

      protected static final int OUTSIDE
      See Also:
    • status

      protected int status
    • cdataOffset

      protected int cdataOffset
    • tailCount

      protected int tailCount
    • startLastMsg

      protected int startLastMsg
    • insideRootTag

      protected boolean insideRootTag
    • msgs

      protected List<String> msgs
    • insideChildrenTag

      protected boolean insideChildrenTag
  • Constructor Details

    • XMLLightweightParser

      public XMLLightweightParser()
  • Method Details

    • 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()
    • isWhitespaceFound

      public boolean isWhitespaceFound()
      Returns true if at least one whitespace character has been encountered outside of any XML element (i.e. between stanzas) since this flag was last reset. This is the mechanism by which XMPP "whitespace keep-alive" pings are tolerated: such characters are skipped rather than becoming part of any parsed stanza, but this flag lets a caller detect that it happened.
      Returns:
      true if extraneous whitespace was found, false otherwise.
    • resetWhitespaceFound

      public void resetWhitespaceFound()
      Clears the flag tracked by isWhitespaceFound().
    • isNonWhitespaceExtraneousDataFound

      public boolean isNonWhitespaceExtraneousDataFound()
      Returns true if at least one non-whitespace character has been encountered outside of any XML element (i.e. before the first stanza, or between stanzas) since this flag was last reset. Unlike whitespace, such data is not the result of any recognised XMPP convention and is more likely to indicate a misbehaving peer.
      Returns:
      true if extraneous non-whitespace data was found, false otherwise.
    • resetNonWhitespaceExtraneousDataFound

      public void resetNonWhitespaceExtraneousDataFound()
      Clears the flag tracked by isNonWhitespaceExtraneousDataFound().
    • read

      public void read(io.netty.buffer.ByteBuf in) throws Exception
      Throws:
      Exception
    • hasIllegalCharacterReferences

      public static boolean hasIllegalCharacterReferences(String string)
      This method verifies if the provided argument contains at least one numeric character reference ( CharRef ::= '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';) for which the decimal or hexadecimal character value refers to an invalid XML 1.0 character.
      Parameters:
      string - The input string
      Returns:
      true if the input string contains an invalid numeric character reference, false otherwise.
      See Also:
    • 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:
      true if the codepoint is a valid character per XML 1.0 definition, false otherwise.
      See Also: