Package com.helger.xml.microdom.util
Class XMLListHandler
java.lang.Object
com.helger.xml.microdom.util.XMLListHandler
Simple class that reads a list from an XML input stream.
The XML file needs to look as follows:
The XML file needs to look as follows:
<list> <item value="..."/> <item value="..."/> ... </list>
- Author:
- Philip Helger
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
ELEMENT_LIST
Name of the root element- See Also:
-
ELEMENT_ITEM
Element name of a single item- See Also:
-
ATTR_VALUE
Attribute name for the item value- See Also:
-
-
Method Details
-
readList
-
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
-
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.
-