Class XMQParseIntoDOM
java.lang.Object
org.libxmq.imp.XMQParser
org.libxmq.imp.XMQParseIntoDOM
- Direct Known Subclasses:
JsonParser, YamlParser
Parses xmq into the xmq DOM. This is a port of the parse callbacks in the
C version (xmq.c: create_node, do_quote, do_entity, do_attr_key ...), so
the resulting DOM is identical to the libxml2 DOM built by the C version.
-
Field Summary
Fields inherited from class XMQParser
MAX_NESTING_DEPTHModifier and TypeFieldDescriptionstatic final intThe parsers recurse for every nested xmq body or json object or array, deeper nesting is an error (XMQ_ERROR_TOO_DEEP) instead of a stack overflow. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddo_apar_left(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a left parenthesis is parsed.protected voiddo_apar_right(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a right parenthesis is parsed.protected voiddo_attr_key(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an attribute key is parsed.protected voiddo_attr_ns(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an attribute namespace is parsed.protected voiddo_attr_value_compound_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside a compound attribute value is parsed.protected voiddo_attr_value_compound_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a compound attribute value quote is parsed.protected voiddo_attr_value_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside an attribute value is parsed.protected voiddo_attr_value_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a quoted attribute value is parsed.protected voiddo_attr_value_text(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when unquoted attribute value text is parsed.protected voiddo_brace_left(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a left brace is parsed.protected voiddo_brace_right(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a right brace is parsed.protected voiddo_colon(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a colon is parsed.protected voiddo_comment(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a comment is parsed.protected voiddo_comment_continuation(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a continued comment is parsed.protected voiddo_cpar_left(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a left square bracket is parsed.protected voiddo_cpar_right(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a right square bracket is parsed.protected voiddo_element_key(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an element key is parsed.protected voiddo_element_name(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an element name is parsed.protected voiddo_element_ns(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an element namespace is parsed.protected voiddo_element_value_compound_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside a compound element value is parsed.protected voiddo_element_value_compound_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a compound element value quote is parsed.protected voiddo_element_value_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside an element value is parsed.protected voiddo_element_value_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a quoted element value is parsed.protected voiddo_element_value_text(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when unquoted element value text is parsed.protected voiddo_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity is parsed.protected voiddo_equals(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an equals sign is parsed.protected voiddo_equals_done(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an equals sign completes a construct.protected voiddo_ns_colon(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a namespace colon is parsed.protected voiddo_ns_declaration(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a namespace declaration is parsed.protected voiddo_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a quote is parsed.protected voiddo_whitespace(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when whitespace is parsed.doc()Returns the parsed document.setDoc(XmlDocument doc) Use an existing document to parse into.setImplicitRoot(String name) Set the implicit root element name.setMergeText(boolean merge) Control whether adjacent text nodes should be merged (the default) or kept separate, like the --no-merge option.setNoTrimQuotes(boolean no_trim) Do not trim the incidental indentation of quotes, used when the quotes were generated from json strings.Methods inherited from class XMQParser
parse, parse_xmq_whitespaceModifier and TypeMethodDescriptionbooleanParses an xmq buffer.protected voidParses xmq whitespace and invokes the whitespace callback.
-
Constructor Details
-
XMQParseIntoDOM
public XMQParseIntoDOM()Creates the parser with no source buffer.
-
-
Method Details
-
doc
-
setDoc
Use an existing document to parse into.- Parameters:
doc- The document.- Returns:
- This parser.
-
setImplicitRoot
Set the implicit root element name. If the first element in the xmq source has a different name, then the implicit root is created to contain all the content.- Parameters:
name- The root element name, or null.- Returns:
- This parser.
-
setMergeText
Control whether adjacent text nodes should be merged (the default) or kept separate, like the --no-merge option.- Parameters:
merge- True to merge.- Returns:
- This parser.
-
setNoTrimQuotes
Do not trim the incidental indentation of quotes, used when the quotes were generated from json strings.- Parameters:
no_trim- True to keep quotes as is.- Returns:
- This parser.
-
do_whitespace
protected void do_whitespace(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when whitespace is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_quote
protected void do_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a quote is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_element_value_quote
protected void do_element_value_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a quoted element value is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_element_value_compound_quote
protected void do_element_value_compound_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a compound element value quote is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_attr_value_quote
protected void do_attr_value_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a quoted attribute value is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_attr_value_compound_quote
protected void do_attr_value_compound_quote(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a compound attribute value quote is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_entity
protected void do_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_element_value_entity
protected void do_element_value_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside an element value is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_element_value_compound_entity
protected void do_element_value_compound_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside a compound element value is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_attr_value_entity
protected void do_attr_value_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside an attribute value is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_attr_value_compound_entity
protected void do_attr_value_compound_entity(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an entity inside a compound attribute value is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_comment
protected void do_comment(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a comment is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_comment_continuation
protected void do_comment_continuation(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a continued comment is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_element_key
protected void do_element_key(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an element key is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_element_name
protected void do_element_name(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an element name is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_element_ns
protected void do_element_ns(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an element namespace is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_colon
protected void do_colon(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a colon is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_apar_left
protected void do_apar_left(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a left parenthesis is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_apar_right
protected void do_apar_right(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a right parenthesis is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_cpar_left
protected void do_cpar_left(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a left square bracket is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_cpar_right
protected void do_cpar_right(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a right square bracket is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_brace_left
protected void do_brace_left(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a left brace is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_brace_right
protected void do_brace_right(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a right brace is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_equals
protected void do_equals(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an equals sign is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_equals_done
protected void do_equals_done(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an equals sign completes a construct.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_attr_value_text
protected void do_attr_value_text(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when unquoted attribute value text is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_element_value_text
protected void do_element_value_text(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when unquoted element value text is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_ns_declaration
protected void do_ns_declaration(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a namespace declaration is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_attr_key
protected void do_attr_key(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an attribute key is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_ns_colon
protected void do_ns_colon(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when a namespace colon is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-
do_attr_ns
protected void do_attr_ns(int start_line, int start_col, int start, int stop, int stop_suffix) Invoked when an attribute namespace is parsed.- Parameters:
start_line- The 0-based starting line.start_col- The 0-based starting column.start- The starting character index.stop- The stopping character index.stop_suffix- The index after the suffix of the token.
-