public class ByteStringTranslator extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MAXNUM
The maximum number of values that this translator can handle.
|
| Constructor and Description |
|---|
ByteStringTranslator()
Initialize empty byte-string two-way translator.
|
ByteStringTranslator(int initialRange)
Prepare a ByteStringTranslator to hold the given amount of data.
|
ByteStringTranslator(String[] strings)
Initialize a byte-string two-way translator, setting byte values according to the position of strings in the array.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(byte b)
Check if the given (unsigned) byte value is contained in the list.
|
boolean |
contains(String s)
Verify if the given string can be translated into a byte by this translator.
|
String |
get(byte b)
Look up the (unsigned) byte in this translator.
|
byte |
get(String s)
Get the (unsigned) byte value associated to the given string.
|
int |
getNumberOfValues()
Give the number of different values in this translator.
|
String[] |
getStringValues() |
void |
set(byte b,
String s)
Associate the given (unsigned) byte with the given String.
|
public static final int MAXNUM
public ByteStringTranslator()
public ByteStringTranslator(int initialRange)
getNumberOfValues() will
still return 0, since there is no actual data yet.initialRange - the number of values to expectIllegalArgumentException - if initialRange is larger than the maximum number of values, MAXNUM.public ByteStringTranslator(String[] strings)
strings - a list of up to MAXNUM strings to be represented by unique byte values.IllegalArgumentException - if list of strings is longer than the maximum number of values, MAXNUM.public void set(byte b,
String s)
set((byte)129, "mystring")b - bs - spublic boolean contains(String s)
s - spublic boolean contains(byte b)
MAXNUM, cast
to byte: contains((byte)129) will indicate if there is a String for the 129'th byte value.b - bpublic byte get(String s)
s - svalue & 0xFF.IllegalArgumentException - if the string is unknown to the translator.public String get(byte b)
MAXNUM, cast to byte:
get((byte)129) will get you the 129'th item in the string list.b - bpublic String[] getStringValues()
public int getNumberOfValues()
Copyright © 2000–2016 DFKI GmbH. All rights reserved.