Class TagDropper

All Implemented Interfaces:
TagValueListener, TagValueWrapper

public class TagDropper extends SimpleTagValueWrapper
Silently drop all tags except those specified, and pass the rest onto a delegate.
Since:
1.2
Author:
Matthew Pocock
  • Constructor Details

    • TagDropper

      public TagDropper()
    • TagDropper

      Create a new TagDropper that will pass on all retained tags and values to tvl. Initially, no tags will be retained.
      Parameters:
      tvl - the TagValueListener to inform of all surviving events
  • Method Details

    • addTag

      public void addTag(Object tag)
      Add a tag to retain.
      Parameters:
      tag - a tag that will be forwarded to the delegate
    • removeTag

      public void removeTag(Object tag)
      Remove a tag so that it will not be retained.
      Parameters:
      tag - a tag that will not be forwarded to the delegate
    • getTags

      public Set getTags()
      Get the complete set of tags that are currently recognized.
      Returns:
      the Set of known tags
    • setRetain

      public void setRetain(boolean retain)
      Set wether known tags are to be retained or dropped.

      If retain is true, then all known tags will be passed on and all other tags will be discarded. If retain is true, then all known tags will be dropped and all others passed on.

      Parameters:
      retain - true if the tags are to be retained
    • doRetain

      public boolean doRetain()
      Find out if known tags are retained or dropped.
      Returns:
      true if values are retained
    • startTag

      public void startTag(Object tag) throws ParserException
      Description copied from interface: TagValueListener
      Start a new tag.
      Specified by:
      startTag in interface TagValueListener
      Overrides:
      startTag in class SimpleTagValueWrapper
      Parameters:
      tag - the Object representing the new tag
      Throws:
      ParserException - if the tag could not be started
    • endTag

      public void endTag() throws ParserException
      Description copied from interface: TagValueListener
      End the current tag.
      Specified by:
      endTag in interface TagValueListener
      Overrides:
      endTag in class SimpleTagValueWrapper
      Throws:
      ParserException - if the tag could not be ended
    • value

      public void value(TagValueContext ctxt, Object value) throws ParserException
      Description copied from interface: TagValueListener
      A value has been seen.
      Specified by:
      value in interface TagValueListener
      Overrides:
      value in class SimpleTagValueWrapper
      Parameters:
      ctxt - a TagValueContext that could be used to push a sub-document
      value - the value Object observed
      Throws:
      ParserException - if the value could not be processed