Package com.nulabinc.zxcvbn
Class WipeableString
- java.lang.Object
-
- com.nulabinc.zxcvbn.WipeableString
-
- All Implemented Interfaces:
java.lang.CharSequence
public class WipeableString extends java.lang.Object implements java.lang.CharSequence
A character sequence with many attributes of Strings, but that can have its content wiped.
-
-
Constructor Summary
Constructors Constructor Description WipeableString(char[] source)
Creates a new wipeable string, copying the content from the specified source.WipeableString(java.lang.CharSequence source)
Creates a new wipeable string, copying the content from the specified source.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description char[]
charArray()
Returns a copy of the content as a char array.char
charAt(int index)
int
codePointAt(int index)
Returns the nth Unicode code point.static WipeableString
copy(java.lang.CharSequence source, int start, int end)
Returns a copy of a portion of a character sequence as a wipeable string.boolean
equals(java.lang.Object obj)
int
hashCode()
int
indexOf(char character)
Returns the position of the first match of the specified character (indexed from 0).boolean
isWiped()
Returns true if the wipeable string has been wiped.int
length()
static WipeableString
lowerCase(java.lang.CharSequence source)
Returns a new wipeable string with the specified content forced into lower case.static int
parseInt(java.lang.CharSequence s)
A version of Integer.parse(String) that accepts CharSequence as parameter.static int
parseInt(java.lang.CharSequence s, int radix)
A version of Integer.parse(String) that accepts CharSequence as parameter.static WipeableString
reversed(java.lang.CharSequence source)
Returns a new wipeable string with the specified content but with the order of the characters reversed.WipeableString
subSequence(int start, int end)
java.lang.String
toString()
void
wipe()
Wipe the content of the wipeable string.static void
wipeIfPossible(java.lang.CharSequence text)
Wipes the content of the specified character sequence if possible.
-
-
-
Method Detail
-
length
public int length()
- Specified by:
length
in interfacejava.lang.CharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAt
in interfacejava.lang.CharSequence
-
subSequence
public WipeableString subSequence(int start, int end)
- Specified by:
subSequence
in interfacejava.lang.CharSequence
-
wipe
public void wipe()
Wipe the content of the wipeable string.Overwrites the content buffer with spaces, then replaces the buffer with an empty one.
-
lowerCase
public static WipeableString lowerCase(java.lang.CharSequence source)
Returns a new wipeable string with the specified content forced into lower case.
-
reversed
public static WipeableString reversed(java.lang.CharSequence source)
Returns a new wipeable string with the specified content but with the order of the characters reversed.
-
copy
public static WipeableString copy(java.lang.CharSequence source, int start, int end)
Returns a copy of a portion of a character sequence as a wipeable string.
-
indexOf
public int indexOf(char character)
Returns the position of the first match of the specified character (indexed from 0).
-
codePointAt
public int codePointAt(int index)
Returns the nth Unicode code point.
-
isWiped
public boolean isWiped()
Returns true if the wipeable string has been wiped.
-
charArray
public char[] charArray()
Returns a copy of the content as a char array.
-
parseInt
public static int parseInt(java.lang.CharSequence s) throws java.lang.NumberFormatException
A version of Integer.parse(String) that accepts CharSequence as parameter.- Throws:
java.lang.NumberFormatException
-
parseInt
public static int parseInt(java.lang.CharSequence s, int radix) throws java.lang.NumberFormatException
A version of Integer.parse(String) that accepts CharSequence as parameter.- Throws:
java.lang.NumberFormatException
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfacejava.lang.CharSequence
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
wipeIfPossible
public static void wipeIfPossible(java.lang.CharSequence text)
Wipes the content of the specified character sequence if possible.The following types can be wiped... WipeableString StringBuilder StringBuffer CharBuffer (if not readOnly)
-
-