public class XMLIncluder extends DefaultHandler implements XMLChildrenIncluder
Constructor and Description |
---|
XMLIncluder()
Constructor.
|
XMLIncluder(File file)
Constructor.
|
XMLIncluder(InputStream stream)
Constructor.
|
XMLIncluder(URL url)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length) |
void |
endElement(String uri,
String localname,
String qname) |
void |
error(SAXParseException e)
Report an XML parsing error.
|
void |
fatalError(SAXParseException e)
Report a fatal XML parsing error.
|
Charset |
getCharset()
Return the charset to use to write the content.
|
ClassLoader |
getClassLoader()
Return the ClassLoader.
|
String |
getContent()
Return a String representing the XML content.
|
ErrorHandler |
getErrorHandler()
Return the ErrorHandler which will be fired for warnings and errors when parsing the content.
|
StringReader |
getReader()
Return a StringReader to the XML content.
|
boolean |
hasFatalError()
Return true if the parsing of the file threw a Fatal error.
|
boolean |
isAddingComments()
Return true if a comment must be added for each included file.
|
boolean |
isAllowingInternalReaders()
Return true if internal readers creation are allowed in this parser instance.
|
boolean |
isEnablingDeepComments()
Return true if the comments in deep include declarations must be added.
|
void |
setAddComments(boolean addComments,
boolean deep)
Set if a comment must be added for each included file.
|
void |
setAllowInternalReaders(boolean allowInternalReaders)
Set if internal readers creation are allowed in this parser instance.
|
void |
setCharset(Charset charset)
Set the charset to use to write the content.
|
void |
setClassLoader(ClassLoader loader)
Set the ClassLoader.
|
void |
setDefaultBaseDirectory(URL baseDir)
Set the default base directory for including files.
|
void |
setDocumentLocator(Locator locator)
Set the document locator.
|
void |
setErrorHandler(ErrorHandler errorHandler)
Set the ErrorHandler which will be fired for warnings and errors when parsing the content.
|
void |
setFile(File file)
Set the includer file.
|
void |
setInputStream(InputStream stream)
Set the includer InputStream.
|
void |
setURL(URL url)
Set the includer URL.
|
void |
startElement(String uri,
String localname,
String qname,
Attributes attr) |
void |
startPrefixMapping(String prefix,
String uri) |
void |
warning(SAXParseException e)
Report an XML parsing warning.
|
void |
write(File file)
Write the resulting XML to a File.
|
void |
write(URL url)
Write the resulting XML to an URL.
|
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, unparsedEntityDecl
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
resetSAXParserFactoryImplementation, setAddComments, setSAXParserFactoryImplementation
public XMLIncluder()
public XMLIncluder(File file) throws MalformedURLException
file
- the fileMalformedURLException
public XMLIncluder(URL url)
url
- the URLpublic XMLIncluder(InputStream stream)
stream
- the InputStreampublic void setAllowInternalReaders(boolean allowInternalReaders)
allowInternalReaders
- true if internal readers creation are allowed in this parser instance.public boolean isAllowingInternalReaders()
public void setCharset(Charset charset)
StandardCharsets.UTF_8
.setCharset
in interface XMLChildrenIncluder
charset
- the charsetpublic Charset getCharset()
getCharset
in interface XMLChildrenIncluder
public void setFile(File file) throws MalformedURLException
setFile
in interface XMLChildrenIncluder
file
- the fileMalformedURLException
public void setURL(URL url)
setURL
in interface XMLChildrenIncluder
url
- the URLpublic void setInputStream(InputStream stream)
setInputStream
in interface XMLChildrenIncluder
stream
- the InputStreampublic void setAddComments(boolean addComments, boolean deep)
setAddComments
in interface XMLChildrenIncluder
addComments
- true if a comment must be added for each included filedeep
- true if the comments in deep include declarations must be addedpublic boolean isAddingComments()
isAddingComments
in interface XMLChildrenIncluder
public boolean isEnablingDeepComments()
isEnablingDeepComments
in interface XMLChildrenIncluder
public void setClassLoader(ClassLoader loader)
XMLSAXParser.isRevertingOldReaderBehavior()
is false.loader
- the ClassLoaderpublic ClassLoader getClassLoader()
XMLSAXParser.isRevertingOldReaderBehavior()
is false.public void setErrorHandler(ErrorHandler errorHandler)
setErrorHandler
in interface XMLChildrenIncluder
errorHandler
- the ErrorHandlerpublic ErrorHandler getErrorHandler()
getErrorHandler
in interface XMLChildrenIncluder
public boolean hasFatalError()
public void setDefaultBaseDirectory(URL baseDir)
setDefaultBaseDirectory
in interface XMLChildrenIncluder
baseDir
- the default base directorypublic void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping
in interface ContentHandler
startPrefixMapping
in class DefaultHandler
SAXException
public void fatalError(SAXParseException e)
fatalError
in interface ErrorHandler
fatalError
in class DefaultHandler
public void error(SAXParseException e)
error
in interface ErrorHandler
error
in class DefaultHandler
public void warning(SAXParseException e)
warning
in interface ErrorHandler
warning
in class DefaultHandler
public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
characters
in class DefaultHandler
SAXException
public void startElement(String uri, String localname, String qname, Attributes attr) throws SAXException
startElement
in interface ContentHandler
startElement
in class DefaultHandler
SAXException
public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in class DefaultHandler
locator
- the locatorpublic void endElement(String uri, String localname, String qname) throws SAXException
endElement
in interface ContentHandler
endElement
in class DefaultHandler
SAXException
public String getContent()
getContent
in interface XMLChildrenIncluder
public void write(URL url) throws IOException
write
in interface XMLChildrenIncluder
url
- the URLIOException
public void write(File file) throws IOException
write
in interface XMLChildrenIncluder
file
- the FileIOException
public StringReader getReader()
getReader
in interface XMLChildrenIncluder