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 boolean
hasNext()
Determine if this sequence has another element.int
index()
Get the current index of the PushbackString.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.static boolean
isOctalDigit(java.lang.Character c)
Returns true if the parameter character is an octal digit 0 through 7.void
mark()
Mark the location of the current index.java.lang.Character
next()
Return the next element in the Sequence and increment the current index.java.lang.Character
nextHex()
Return the next element in the Sequence in Hex format and increment the current index.java.lang.Character
nextOctal()
Return the next element in the Sequence in Octal format and increment the current index.java.lang.Character
peek()
Return the next element in the Sequence without affecting the current index.boolean
peek(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.String
remainder()
Not at all sure what this method is intended to do.void
reset()
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:AbstractPushbackSequence
Get the current index of the PushbackString. Typically used in error messages.- Specified by:
index
in interfacePushbackSequence<java.lang.Character>
- Overrides:
index
in classAbstractPushbackSequence<java.lang.Character>
- Returns:
- The current index of the PushbackSequence.
-
hasNext
public boolean hasNext()
Description copied from class:AbstractPushbackSequence
Determine if this sequence has another element.- Specified by:
hasNext
in interfacePushbackSequence<java.lang.Character>
- Overrides:
hasNext
in 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:PushbackSequence
Return 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:PushbackSequence
Return 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:PushbackSequence
Return 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:PushbackSequence
Return 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:PushbackSequence
Test 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).
-
-