Class XMLMapHandler

java.lang.Object
com.helger.xml.microdom.util.XMLMapHandler

@Immutable public final class XMLMapHandler extends Object
Simple class that reads a generic String-to-String mapping from a classpath resource into a Map.
The XML file needs to look as follows:
 <mapping>
   <map key="..." value="..."/>
   <map key="..." value="..."/>
   ...
 </mapping>
 
Author:
Philip
  • Field Details

  • Method Details

    • readMap

      @Nullable @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsMap<String,String> readMap(@Nonnull com.helger.commons.io.IHasInputStream aISP)
    • readMap

      @Nonnull public static com.helger.commons.state.ESuccess readMap(@Nonnull com.helger.commons.io.IHasInputStream aISP, @Nonnull Map<String,String> aTargetMap)
    • readMap

      @Nullable @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsMap<String,String> readMap(@Nonnull @WillClose InputStream aIS)
      Read a mapping from the passed input stream.
      Parameters:
      aIS - The input stream to read from. May not be null.
      Returns:
      null if reading the map failed
    • readMap

      @Nonnull public static com.helger.commons.state.ESuccess readMap(@Nonnull @WillClose InputStream aIS, @Nonnull Map<String,String> aTargetMap)
      Read a mapping from the passed input stream.
      Parameters:
      aIS - The input stream to read from. May not be null.
      aTargetMap - The target map to be filled.
      Returns:
      ESuccess.SUCCESS if the stream could be opened, if it could be read as XML and if the root element was correct. ESuccess.FAILURE otherwise.
    • readMap

      @Nonnull public static com.helger.commons.state.ESuccess readMap(@Nonnull IMicroElement aParentElement, @Nonnull Map<String,String> aTargetMap)
    • createMapDocument

      @Nonnull public static IMicroDocument createMapDocument(@Nonnull Map<String,String> aMap)
    • writeMap

      @Nonnull public static com.helger.commons.state.ESuccess writeMap(@Nonnull Map<String,String> aMap, @Nonnull com.helger.commons.io.IHasOutputStream aOSP)
    • writeMap

      @Nonnull public static com.helger.commons.state.ESuccess writeMap(@Nonnull Map<String,String> aMap, @Nonnull @WillClose OutputStream aOS)
      Write the passed map to the passed output stream using the predefined XML layout.
      Parameters:
      aMap - 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.