public class XMLNodeUtilities2 extends Object implements XMLNodeUtilitiesOptions
XMLNodeUtilities2
, class, all methods are instance methods.ALLOW_INTERNAL_READERS, KEEP_LINE_NUMBERS, NAMESPACE_AWARE, PRESERVE_SPACE, SHOW_EXCEPTIONS, SHOW_WARNINGS
Constructor and Description |
---|
XMLNodeUtilities2() |
XMLNodeUtilities2(XMLNodeUtilities2 utils) |
Modifier and Type | Method and Description |
---|---|
void |
applyConfiguration(XMLParserConfiguration config)
Apply a parser configuration.
|
Charset |
getCharset()
Return the charset to use to write the content.
|
EntityListResolver |
getEntityListResolver()
Return the EntityListResolver which can manage entity resolution in XML files.
|
ErrorHandler |
getErrorHandler()
Return the error handler wich will be fired for parsing errors detected by the underlying parser. null by default.
|
Map<String,Boolean> |
getFeatures()
Return the underlying parser factory features.
|
XMLNode |
getNode(File file)
Return the Node from a file.
|
XMLNode |
getNode(Reader reader)
Return the Node from a Reader.
|
XMLNode |
getNode(String str)
Return the Node from a String.
|
XMLNode |
getNode(URL xmlURL)
Return the root Node from an XML URL.
|
XMLNode |
getNode(URL xmlURL,
String comment)
Return the root Node from an XML URL, with a comment.
|
Map<String,Object> |
getProperties()
Return the underlying parser properties.
|
XMLRoot |
getRootNode(File file)
Return the root Node from a file.
|
XMLRoot |
getRootNode(Reader reader)
Return the root Node from a Reader.
|
XMLRoot |
getRootNode(String str)
Return the root Node from a String.
|
XMLRoot |
getRootNode(URL xmlURL)
Return the root Node from an XML URL.
|
URL |
getSchema()
Return the schema of the underlying parser.
|
boolean |
isAllowingInternalReaders()
Return true if internal readers creation are allowed in the underlying parser instance.
|
boolean |
isKeepingLineNumbers()
Return true if the line numbers should be kept during the parsing.
|
boolean |
isKeepingPrefixes()
Return true if the underlying parser must keep the prefixes.
|
boolean |
isNameSpaceAware()
Return true if the parser is namespace-aware.
|
boolean |
isPreservingSpaces()
Return true if spaces should be preserved.
|
boolean |
isShowingExceptions()
Return true if the parser shows the exceptions encountered during the parsing.
|
boolean |
isShowingWarnings()
Return true if the parser shows the warnings encountered during the parsing.
|
boolean |
isValidating()
Return true if the underlying parser is validating.
|
void |
keepLineNumbers(boolean keepLineNumbers)
Set if the line numbers should be kept during the parsing.
|
void |
preserveSpaces(boolean preserveSpace)
Set if spaces should be preserved.
|
String |
print(XMLNode node,
int indentation)
Print as a String the content of an XML file under a root Node.
|
void |
print(XMLNode node,
int indentation,
boolean isOrdered,
File outputFile)
Save in a File the content of an XML file under a root Node.
|
String |
print(XMLNode node,
int indentation,
boolean isOrdered,
NodeSerializer serializer)
Print as a String the content of an XML file under a root Node.
|
void |
print(XMLNode node,
int indentation,
boolean isOrdered,
NodeSerializer serializer,
File outputFile)
Save in a File the content of an XML file under a root Node.
|
String |
print(XMLNode node,
int indentation,
boolean isOrdered,
NodeSerializer serializer,
String encoding)
Print as a String the content of an XML file under a root Node.
|
void |
print(XMLNode node,
int indentation,
boolean isOrdered,
NodeSerializer serializer,
URL outputURL)
Save in an URL the content of an XML file under a root Node.
|
void |
print(XMLNode node,
int indentation,
boolean isOrdered,
URL outputURL)
Save in an URL the content of an XML file under a root Node.
|
void |
print(XMLNode node,
int indentation,
File outputFile)
Save in a File the content of an XML file under a root Node.
|
void |
print(XMLNode node,
int indentation,
File outputFile,
boolean isOrdered,
NodeSerializer serializer,
String encoding)
Save in a File the content of an XML file under a root Node.
|
void |
print(XMLNode node,
int indentation,
File outputFile,
String encoding)
Save in a File the content of an XML file under a root Node.
|
String |
print(XMLNode node,
int indentation,
String encoding)
Print as a String the content of an XML file under a root Node.
|
void |
print(XMLNode node,
int indentation,
URL outputURL)
Save in an URL the content of an XML file under a root Node.
|
void |
resetConfiguration()
Reset the configuration of the underlying parser (reatures and properties).
|
List<XMLNode> |
search(XMLNode node,
List<QName> qnames,
boolean deep)
Search for the children nodes having a specified qualified name among a list of names.
|
List<XMLNode> |
search(XMLNode node,
QName[] qnames,
boolean deep)
Search for the children nodes having a specified qualified name among a list of names.
|
List<XMLNode> |
search(XMLNode node,
QName qname,
boolean deep)
Search for the children nodes having a specified qualified name.
|
List<XMLNode> |
search(XMLNode node,
String name,
boolean deep)
Search for the children nodes having a specified name.
|
XMLNode |
searchFirst(XMLNode node,
List<QName> qnames,
boolean deep)
Search for the first child node having a specified qualified name among a list of qualified names.
|
XMLNode |
searchFirst(XMLNode node,
QName[] qnames,
boolean deep)
Search for the first child node having a specified qualified name among a list of qualified names.
|
XMLNode |
searchFirst(XMLNode node,
QName qname,
boolean deep)
Search for the first child node having a specified qualified name.
|
XMLNode |
searchFirst(XMLNode node,
String name,
boolean deep)
Search for the first child node having a specified name.
|
XMLNode |
searchFirstForNames(XMLNode node,
List<String> names,
boolean deep)
Search for the first child node having a specified name among a list of names.
|
XMLNode |
searchFirstForNames(XMLNode node,
String[] names,
boolean deep)
Search for the first child node having a specified name among a list of names.
|
List<XMLNode> |
searchForNames(XMLNode node,
List<String> names,
boolean deep)
Search for the children nodes having a specified name among a list of names.
|
List<XMLNode> |
searchForNames(XMLNode node,
String[] names,
boolean deep)
Search for the children nodes having a specified name among a list of names.
|
void |
setAllowInternalReaders(boolean allowInternalReaders)
Set if internal readers creation are allowed in the underlying parser instance.
|
void |
setCharset(Charset charset)
Set the charset to use to write the content.
|
void |
setEntityListResolver(EntityListResolver resolver)
Set the EntityListResolver which can manage entity resolution in XML files.
|
void |
setErrorHandler(ErrorHandler errorHandler)
Set an error handler wich will be fired for parsing errors detected by the underlying parser.
|
void |
setFeature(String name,
boolean value)
Set a underlying parser factory feature.
|
void |
setKeepPrefixes(boolean keepPrefixes)
Set if the underlying parser must keep the prefixes.
|
void |
setNameSpaceAware(boolean isNameSpaceAware)
Set if the parser is namespace-aware.
|
void |
setOptions(int options)
Set the underlying parser options.
|
void |
setProperty(String name,
Object value)
Set an underlying parser property.
|
void |
setSchema(URL schema)
Set the schema of the underlying parser.
|
void |
setValidating(boolean isValidating)
Set if the underlying parser is validating.
|
void |
showExceptions(boolean isShowingExceptions)
Set if the parser shows the exceptions encountered during the parsing.
|
void |
showWarnings(boolean isShowingWarnings)
Set if the parser shows the warnings encountered during the parsing.
|
public XMLNodeUtilities2()
public XMLNodeUtilities2(XMLNodeUtilities2 utils)
public void applyConfiguration(XMLParserConfiguration config)
config
- the configurationpublic void setCharset(Charset charset)
StandardCharsets.UTF_8
.charset
- the charsetpublic Charset getCharset()
public void setSchema(URL schema)
schema
- the schema of the underlying parserpublic URL getSchema()
public void setValidating(boolean isValidating)
isValidating
- true if the underlying parser is validatingpublic boolean isValidating()
public void setOptions(int options)
options
- the optionspublic void showExceptions(boolean isShowingExceptions)
isShowingExceptions
- true if the parser shows the exceptions encountered during the parsingpublic boolean isShowingExceptions()
public void showWarnings(boolean isShowingWarnings)
isShowingWarnings
- true if the parser shows the warnings encountered during the parsingpublic boolean isShowingWarnings()
public void preserveSpaces(boolean preserveSpace)
preserveSpace
- true if spaces should be preservedpublic boolean isPreservingSpaces()
public void keepLineNumbers(boolean keepLineNumbers)
keepLineNumbers
- true if the line numbers should be kept during the parsingpublic boolean isKeepingLineNumbers()
public void setNameSpaceAware(boolean isNameSpaceAware)
isNameSpaceAware
- true if the parser is namespace-awarepublic boolean isNameSpaceAware()
public void setKeepPrefixes(boolean keepPrefixes)
keepPrefixes
- true if the parser must keep the prefixespublic boolean isKeepingPrefixes()
public void setAllowInternalReaders(boolean allowInternalReaders)
allowInternalReaders
- true if internal readers creation are allowed in the underlying parser instance.public boolean isAllowingInternalReaders()
public void setEntityListResolver(EntityListResolver resolver)
resolver
- the resolverpublic EntityListResolver getEntityListResolver()
public void setErrorHandler(ErrorHandler errorHandler)
errorHandler
- the error handlerpublic ErrorHandler getErrorHandler()
public void resetConfiguration()
public void setFeature(String name, boolean value)
name
- the feature namevalue
- the feature valuepublic Map<String,Boolean> getFeatures()
public void setProperty(String name, Object value)
name
- the property namevalue
- the property valuepublic Map<String,Object> getProperties()
public List<XMLNode> search(XMLNode node, String name, boolean deep)
<root desc="example"> <element1 name="first" id="theID"> <element2 name="second"> <element3 name="fourth" /> <element2 name="fith"/> </element2> <element3 name="third" /> </element1> </root>Then:
search(root, "element2", false)
, the method will return one node, which is the first "element2" childsearch(root, "element2", true)
, the method will return two nodeq, which is the two "element2" childrensearch(root, "h:element", false)
is equivalent to
search(root, new QName(XMLConstants.NULL_NS_URI, "element", "h"), false)
node
- the root nodename
- the name to search fordeep
- if the search should continue for children of nodes found in the searchpublic List<XMLNode> searchForNames(XMLNode node, List<String> names, boolean deep)
node
- the root nodenames
- the name to search fordeep
- if the search should continue for children of nodes found in the searchpublic List<XMLNode> searchForNames(XMLNode node, String[] names, boolean deep)
node
- the root nodenames
- the name to search fordeep
- if the search should continue for children of nodes found in the searchpublic XMLNode searchFirst(XMLNode node, QName qname, boolean deep)
node
- the root nodeqname
- the qualified name to search fordeep
- if the search should continue for children of nodes found in the searchpublic XMLNode searchFirst(XMLNode node, List<QName> qnames, boolean deep)
node
- the root nodeqnames
- the qualified qnames to search fordeep
- if the search should continue for children of nodes found in the searchpublic XMLNode searchFirst(XMLNode node, QName[] qnames, boolean deep)
node
- the root nodeqnames
- the qualified qnames to search fordeep
- if the search should continue for children of nodes found in the searchpublic XMLNode searchFirst(XMLNode node, String name, boolean deep)
<root desc="example"> <element1 name="first" id="theID"> <element2 name="second"> <element3 name="fourth" /> <element2 name="fith"/> </element2> <element3 name="third" /> </element1> </root>Then:
searchFirst(root, "element2", false)
, the method will return one node, which is the first "element2" childsearchFirst(root, "element2", true)
, the method will also return one node, which is the first "element2" childsearch(root, "h:element", false)
is equivalent to
searchFirst(root, new QName(XMLConstants.NULL_NS_URI, "element", "h"), false)
node
- the root nodename
- the name to search fordeep
- if the search should continue for children of nodes found in the searchpublic XMLNode searchFirstForNames(XMLNode node, List<String> names, boolean deep)
node
- the root nodenames
- the names to search fordeep
- if the search should continue for children of nodes found in the searchpublic XMLNode searchFirstForNames(XMLNode node, String[] names, boolean deep)
node
- the root nodenames
- the names to search fordeep
- if the search should continue for children of nodes found in the searchpublic List<XMLNode> search(XMLNode node, QName qname, boolean deep)
node
- the root nodeqname
- the qualified name to search fordeep
- if the search should continue for children of nodes found in the searchpublic List<XMLNode> search(XMLNode node, List<QName> qnames, boolean deep)
node
- the root nodeqnames
- the qualified names to search fordeep
- if the search should continue for children of nodes found in the searchpublic List<XMLNode> search(XMLNode node, QName[] qnames, boolean deep)
node
- the root nodeqnames
- the qualified names to search fordeep
- if the search should continue for children of nodes found in the searchpublic XMLNode getNode(String str)
str
- the Stringpublic XMLNode getNode(Reader reader)
reader
- the Readerpublic XMLNode getNode(File file)
file
- the filepublic XMLNode getNode(URL xmlURL)
xmlURL
- the XML URLpublic XMLNode getNode(URL xmlURL, String comment)
xmlURL
- the XML URLcomment
- the commentpublic XMLRoot getRootNode(String str)
str
- the Stringpublic XMLRoot getRootNode(File file)
file
- the filepublic XMLRoot getRootNode(Reader reader)
reader
- the Readerpublic XMLRoot getRootNode(URL xmlURL)
xmlURL
- the XML URLpublic void print(XMLNode node, int indentation, File outputFile) throws IOException
node
- the root nodeindentation
- the indentation for the XML file for each child nodeoutputFile
- the output fileIOException
public void print(XMLNode node, int indentation, boolean isOrdered, File outputFile) throws IOException
node
- the root nodeindentation
- the indentation for the XML file for each child nodeisOrdered
- true if the order of attributes is preservedoutputFile
- the output fileIOException
public void print(XMLNode node, int indentation, boolean isOrdered, NodeSerializer serializer, File outputFile) throws IOException
node
- the root nodeindentation
- the indentation for the XML file for each child nodeisOrdered
- true if the order of attributes is preservedserializer
- the node serializeroutputFile
- the output fileIOException
public void print(XMLNode node, int indentation, File outputFile, String encoding) throws IOException
node
- the root nodeindentation
- the indentation for the XML file for each child nodeoutputFile
- the output fileencoding
- the encoding (can be null)IOException
public void print(XMLNode node, int indentation, File outputFile, boolean isOrdered, NodeSerializer serializer, String encoding) throws IOException
node
- the root nodeindentation
- the indentation for the XML file for each child nodeoutputFile
- the output fileisOrdered
- true if the order of attributes is preservedserializer
- the node serializerencoding
- the encoding (can be null)IOException
public void print(XMLNode node, int indentation, URL outputURL) throws IOException
node
- the root nodeindentation
- the indentation for the XML file for each child nodeoutputURL
- the output URLIOException
public void print(XMLNode node, int indentation, boolean isOrdered, URL outputURL) throws IOException
node
- the root nodeindentation
- the indentation for the XML file for each child nodeisOrdered
- true if the order of attributes is preservedoutputURL
- the output URLIOException
public void print(XMLNode node, int indentation, boolean isOrdered, NodeSerializer serializer, URL outputURL) throws IOException
node
- the root nodeindentation
- the indentation for the XML file for each child nodeisOrdered
- true if the order of attributes is preservedserializer
- the node serailizeroutputURL
- the output URLIOException
public String print(XMLNode node, int indentation)
node
- the root nodeindentation
- the indentation for the XML file for each child nodepublic String print(XMLNode node, int indentation, boolean isOrdered, NodeSerializer serializer)
node
- the root nodeindentation
- the indentation for the XML file for each child nodeisOrdered
- true if the order of attributes is preservedserializer
- the node serializerpublic String print(XMLNode node, int indentation, String encoding)
node
- the root nodeindentation
- the indentation for the XML file for each child nodeencoding
- the encoding (vcan be null)public String print(XMLNode node, int indentation, boolean isOrdered, NodeSerializer serializer, String encoding)
node
- the root nodeindentation
- the indentation for the XML file for each child nodeisOrdered
- true if the order of attributes is preservedserializer
- the node serialierencoding
- the encoding (vcan be null)