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 Details

  • Method Details

    • 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 be null. Automatically closed no matter whether reading succeeded or not.
      Returns:
      null if 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 be null. Automatically closed no matter whether reading succeeded or not.
      aTargetList - The target collection to be filled. May not be null.
      Returns:
      ESuccess.SUCCESS if reading succeeded, ESuccess.FAILURE if 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 be null.
      aOS - The output stream to write to. The stream is closed independent of success or failure. May not be null.
      Returns:
      ESuccess.SUCCESS when everything went well, ESuccess.FAILURE otherwise.