Class UprHandler

  • All Implemented Interfaces:
    IParserEventHandler

    public class UprHandler
    extends java.lang.Object
    implements IParserEventHandler
    The upr command is used to wrap two different versions of the same set of formatting commands. The first set of formatting commands uses ANSI encoding, the second set uses Unicode. The upr command is expected to appear in its own group, so this handler can be used to consume all of the RTF events received up to the end of the group It can then pass the Unicode version of the command it wraps to the listener, discarding the ANSI version.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IParserEvent getLastEvent()
      Retrieve the last event seen by the handler.
      void handleEvent​(IParserEvent event)
      Buffers events until the end of the group containing the upr command is reached.
      boolean isComplete()
      Returns true once the end of the group containing the upr command as been reached.
      private void processCommands()
      Extracts the Unicode version of the commands wrapped by the upr command and passes them to the listener.
      void removeLastEvent()
      Assumes the handler is buffering events, and removes the last event from this buffer.
      • Methods inherited from class java.lang.Object

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

      • groupCount

        private int groupCount
      • complete

        private boolean complete
    • Method Detail

      • handleEvent

        public void handleEvent​(IParserEvent event)
        Buffers events until the end of the group containing the upr command is reached. Once the end of the group is reached, the buffered events representing the Unicode content is sent to the listener.
        Specified by:
        handleEvent in interface IParserEventHandler
      • removeLastEvent

        public void removeLastEvent()
        Assumes the handler is buffering events, and removes the last event from this buffer.
        Specified by:
        removeLastEvent in interface IParserEventHandler
      • isComplete

        public boolean isComplete()
        Returns true once the end of the group containing the upr command as been reached.
        Specified by:
        isComplete in interface IParserEventHandler
      • processCommands

        private void processCommands()
        Extracts the Unicode version of the commands wrapped by the upr command and passes them to the listener.