Package com.rtfparserkit.parser.standard
Class UprHandler
- java.lang.Object
-
- com.rtfparserkit.parser.standard.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.
-
-
Field Summary
Fields Modifier and Type Field Description private booleancompleteprivate java.util.List<IParserEvent>eventsprivate intgroupCountprivate IParserEventHandlerhandler
-
Constructor Summary
Constructors Constructor Description UprHandler(IParserEventHandler handler)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IParserEventgetLastEvent()Retrieve the last event seen by the handler.voidhandleEvent(IParserEvent event)Buffers events until the end of the group containing the upr command is reached.booleanisComplete()Returns true once the end of the group containing the upr command as been reached.private voidprocessCommands()Extracts the Unicode version of the commands wrapped by the upr command and passes them to the listener.voidremoveLastEvent()Assumes the handler is buffering events, and removes the last event from this buffer.
-
-
-
Field Detail
-
handler
private final IParserEventHandler handler
-
groupCount
private int groupCount
-
complete
private boolean complete
-
events
private final java.util.List<IParserEvent> events
-
-
Constructor Detail
-
UprHandler
public UprHandler(IParserEventHandler handler)
Constructor.
-
-
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:
handleEventin interfaceIParserEventHandler
-
getLastEvent
public IParserEvent getLastEvent()
Retrieve the last event seen by the handler.- Specified by:
getLastEventin interfaceIParserEventHandler
-
removeLastEvent
public void removeLastEvent()
Assumes the handler is buffering events, and removes the last event from this buffer.- Specified by:
removeLastEventin interfaceIParserEventHandler
-
isComplete
public boolean isComplete()
Returns true once the end of the group containing the upr command as been reached.- Specified by:
isCompletein interfaceIParserEventHandler
-
processCommands
private void processCommands()
Extracts the Unicode version of the commands wrapped by the upr command and passes them to the listener.
-
-