R - The return type.public abstract class AbstractResourceLoader<R>
extends java.lang.Object
| Constructor | Description |
|---|---|
AbstractResourceLoader(cdc.util.lang.FailureReaction reaction) |
Creates a Loader with reaction to adopt in case of error.
|
| Modifier and Type | Method | Description |
|---|---|---|
org.apache.logging.log4j.Logger |
getLogger() |
|
cdc.util.events.ProgressSupplier |
getProgressSupplier() |
|
cdc.util.lang.FailureReaction |
getReaction() |
|
protected abstract R |
loadRoot(Element root) |
Method that must be implemented by concrete classes to load the file.
|
R |
loadXml(java.io.File file,
cdc.util.compress.Compressor compressor,
XmlDataReader.Feature... features) |
Loads an XML file, possibly compressed.
|
R |
loadXml(java.io.File file,
XmlDataReader.Feature... features) |
Loads an uncompressed XML file.
|
R |
loadXml(java.io.InputStream is,
java.lang.String systemId,
cdc.util.compress.Compressor compressor,
XmlDataReader.Feature... features) |
Loads an XML input stream, possibly compressed.
|
R |
loadXml(java.io.InputStream is,
java.lang.String systemId,
XmlDataReader.Feature... features) |
Loads an uncompressed XML input stream.
|
R |
loadXml(java.lang.String filename,
cdc.util.compress.Compressor compressor,
XmlDataReader.Feature... features) |
Loads an XML file, possibly compressed.
|
R |
loadXml(java.lang.String filename,
XmlDataReader.Feature... features) |
Loads an uncompressed XML file.
|
R |
loadXml(java.net.URL url,
cdc.util.compress.Compressor compressor,
XmlDataReader.Feature... features) |
Loads an XML URL, possibly compressed.
|
R |
loadXml(java.net.URL url,
XmlDataReader.Feature... features) |
Loads an uncompressed XML URL.
|
void |
loadXml(java.util.List<java.net.URL> urls,
cdc.util.compress.Compressor compressor,
XmlDataReader.Feature... features) |
Loads a list of XML URLs, possibly compressed.
|
void |
loadXml(java.util.List<java.net.URL> urls,
XmlDataReader.Feature... features) |
Loads a list of uncompressed XML URLs.
|
protected void |
onError(java.lang.String message) |
Function that either keeps silent, warns or raises an exception,
depending on error reaction.
|
protected <T> T |
onError(java.lang.String message,
T def) |
Function that either silently returns a value, warns and returns a value
or raises an exception, depending on error reaction.
|
protected <T> T |
onResult(T result,
java.lang.String message,
T def) |
Function that returns a computed value if it is not
null,
or silently returns a default value, warns and returns a default value
or throws an exception. |
void |
setProgressController(cdc.util.events.ProgressController controller) |
Associates a progress controller to this loader.
|
protected void |
unexpectedElement(Element element,
java.lang.String... expected) |
|
protected <V> V |
unexpectedElement(Element element,
V def,
java.lang.String... expected) |
public AbstractResourceLoader(cdc.util.lang.FailureReaction reaction)
A logger named from the class is created.
reaction - The reaction to adopt in case of error.public final org.apache.logging.log4j.Logger getLogger()
public final cdc.util.lang.FailureReaction getReaction()
public void setProgressController(cdc.util.events.ProgressController controller)
controller - The progress controller.public cdc.util.events.ProgressSupplier getProgressSupplier()
public final R loadXml(java.io.File file, cdc.util.compress.Compressor compressor, XmlDataReader.Feature... features) throws java.io.IOException
file - The file.compressor - The compressor to use (if the file is compressed).features - The enabled XMLDataReader features.java.io.IOException - When an IO exception occurs.public final R loadXml(java.io.File file, XmlDataReader.Feature... features) throws java.io.IOException
file - The file.features - The enabled XMLDataReader features.java.io.IOException - When an IO exception occurs.public final R loadXml(java.lang.String filename, cdc.util.compress.Compressor compressor, XmlDataReader.Feature... features) throws java.io.IOException
filename - The file name.compressor - The compressor to use (if the file is compressed).features - The enabled XMLDataReader features.java.io.IOException - When an IO exception occurs.public final R loadXml(java.lang.String filename, XmlDataReader.Feature... features) throws java.io.IOException
filename - The file name.features - The enabled XMLDataReader features.java.io.IOException - When an IO exception occurs.public final R loadXml(java.net.URL url, cdc.util.compress.Compressor compressor, XmlDataReader.Feature... features) throws java.io.IOException
url - The URL.compressor - The compressor to use (if the file is compressed).features - The enabled XMLDataReader features.java.io.IOException - When an IO exception occurs.public final R loadXml(java.net.URL url, XmlDataReader.Feature... features) throws java.io.IOException
url - The URL.features - The enabled XMLDataReader features.java.io.IOException - When an IO exception occurs.public final void loadXml(java.util.List<java.net.URL> urls,
cdc.util.compress.Compressor compressor,
XmlDataReader.Feature... features)
urls - The list of URLs.compressor - The compressor to use (if the URLs are compressed).features - The enabled XMLDataReader features.public final void loadXml(java.util.List<java.net.URL> urls,
XmlDataReader.Feature... features)
urls - The list of URLs.features - The enabled XMLDataReader features.public final R loadXml(java.io.InputStream is, java.lang.String systemId, cdc.util.compress.Compressor compressor, XmlDataReader.Feature... features) throws java.io.IOException
is - The input stream.systemId - The system id.compressor - The compressor to use (if the input stream is compressed).features - The enabled XMLDataReader features.java.io.IOException - When an IO exception occurs.public final R loadXml(java.io.InputStream is, java.lang.String systemId, XmlDataReader.Feature... features) throws java.io.IOException
is - The input stream.systemId - The system id.features - The enabled XMLDataReader features.java.io.IOException - When an IO exception occurs.protected abstract R loadRoot(Element root) throws java.io.IOException
root - The root element.java.io.IOException - When an IO exception occurs.protected final void onError(java.lang.String message)
message - The error message.DataException - When error reaction is FailureReaction.FAIL.protected final <T> T onError(java.lang.String message,
T def)
T - The return type.message - The error message.def - The default return value.def if error reaction is FailureReaction.DEFAULT
or FailureReaction.WARN.DataException - When error reaction is FailureReaction.FAIL.protected final <T> T onResult(T result,
java.lang.String message,
T def)
null,
or silently returns a default value, warns and returns a default value
or throws an exception.T - The return type.result - The computed result.message - The error message.def - The default return value.result if it is not null, or def if
error reaction is FailureReaction.DEFAULT
or FailureReaction.WARN.DataException - When result is null
and error reaction is FailureReaction.FAIL.protected final void unexpectedElement(Element element, java.lang.String... expected)
protected final <V> V unexpectedElement(Element element, V def, java.lang.String... expected)
Copyright © 2019. All rights reserved.