Package com.helger.xml.microdom.util
Class XMLListHandler
- java.lang.Object
-
- com.helger.xml.microdom.util.XMLListHandler
-
@Immutable public final class XMLListHandler extends Object
Simple class that reads a list from an XML input stream.
The XML file needs to look as follows:<list> <item value="..."/> <item value="..."/> ... </list>
- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_VALUEAttribute name for the item valuestatic StringELEMENT_ITEMElement name of a single itemstatic StringELEMENT_LISTName of the root element
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IMicroDocumentcreateListDocument(Collection<String> aCollection)static com.helger.commons.collection.impl.ICommonsList<String>readList(com.helger.commons.io.IHasInputStream aISP)static com.helger.commons.state.ESuccessreadList(com.helger.commons.io.IHasInputStream aISP, Collection<String> aTargetList)static com.helger.commons.state.ESuccessreadList(IMicroElement aParentElement, Collection<String> aTargetList)static com.helger.commons.collection.impl.ICommonsList<String>readList(InputStream aIS)Read a predefined XML file that contains list items.static com.helger.commons.state.ESuccessreadList(InputStream aIS, Collection<String> aTargetList)Read a predefined XML file that contains list items.static com.helger.commons.state.ESuccesswriteList(Collection<String> aCollection, com.helger.commons.io.IHasOutputStream aOSP)static com.helger.commons.state.ESuccesswriteList(Collection<String> aCollection, OutputStream aOS)Write the passed collection to the passed output stream using the predefined XML layout.
-
-
-
Field Detail
-
ELEMENT_LIST
public static final String ELEMENT_LIST
Name of the root element- See Also:
- Constant Field Values
-
ELEMENT_ITEM
public static final String ELEMENT_ITEM
Element name of a single item- See Also:
- Constant Field Values
-
ATTR_VALUE
public static final String ATTR_VALUE
Attribute name for the item value- See Also:
- Constant Field Values
-
-
Method Detail
-
readList
@Nullable @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsList<String> readList(@Nonnull com.helger.commons.io.IHasInputStream aISP)
-
readList
@Nonnull public static com.helger.commons.state.ESuccess readList(@Nonnull com.helger.commons.io.IHasInputStream aISP, @Nonnull Collection<String> aTargetList)
-
readList
@Nullable @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsList<String> readList(@Nonnull @WillClose InputStream aIS)
Read a predefined XML file that contains list items.- Parameters:
aIS- The input stream to read from. May not benull. Automatically closed no matter whether reading succeeded or not.- Returns:
nullif reading fails - all list items otherwise.
-
readList
@Nonnull public static com.helger.commons.state.ESuccess readList(@Nonnull @WillClose InputStream aIS, @Nonnull Collection<String> aTargetList)
Read a predefined XML file that contains list items.- Parameters:
aIS- The input stream to read from. May not benull. Automatically closed no matter whether reading succeeded or not.aTargetList- The target collection to be filled. May not benull.- Returns:
ESuccess.SUCCESSif reading succeeded,ESuccess.FAILUREif the input stream is no valid XML or any other error occurred.
-
readList
@Nonnull public static com.helger.commons.state.ESuccess readList(@Nonnull IMicroElement aParentElement, @Nonnull Collection<String> aTargetList)
-
createListDocument
@Nonnull public static IMicroDocument createListDocument(@Nonnull Collection<String> aCollection)
-
writeList
@Nonnull public static com.helger.commons.state.ESuccess writeList(@Nonnull Collection<String> aCollection, @Nonnull com.helger.commons.io.IHasOutputStream aOSP)
-
writeList
@Nonnull public static com.helger.commons.state.ESuccess writeList(@Nonnull Collection<String> aCollection, @Nonnull @WillClose OutputStream aOS)
Write the passed collection to the passed output stream using the predefined XML layout.- Parameters:
aCollection- The map to be written. May not benull.aOS- The output stream to write to. The stream is closed independent of success or failure. May not benull.- Returns:
ESuccess.SUCCESSwhen everything went well,ESuccess.FAILUREotherwise.
-
-