- Author:
- Lukas Eder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Match$()Wrap a new empty documentstatic MatchRead a DOM document from a file into aMatchelement setstatic Match$(InputStream stream) Read a DOM document from a stream into aMatchelement setstatic MatchRead a DOM document from a reader into aMatchelement setstatic MatchWrap a JAXB-marshallable element in a jOOXMatchelement setstatic MatchCreate a new DOM element in an independent documentstatic MatchCreate a new DOM element in an independent documentstatic MatchCreate a new DOM element in an independent documentstatic MatchCreate a new DOM element in an independent documentstatic MatchConvenience method for calling$(new File(uri))static MatchConvenience method for calling$(url.openStream())static MatchRead a DOM document from a file into aMatchelement setstatic MatchConvenience method for calling$(context.element())static MatchConvenience method for calling$(match)static MatchWrap a DOM document in a jOOXMatchelement setstatic MatchWrap a DOM element in a jOOXMatchelement setstatic Matchstatic Matchstatic Match$(InputSource source) Read a DOM document from a file into aMatchelement setstatic FastFilterall()A filter that always returns truestatic FilterCombine filtersstatic FastFilterat(int... indexes) A filter that returns true on elements at given iteration indexesstatic FastFilterA filter that returns all elements with a given attributestatic FastFilterA filter that returns all elements with a given attribute being set to a given valuestatic FastFilterA filter that returns all elements with a given attribute being set to a given valueCreate a mapper that returns all attributes with a given namestatic DocumentBuilderbuilder()Get a namespace-aware document builderstatic EachChain several instances ofEachinto a single one.static EachChain several instances ofEachinto a single one.static ContentGet a constant content that returns a marshalled, JAXB-annotatedvaluefor all elements.static ContentGet a constant content that returns the samevaluefor all elements.static <T> Tstatic <T> List<T> Convert several valuesstatic FastFiltereven()A filter that returns true on all even iteration indexes (starting with 0!)ids()Create a mapper that returns allidattributesstatic FastFilterCreate a filter matching id attributesstatic FastFilterleaf()A filter that returns true on leaf elementsstatic FastFilterA filter that returns all elements whose text content matches a given regexstatic FastFilterA filter that returns all elements whose tag name matches a given regexstatic FastFilterA filter that returns all elements whose tag name matches a given regexstatic FastFilterA filter that returns all elements whose text content matches a given regexstatic FastFilternamespacePrefix(String namespacePrefix) A filter that returns all elements with a given namespace prefixstatic FastFilternamespaceURI(String namespaceURI) A filter that returns all elements with a given namespace URIstatic FastFilternone()A filter that always returns falsestatic FilterInverse a filterstatic FastFilterodd()A filter that returns true on all odd iteration indexes (starting with 0!)static FilterCombine filterspaths()Create a mapper that returns all paths to given elementsstatic FilterA filter that returns all elements matched by a given selector.static FastFilterA filter that returns all elements with a given tag namestatic FastFilterA filter that returns all elements with a given tag name
-
Constructor Details
-
JOOX
public JOOX()
-
-
Method Details
-
$
Wrap a new empty document -
$
Wrap a JAXB-marshallable element in a jOOXMatchelement set- See Also:
-
$
Create a new DOM element in an independent document -
$
Create a new DOM element in an independent document -
$
Create a new DOM element in an independent documentThe added content is cloned into the new document
-
$
Create a new DOM element in an independent documentThe added content is cloned into the new document
-
$
Wrap a DOM document in a jOOXMatchelement set -
$
Wrap a DOM element in a jOOXMatchelement set -
$
Wrap a DOMNodein a jOOXMatchelement setSupported node types are
-
Document: see$(Document) -
Element: see$(Element)
-
-
$
-
$
Convenience method for calling$(context.element()) -
$
Convenience method for calling$(match) -
$
Convenience method for calling$(url.openStream())- Throws:
SAXExceptionIOException
-
$
Convenience method for calling$(new File(uri))- Throws:
SAXExceptionIOException
-
$
Read a DOM document from a file into aMatchelement set- Throws:
IOExceptionSAXException
-
$
Read a DOM document from a file into aMatchelement set- Throws:
IOExceptionSAXException
-
$
Read a DOM document from a stream into aMatchelement set- Throws:
IOExceptionSAXException
-
$
Read a DOM document from a reader into aMatchelement set- Throws:
IOExceptionSAXException
-
$
Read a DOM document from a file into aMatchelement set- Throws:
IOExceptionSAXException
-
none
A filter that always returns false -
all
A filter that always returns true -
even
A filter that returns true on all even iteration indexes (starting with 0!) -
odd
A filter that returns true on all odd iteration indexes (starting with 0!) -
leaf
A filter that returns true on leaf elements -
at
A filter that returns true on elements at given iteration indexes -
selector
A filter that returns all elements matched by a given selector.In most cases, this is the same as calling
tag(String). InMatch.find(String), the following CSS-style selector syntax elements are also supported:Selector pattern meaning * any element E an element of type E E[foo] an E element with a "foo" attribute E[foo="bar"] an E element whose "foo" attribute value is exactly equal to "bar" E[foo~="bar"] an E element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar" E[foo^="bar"] an E element whose "foo" attribute value begins exactly with the string "bar" E[foo$="bar"] an E element whose "foo" attribute value ends exactly with the string "bar" E[foo*="bar"] an E element whose "foo" attribute value contains the substring "bar" E[foo|="en"] an E element whose "foo" attribute has a hyphen-separated list of values beginning (from the left) with "en" E:root an E element, root of the document E:first-child an E element, first child of its parent E:last-child an E element, last child of its parent E:only-child an E element, only child of its parent E:empty an E element that has no children (including text nodes) E#myid an E element with ID equal to "myid". E F an F element descendant of an E element E > F an F element child of an E element E + F an F element immediately preceded by an E element E ~ F an F element preceded by an E element Note that due to the presence of pseudo selectors, such as
:root,:empty, etc, namespaces are not supported in selectors. Use jOOX's XPath functionality provided inMatch.xpath(String)along withMatch.namespaces(java.util.Map)if your XML document contains namespaces- See Also:
-
tag
A filter that returns all elements with a given tag nameThis is the same as calling
tag(tagName, true)- See Also:
-
tag
A filter that returns all elements with a given tag nameThis method allows for specifying whether namespace prefixes should be ignored. This is particularly useful in DOM Level 1 documents, which are namespace-unaware. In those methods
Document.getElementsByTagNameNS(String, String)will not work, as elements do not contain anylocalName.- Parameters:
tagName- The tag name to match. Use * as a special tag name to match all tag namesignoreNamespace- Whether namespace prefixes can be ignored. When set totrue, then the namespace prefix is ignored. When set tofalse, thentagNamemust include the actual namespace prefix.
-
namespacePrefix
A filter that returns all elements with a given namespace prefixnulland the empty string are treated equally to indicate that no namespace prefix should be present. -
namespaceURI
A filter that returns all elements with a given namespace URInulland the empty string are treated equally to indicate that no namespace URI should be present.This only works if the underlying document is namespace-aware
-
matchText
A filter that returns all elements whose text content matches a given regex- See Also:
-
matchAttr
A filter that returns all elements whose text content matches a given regex- See Also:
-
matchTag
A filter that returns all elements whose tag name matches a given regexThis is the same as calling
matchTag(regex, true)- See Also:
-
matchTag
A filter that returns all elements whose tag name matches a given regexThis method allows for specifying whether namespace prefixes should be ignored. This is particularly useful in DOM Level 1 documents, which are namespace-unaware. In those methods
Document.getElementsByTagNameNS(String, String)will not work, as elements do not contain anylocalName.- Parameters:
regex- The regular expression to use for matching tag names.ignoreNamespace- Whether namespace prefixes can be ignored. When set totrue, then the namespace prefix is ignored. When set tofalse, thenregexmust also match potential namespace prefixes.- See Also:
-
attr
A filter that returns all elements with a given attribute -
attr
A filter that returns all elements with a given attribute being set to a given value -
attr
A filter that returns all elements with a given attribute being set to a given value -
and
Combine filters -
or
Combine filters -
not
Inverse a filter -
ids
Create a filter matching id attributes -
content
Get a constant content that returns the samevaluefor all elements. -
content
Get a constant content that returns a marshalled, JAXB-annotatedvaluefor all elements.- See Also:
-
ids
Create a mapper that returns allidattributes -
attrs
Create a mapper that returns all attributes with a given name -
paths
Create a mapper that returns all paths to given elements -
chain
Chain several instances ofEachinto a single one.The resulting chained
Eachproduces a newEachthat can be used in theMatch.each(Each)method. I.e. every node in a set of matched nodes will be passed to every chainedEach, sequentially. -
chain
Chain several instances ofEachinto a single one.The resulting chained
Eachproduces a newEachthat can be used in theMatch.each(Each)method. I.e. every node in a set of matched nodes will be passed to every chainedEach, sequentially. -
iterable
-
iterator
-
list
-
builder
Get a namespace-aware document builder -
convert
Convert a string value to any of these types:-
String: The conversion has no effect -
Byte: Numeric conversion. NaN will return null -
Short: Numeric conversion. NaN will return null -
Integer: Numeric conversion. NaN will return null -
Long: Numeric conversion. NaN will return null -
Float: Numeric conversion. NaN will return null -
Double: Numeric conversion. NaN will return null -
BigDecimal: Numeric conversion. NaN will return null -
BigInteger: Numeric conversion. NaN will return null -
Boolean: Boolean conversion. Boolean values fortrueare any of these case-insensitive strings:1yyestrueonenabled
falseare any of these case-insensitive strings:0nnofalseoffdisabled
- Primitive types: Numeric or boolean conversion, except that
nulland illegal values will result in0orfalse -
Date: Datetime conversion. -
Calendar: Datetime conversion. -
GregorianCalendar: Datetime conversion. -
Timestamp: Datetime conversion. Possible patterns for datetime conversion areyyyy: Only the year is parsedyyyy[-/]MM: Year and month are parsed. Separator characters are optionalyyyy[-/]MM[-/]dd: Date is parsed. Separator characters are optionaldd[-/.]MM[-/.]yyyy: Date is parsed. Separator characters are mandatoryyyyy[-/]MM[-/]dd[T ]HH: Date and hour are parsed. Separator characters are optionalyyyy[-/]MM[-/]dd[T ]HH[:]mm: Date and time are parsed. Separator characters are optionalyyyy[-/]MM[-/]dd[T ]HH[:]mm[:]ss: Date and time are parsed. Separator characters are optionalyyyy[-/]MM[-/]dd[T ]HH[:]mm[:]ss.SSS: Date and time are parsed. Separator characters are optional
-
Date: Date conversion. Possible patterns for date conversion areyyyy: Only the year is parsedyyyy[-/]MM: Year and month are parsed. Separator characters are optionalyyyy[-/]MM[-/]dd: Date is parsed. Separator characters are optionaldd[-/.]MM[-/.]yyyy: Date is parsed. Separator characters are mandatory
-
Time: Time conversion. Possible patterns for time conversion areHH: Hour is parsed. Separator characters are optionalHH[:]mm: Hour and minute are parsed. Separator characters are optionalHH[:]mm[:]ss: Time is parsed. Separator characters are optional
- Any of the above as array. Arrays of any type are split by any whitespace character, comma or semi-colon. String literals may be delimited by quotes as well.
All other values evaluate to
null -
-
convert
Convert several values- See Also:
-