|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xins.common.types.Type org.xins.common.types.standard.Hex
Standard type _hex.
Field Summary | |
static Hex |
SINGLETON
The only instance of this class. |
Constructor Summary | |
protected |
Hex(String name,
int minimum,
int maximum)
Constructs a new Hex object (constructor for
subclasses). |
Method Summary | |
static byte[] |
fromStringForOptional(String string)
Converts the specified string value to a byte[] value. |
static byte[] |
fromStringForRequired(String string)
Converts the specified non- null string value to a
byte[] value. |
protected Object |
fromStringImpl(String string)
Converts from a String to an instance of the value class
for this type (implementation method).
|
String |
getDescription()
Retrieves the description of this type. |
protected boolean |
isValidValueImpl(String string)
Determines if the specified String value is considered
valid for this type (implementation method).
|
static String |
toString(byte[] value)
Converts the specified byte[] to a hexadecimal string. |
String |
toString(Object value)
Generates a string representation of the specified value for this type. |
Methods inherited from class org.xins.common.types.Type |
checkValue, fromString, getName, getValueClass, isValidValue, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Hex SINGLETON
null
.
Constructor Detail |
protected Hex(String name, int minimum, int maximum)
Hex
object (constructor for
subclasses).
name
- the name of this type, cannot be null
.minimum
- the minimum for the value.# minimum number of bytes this Hex can havemaximum
- the maximum for the value.# maximum number of bytes this Hex can haveMethod Detail |
public static byte[] fromStringForRequired(String string) throws IllegalArgumentException, TypeValueException
null
string value to a
byte[]
value.
string
- the hexadecimal string to convert, cannot be null
.
byte[]
value.
IllegalArgumentException
- if string == null
.
TypeValueException
- if the specified string does not represent a valid value for this
type.If the string does not have a hexadecimal value or have a character
that is not hexadecimal digit.public static byte[] fromStringForOptional(String string) throws TypeValueException
byte[]
value.
string
- the hexadecimal string to convert, can be null
.
null
if
string == null
.
TypeValueException
- if the specified string does not represent a valid value for this
type.If the string does not have a hexadecimal value or
have a character that is not hexadecimal digit.public static String toString(byte[] value)
byte[]
to a hexadecimal string.
value
- the value to convert, can be null
.
null
if and
only if value == null
.protected boolean isValidValueImpl(String string)
String
value is considered
valid for this type (implementation method).
This method is called from Type.isValidValue(String)
. When
called from that method, it is guaranteed that the argument is not
null
.
# 1.check if the string has hex digits
# 2. if the byte[] created from that string has minimum < byte[].length < maximum
isValidValueImpl
in class Type
string
- the String
value that should be checked for validity,
never null
.
true
if and only if the specified String
value is valid, false
otherwise.protected Object fromStringImpl(String string) throws TypeValueException
String
to an instance of the value class
for this type (implementation method).
This method is not required to check the validity of the specified
value (since isValidValueImpl(String)
should have been called
before) but if it does, then it may throw a TypeValueException
.
fromStringImpl
in class Type
string
- the string to convert to an instance of the value class, guaranteed
to be not null
and guaranteed to have been passed to
isValidValueImpl(String)
without getting an exception.
null
.
TypeValueException
- if string
is considered to be an invalid value for this
type.public final String toString(Object value) throws IllegalArgumentException, ClassCastException, TypeValueException
Type.getValueClass()
). Also, it may have to fall within a
certain range of valid values, depending on the type.
toString
in class Type
value
- the value, cannot be null
.
null
.
IllegalArgumentException
- if value == null
.
ClassCastException
- if getValueClass().isInstance(value) == false
.
TypeValueException
- if the specified value is not in the allowed range.
#Maybe this is redundant because i dont think that there is any possibility to be out of range
but since it exists also to other standard types i left it.public String getDescription()
Type
getDescription
in class Type
null
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |