|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD | |||||||||
java.lang.Objectjava.lang.Enum<SourceEnum>
sk.baka.ikslibs.SourceEnum
public enum SourceEnum
Enumerates all possible source types that exporter can accept as an input.
| Enum Constant Summary | |
|---|---|
DOM
The DOM Document instance source. |
|
OBJECT
Java Object source. |
|
SAX
The DocumentHandler instance source. |
|
STAX
STAX source. |
|
STREAM
InputStream source. |
|
| Field Summary | |
|---|---|
static List<SourceEnum> |
priorityList
List describing priorities for target-to-source conversion. |
| Method Summary | |
|---|---|
static void |
checkReadability(Source source)
If given source is not readable IllegalArgumentException is
thrown. |
abstract Source |
convert(Source source,
String encoding)
Tries to convert given source to this source type. |
static void |
copy(Source source,
Result result)
Performs a data copy from the source to the result. |
protected abstract void |
copyIntern(Source source,
Result result)
Performs a data copy from the source to the result. |
abstract ResultEnum |
getPair()
Returns result type that has the same type as this source. |
static EnumSet<ResultEnum> |
getPairSet(EnumSet<SourceEnum> sourceTypes)
Returns set consisting of pairs for all items in given set. |
static EnumSet<SourceEnum> |
getRedirectKinds(EnumSet<ResultEnum> products)
Computes all kinds of sources, that the product kinds are able to be redirected to. |
Class<? extends Source> |
getSourceClass()
Returns the class of Source object that is represented by the enum item. |
static boolean |
isReadable(Source source)
Checks if given source is readable (if it contains at least one non-null stream, node, etc). |
protected abstract boolean |
isReadableIntern(Source source)
Checks if given source is readable (if it contains at least one non-null stream, node, etc). |
boolean |
represents(Class<? extends Source> sourceClass)
Returns true if this enum constant represents Source object of required instance. |
static SourceEnum |
valueOf(Class<? extends Source> sourceClass)
Finds appropriate enum item for the source instance. |
static SourceEnum |
valueOf(String name)
Returns the enum constant of this type with the specified name. |
static SourceEnum[] |
values()
Returns an array containing the constants of this enum type, in the order they're declared. |
| Methods inherited from class java.lang.Enum |
|---|
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Enum Constant Detail |
|---|
public static final SourceEnum DOM
public static final SourceEnum SAX
public static final SourceEnum STREAM
public static final SourceEnum OBJECT
public static final SourceEnum STAX
| Field Detail |
|---|
public static final List<SourceEnum> priorityList
List describing priorities for target-to-source conversion. First item has the highest priority. Items priorities are as follows:
OBJECT - native data exchangeDOMSTAX - lowest memory consumption,SAX - lowest memory consumption,STREAM
| Method Detail |
|---|
public static final SourceEnum[] values()
for(SourceEnum c : SourceEnum.values())
System.out.println(c);
public static SourceEnum valueOf(String name)
name - the name of the enum constant to be returned.
IllegalArgumentException - if this enum type has no constant
with the specified namepublic final Class<? extends Source> getSourceClass()
public final boolean represents(Class<? extends Source> sourceClass)
sourceClass -
true if this enum constant represents this class,
false otherwise.public static SourceEnum valueOf(Class<? extends Source> sourceClass)
sourceClass - class of Source object instance.
public abstract ResultEnum getPair()
public abstract Source convert(Source source,
String encoding)
throws IOException,
TransformerException
Tries to convert given source to this source type. Conversion follows this table:
| From | To | Description |
| DOM | SAX, STAX | Standard conversion |
| SAX | DOM, STAX | Standard conversion |
| DOM, SAX, STAX | Stream | Serialization is performed. Result is valid XML file. Output document formatting is undefined. |
| Stream | DOM, SAX, STAX | Stream is not parsed - one Text node containing stream contents is constructed instead. Stream is expected to be in UTF-8 encoding. |
| Object | Stream, DOM, SAX, STAX | Returns null. |
| DOM, SAX, Stream, STAX | Object | Returns null |
If both kinds are same then source is simply returned. If
a different source is returned then you should not attempt to read from
the original source.
The conversion may be performed by a background thread, to save memory
space. The conversion simply uses TransformUtils' sourceToXXX
methods (depending on the source type). For full description of
blocking/thread safety please consult appropriate sourceToXXX method.
source - source to convert.encoding - the encoding to use when reading from/writing to a
stream. If null then it is detected from the source and/or
result. If it cannot be detected then UTF-8 is used. For details please
see TransformUtils.getEncoding(String, Source, Result).
null. Returned source instance is fully
initialized and prepared for reading.
IOException - if i/o error occurs during source reading.
TransformerException - if transformer fails while processing
source.
public static void copy(Source source,
Result result)
throws IOException
source - data source, must not be null. Must be
readable.result - data result, must not be null. Must be
writable.
IOException - if IO error occurs.protected abstract boolean isReadableIntern(Source source)
source - source to check
true if given source gives access to some content.public static boolean isReadable(Source source)
source - source to check
true if given source gives access to some content.public static void checkReadability(Source source)
IllegalArgumentException is
thrown.
source - source to check.
protected abstract void copyIntern(Source source,
Result result)
throws IOException
Performs a data copy from the source to the result. Both source and result will be of same kind. Blocks until the copy is finished. If copying from an input source to a writer (or vice versa), UTF-8 encoding is used.
source - data source, must not be null.result - data result, must not be null.
IOException - if IO error occurs.public static EnumSet<ResultEnum> getPairSet(EnumSet<SourceEnum> sourceTypes)
sourceTypes - the source types.
public static final EnumSet<SourceEnum> getRedirectKinds(EnumSet<ResultEnum> products)
products - set of result kinds.
products set.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD | |||||||||