Package org.owasp.esapi.codecs
Class PushbackString
- java.lang.Object
-
- org.owasp.esapi.codecs.AbstractPushbackSequence<java.lang.Character>
-
- org.owasp.esapi.codecs.PushbackString
-
- All Implemented Interfaces:
PushbackSequence<java.lang.Character>
public class PushbackString extends AbstractPushbackSequence<java.lang.Character>
The pushback string is used by Codecs to allow them to push decoded characters back onto a string for further decoding. This is necessary to detect double-encoding.- Since:
- June 1, 2007
- Author:
- Jeff Williams (jeff.williams .at. aspectsecurity.com) Aspect Security
- See Also:
Encoder
-
-
Constructor Summary
Constructors Constructor Description PushbackString(java.lang.String input)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhasNext()Determine if this sequence has another element.intindex()Get the current index of the PushbackString.static booleanisHexDigit(java.lang.Character c)Returns true if the parameter character is a hexidecimal digit 0 through 9, a through f, or A through F.static booleanisOctalDigit(java.lang.Character c)Returns true if the parameter character is an octal digit 0 through 7.voidmark()Mark the location of the current index.java.lang.Characternext()Return the next element in the Sequence and increment the current index.java.lang.CharacternextHex()Return the next element in the Sequence in Hex format and increment the current index.java.lang.CharacternextOctal()Return the next element in the Sequence in Octal format and increment the current index.java.lang.Characterpeek()Return the next element in the Sequence without affecting the current index.booleanpeek(java.lang.Character c)Test to see if the next element in the Sequence matches the supplied value without affecting the current index.java.lang.Stringremainder()Not at all sure what this method is intended to do.voidreset()Set the index back to the last marked location.-
Methods inherited from class org.owasp.esapi.codecs.AbstractPushbackSequence
pushback
-
-
-
-
Method Detail
-
index
public int index()
Description copied from class:AbstractPushbackSequenceGet the current index of the PushbackString. Typically used in error messages.- Specified by:
indexin interfacePushbackSequence<java.lang.Character>- Overrides:
indexin classAbstractPushbackSequence<java.lang.Character>- Returns:
- The current index of the PushbackSequence.
-
hasNext
public boolean hasNext()
Description copied from class:AbstractPushbackSequenceDetermine if this sequence has another element.- Specified by:
hasNextin interfacePushbackSequence<java.lang.Character>- Overrides:
hasNextin classAbstractPushbackSequence<java.lang.Character>- Returns:
- True if there is another element in this sequence. False otherwise.
-
next
public java.lang.Character next()
Description copied from interface:PushbackSequenceReturn the next element in the Sequence and increment the current index.- Returns:
- The next element in the Sequence.
-
nextHex
public java.lang.Character nextHex()
Description copied from interface:PushbackSequenceReturn the next element in the Sequence in Hex format and increment the current index.- Returns:
- The next element in the Sequence in Hex format (if that makes sense for this Sequence's type).
-
nextOctal
public java.lang.Character nextOctal()
Description copied from interface:PushbackSequenceReturn the next element in the Sequence in Octal format and increment the current index.- Returns:
- The next element in the Sequence in Octal format (if that makes sense for this Sequence's type).
-
isHexDigit
public static boolean isHexDigit(java.lang.Character c)
Returns true if the parameter character is a hexidecimal digit 0 through 9, a through f, or A through F.- Parameters:
c-- Returns:
- true if it is a hexidecimal digit, false otherwise.
-
isOctalDigit
public static boolean isOctalDigit(java.lang.Character c)
Returns true if the parameter character is an octal digit 0 through 7.- Parameters:
c-- Returns:
- true if it is an octal digit, false otherwise.
-
peek
public java.lang.Character peek()
Description copied from interface:PushbackSequenceReturn the next element in the Sequence without affecting the current index.- Returns:
- the next element in the Sequence.
-
peek
public boolean peek(java.lang.Character c)
Description copied from interface:PushbackSequenceTest to see if the next element in the Sequence matches the supplied value without affecting the current index.- Parameters:
c- The value to match against.- Returns:
- True if the next element matches the supplied value. False otherwise.
-
mark
public void mark()
Mark the location of the current index.
-
reset
public void reset()
Set the index back to the last marked location.
-
remainder
public java.lang.String remainder()
Not at all sure what this method is intended to do. There is a line in HTMLEntityCodec that said calling this method is a "kludge around PushbackString..."- Returns:
- Return the remaining portion of the sequence, with any pushback appended to the front (if any).
-
-