Package tigase.xml
Class SimpleParser
- java.lang.Object
-
- tigase.xml.SimpleParser
-
public class SimpleParser extends java.lang.Object
SimpleParser
- implementation of SAX parser. This is very basic implementation of XML parser designed especially to be light and parse XML streams like jabber XML stream. It is very efficient, capable of parsing parts of XML document received from the network connection as well as handling a few XML documents in one buffer. This is especially useful when parsing data received from the network. Packets received from the network can contain non-comlete XML document as well as a few complete XML documents. It doesn't support XML comments, processing instructions, document inclussions. Actually it supports only:- Start element event (with all attributes found).
- End element even.
- Character data event.
- 'OtherXML' data event - everything between '<' and '>' if after < is '?' or '!'. So it can 'catch' doctype declaration, processing instructions but it can't process correctly commented blocks.
UserRepository
based on XML file or server configuration.It is worth to note also that this class is fully thread safe. It means that one instance of this class can be simultanously used by many threads. This is to improve resources usage when processing many client connections at the same time.
Created: Fri Oct 1 23:02:15 2004
- Version:
- $Rev$
- Author:
- Artur Hefczyc
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
SimpleParser.EntityType
protected static class
SimpleParser.ParserState
protected static class
SimpleParser.State
-
Field Summary
Fields Modifier and Type Field Description int
ATTRIBUTES_NUMBER_LIMIT
static java.lang.String
ATTRIBUTES_NUMBER_LIMIT_PROP_KEY
int
MAX_ATTRIBS_NUMBER
Variable constantMAX_ATTRIBS_NUMBER
keeps value of maximum possible attributes number.static java.lang.String
MAX_ATTRIBS_NUMBER_PROP_KEY
int
MAX_ATTRIBUTE_NAME_SIZE
static java.lang.String
MAX_ATTRIBUTE_NAME_SIZE_PROP_KEY
int
MAX_ATTRIBUTE_VALUE_SIZE
static java.lang.String
MAX_ATTRIBUTE_VALUE_SIZE_PROP_KEY
int
MAX_CDATA_SIZE
static java.lang.String
MAX_CDATA_SIZE_PROP_KEY
int
MAX_ELEMENT_NAME_SIZE
static java.lang.String
MAX_ELEMENT_NAME_SIZE_PROP_KEY
-
Constructor Summary
Constructors Constructor Description SimpleParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkIsCharValidInXML(SimpleParser.ParserState parserState, char chr)
void
parse(SimpleHandler handler, char[] data, int off, int len)
void
parse(SimpleHandler handler, java.lang.String input)
-
-
-
Field Detail
-
ATTRIBUTES_NUMBER_LIMIT_PROP_KEY
public static final java.lang.String ATTRIBUTES_NUMBER_LIMIT_PROP_KEY
- See Also:
- Constant Field Values
-
MAX_ATTRIBS_NUMBER_PROP_KEY
public static final java.lang.String MAX_ATTRIBS_NUMBER_PROP_KEY
- See Also:
- Constant Field Values
-
MAX_ELEMENT_NAME_SIZE_PROP_KEY
public static final java.lang.String MAX_ELEMENT_NAME_SIZE_PROP_KEY
- See Also:
- Constant Field Values
-
MAX_ATTRIBUTE_NAME_SIZE_PROP_KEY
public static final java.lang.String MAX_ATTRIBUTE_NAME_SIZE_PROP_KEY
- See Also:
- Constant Field Values
-
MAX_ATTRIBUTE_VALUE_SIZE_PROP_KEY
public static final java.lang.String MAX_ATTRIBUTE_VALUE_SIZE_PROP_KEY
- See Also:
- Constant Field Values
-
MAX_CDATA_SIZE_PROP_KEY
public static final java.lang.String MAX_CDATA_SIZE_PROP_KEY
- See Also:
- Constant Field Values
-
ATTRIBUTES_NUMBER_LIMIT
public int ATTRIBUTES_NUMBER_LIMIT
-
MAX_ATTRIBS_NUMBER
public int MAX_ATTRIBS_NUMBER
Variable constantMAX_ATTRIBS_NUMBER
keeps value of maximum possible attributes number. Real XML parser shouldn't have such limit but in most cases XML elements don't have too many attributes. For efficiency it is better to use fixed number of attributes and operate on arrays than on lists. Data structures will automaticly grow if real attributes number is bigger so there should be no problem with processing XML streams different than expected.
-
MAX_ATTRIBUTE_NAME_SIZE
public int MAX_ATTRIBUTE_NAME_SIZE
-
MAX_ATTRIBUTE_VALUE_SIZE
public int MAX_ATTRIBUTE_VALUE_SIZE
-
MAX_CDATA_SIZE
public int MAX_CDATA_SIZE
-
MAX_ELEMENT_NAME_SIZE
public int MAX_ELEMENT_NAME_SIZE
-
-
Method Detail
-
parse
public final void parse(SimpleHandler handler, java.lang.String input)
-
parse
@TODO(note="1. Better XML errors detection. 2. Add XML comments handling. 3. Character overflow detection i.e. limit max number of characters for each entity.") public final void parse(SimpleHandler handler, char[] data, int off, int len)
-
checkIsCharValidInXML
protected boolean checkIsCharValidInXML(SimpleParser.ParserState parserState, char chr)
-
-