public class MinimalECIInput extends java.lang.Object implements ECIInput
Modifier and Type | Class and Description |
---|---|
private static class |
MinimalECIInput.InputEdge |
Modifier and Type | Field and Description |
---|---|
private int[] |
bytes |
private static int |
COST_PER_ECI |
private int |
fnc1 |
Constructor and Description |
---|
MinimalECIInput(java.lang.String stringToEncode,
java.nio.charset.Charset priorityCharset,
int fnc1)
Constructs a minimal input
|
Modifier and Type | Method and Description |
---|---|
(package private) static void |
addEdge(MinimalECIInput.InputEdge[][] edges,
int to,
MinimalECIInput.InputEdge edge) |
(package private) static void |
addEdges(java.lang.String stringToEncode,
ECIEncoderSet encoderSet,
MinimalECIInput.InputEdge[][] edges,
int from,
MinimalECIInput.InputEdge previous,
int fnc1) |
char |
charAt(int index)
Returns the
byte value at the specified index. |
(package private) static int[] |
encodeMinimally(java.lang.String stringToEncode,
ECIEncoderSet encoderSet,
int fnc1) |
int |
getECIValue(int index)
Returns the
int ECI value at the specified index. |
int |
getFNC1Character() |
boolean |
haveNCharacters(int index,
int n) |
boolean |
isECI(int index)
Determines if a value is an ECI
|
boolean |
isFNC1(int index)
Determines if a value is the FNC1 character
|
int |
length()
Returns the length of this input.
|
java.lang.CharSequence |
subSequence(int start,
int end)
Returns a
CharSequence that is a subsequence of this sequence. |
java.lang.String |
toString() |
private static final int COST_PER_ECI
private final int[] bytes
private final int fnc1
public MinimalECIInput(java.lang.String stringToEncode, java.nio.charset.Charset priorityCharset, int fnc1)
stringToEncode
- the character string to encodepriorityCharset
- The preferred Charset
. When the value of the argument is null, the algorithm
chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority
charset to encode any character in the input that can be encoded by it if the charset is among the
supported charsets.fnc1
- denotes the character in the input that represents the FNC1 character or -1 if this is not GS1
input.public int getFNC1Character()
public int length()
byte
s, FNC1 characters or ECIs in the sequence.public boolean haveNCharacters(int index, int n)
haveNCharacters
in interface ECIInput
public char charAt(int index)
byte
value at the specified index. An index ranges from zero
to length() - 1
. The first byte
value of the sequence is at
index zero, the next at index one, and so on, as for array
indexing.charAt
in interface ECIInput
index
- the index of the byte
value to be returnedbyte
value as character or the FNC1 characterjava.lang.IndexOutOfBoundsException
- if the index
argument is negative or not less than
length()
java.lang.IllegalArgumentException
- if the value at the index
argument is an ECI (@see #isECI)public java.lang.CharSequence subSequence(int start, int end)
CharSequence
that is a subsequence of this sequence.
The subsequence starts with the char
value at the specified index and
ends with the char
value at index end - 1
. The length
(in char
s) of the
returned sequence is end - start
, so if start == end
then an empty sequence is returned.subSequence
in interface ECIInput
start
- the start index, inclusiveend
- the end index, exclusivejava.lang.IndexOutOfBoundsException
- if start
or end
are negative,
if end
is greater than length()
,
or if start
is greater than end
java.lang.IllegalArgumentException
- if a value in the range start
-end
is an ECI (@see #isECI)public boolean isECI(int index)
public boolean isFNC1(int index)
index
- the index of the valueindex
is the FNC1 characterjava.lang.IndexOutOfBoundsException
- if the index
argument is negative or not less than
length()
public int getECIValue(int index)
int
ECI value at the specified index. An index ranges from zero
to length() - 1
. The first byte
value of the sequence is at
index zero, the next at index one, and so on, as for array
indexing.getECIValue
in interface ECIInput
index
- the index of the int
value to be returnedint
ECI value.
The ECI specified the encoding of all bytes with a higher index until the
next ECI or until the end of the input if no other ECI follows.java.lang.IndexOutOfBoundsException
- if the index
argument is negative or not less than
length()
java.lang.IllegalArgumentException
- if the value at the index
argument is not an ECI (@see #isECI)public java.lang.String toString()
toString
in class java.lang.Object
static void addEdge(MinimalECIInput.InputEdge[][] edges, int to, MinimalECIInput.InputEdge edge)
static void addEdges(java.lang.String stringToEncode, ECIEncoderSet encoderSet, MinimalECIInput.InputEdge[][] edges, int from, MinimalECIInput.InputEdge previous, int fnc1)
static int[] encodeMinimally(java.lang.String stringToEncode, ECIEncoderSet encoderSet, int fnc1)