- java.lang.Object
-
- com.github.rvesse.airline.io.ControlTracker<T>
-
- Type Parameters:
T
- Attribute source type
- Direct Known Subclasses:
OutputStreamControlTracker
,WriterControlTracker
public abstract class ControlTracker<T> extends java.lang.Object
Class used to track the state of a control allowing it to be lazily written to the output only if necessary and ensuring it can be appropriately reset when necessary
-
-
Field Summary
Fields Modifier and Type Field Description private T
current
private T
previous
protected ControlCodeSource<T>
provider
private boolean
requireWrite
-
Constructor Summary
Constructors Constructor Description ControlTracker(ControlCodeSource<T> provider)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
apply()
Applies the control, if the current state of the control has not been previously applied to the stream then it will be applied nowprotected abstract void
applyInternal(T value)
Method that derived classes must implement to add the actual logic for applying the control to the streamvoid
reset()
Resets the control to the default unintialized state, if necessary this will will cause theprotected abstract void
resetInternal(T value)
Method that derived classes must implement to add the actual logic for resetting the control against the streamvoid
set(T value)
Sets the value for the control
-
-
-
Field Detail
-
provider
protected final ControlCodeSource<T> provider
-
current
private T current
-
previous
private T previous
-
requireWrite
private boolean requireWrite
-
-
Constructor Detail
-
ControlTracker
public ControlTracker(ControlCodeSource<T> provider)
-
-
Method Detail
-
set
public final void set(T value)
Sets the value for the control- Parameters:
value
- Value
-
reset
public final void reset() throws java.io.IOException
Resets the control to the default unintialized state, if necessary this will will cause the- Throws:
java.io.IOException
-
resetInternal
protected abstract void resetInternal(T value) throws java.io.IOException
Method that derived classes must implement to add the actual logic for resetting the control against the stream- Parameters:
value
- Value to be reset from- Throws:
java.io.IOException
-
apply
public final void apply() throws java.io.IOException
Applies the control, if the current state of the control has not been previously applied to the stream then it will be applied now- Throws:
java.io.IOException
-
applyInternal
protected abstract void applyInternal(T value) throws java.io.IOException
Method that derived classes must implement to add the actual logic for applying the control to the stream- Parameters:
value
- Value to be applied- Throws:
java.io.IOException
-
-