Class MapFilter

java.lang.Object
org.simpleframework.xml.filter.MapFilter
All Implemented Interfaces:
Filter

public class MapFilter extends Object implements Filter
The MapFilter object is a filter that can make use of user specified mappings for replacement. This filter can be given a Map of name value pairs which will be used to resolve a value using the specified mappings. If there is no match found the filter will delegate to the provided filter.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Filter
    This will resolve the replacement if no mapping is found.
    private Map
    This contains a collection of user specified mappings.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the MapFilter object.
    MapFilter(Map map, Filter filter)
    Constructor for the MapFilter object.
  • Method Summary

    Modifier and Type
    Method
    Description
    Replaces the text provided with the value resolved from the specified Map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • filter

      private Filter filter
      This will resolve the replacement if no mapping is found.
    • map

      private Map map
      This contains a collection of user specified mappings.
  • Constructor Details

    • MapFilter

      public MapFilter(Map map)
      Constructor for the MapFilter object. This will use the specified mappings to resolve replacements. If this map does not contain a requested mapping null is resolved.
      Parameters:
      map - this contains the user specified mappings
    • MapFilter

      public MapFilter(Map map, Filter filter)
      Constructor for the MapFilter object. This will use the specified mappings to resolve replacements. If this map does not contain a requested mapping the provided filter is used to resolve the replacement text.
      Parameters:
      map - this contains the user specified mappings
      filter - this is delegated to if the map fails
  • Method Details

    • replace

      public String replace(String text)
      Replaces the text provided with the value resolved from the specified Map. If the map fails this will delegate to the specified Filter if it is not a null object. If no match is found a null is returned.
      Specified by:
      replace in interface Filter
      Parameters:
      text - this is the text value to be replaced
      Returns:
      this will return the replacement text resolved