Package com.google.zxing.common
Class MinimalECIInput
java.lang.Object
com.google.zxing.common.MinimalECIInput
- All Implemented Interfaces:
ECIInput
Class that converts a character string into a sequence of ECIs and bytes
The implementation uses the Dijkstra algorithm to produce minimal encodings
- Author:
- Alex Geller
-
Constructor Summary
ConstructorsConstructorDescriptionMinimalECIInput
(String stringToEncode, Charset priorityCharset, int fnc1) Constructs a minimal input -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int index) Returns thebyte
value at the specified index.int
getECIValue
(int index) Returns theint
ECI value at the specified index.int
boolean
haveNCharacters
(int index, int n) boolean
isECI
(int index) Determines if a value is an ECIboolean
isFNC1
(int index) Determines if a value is the FNC1 characterint
length()
Returns the length of this input.subSequence
(int start, int end) Returns aCharSequence
that is a subsequence of this sequence.toString()
-
Constructor Details
-
MinimalECIInput
Constructs a minimal input- Parameters:
stringToEncode
- the character string to encodepriorityCharset
- The preferredCharset
. 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.
-
-
Method Details
-
getFNC1Character
public int getFNC1Character() -
length
public int length()Returns the length of this input. The length is the number ofbyte
s, FNC1 characters or ECIs in the sequence. -
haveNCharacters
public boolean haveNCharacters(int index, int n) - Specified by:
haveNCharacters
in interfaceECIInput
-
charAt
public char charAt(int index) Returns thebyte
value at the specified index. An index ranges from zero tolength() - 1
. The firstbyte
value of the sequence is at index zero, the next at index one, and so on, as for array indexing.- Specified by:
charAt
in interfaceECIInput
- Parameters:
index
- the index of thebyte
value to be returned- Returns:
- the specified
byte
value as character or the FNC1 character - Throws:
IndexOutOfBoundsException
- if theindex
argument is negative or not less thanlength()
IllegalArgumentException
- if the value at theindex
argument is an ECI (@see #isECI)
-
subSequence
Returns aCharSequence
that is a subsequence of this sequence. The subsequence starts with thechar
value at the specified index and ends with thechar
value at indexend - 1
. The length (inchar
s) of the returned sequence isend - start
, so ifstart == end
then an empty sequence is returned.- Specified by:
subSequence
in interfaceECIInput
- Parameters:
start
- the start index, inclusiveend
- the end index, exclusive- Returns:
- the specified subsequence
- Throws:
IndexOutOfBoundsException
- ifstart
orend
are negative, ifend
is greater thanlength()
, or ifstart
is greater thanend
IllegalArgumentException
- if a value in the rangestart
-end
is an ECI (@see #isECI)
-
isECI
public boolean isECI(int index) Determines if a value is an ECI- Specified by:
isECI
in interfaceECIInput
- Parameters:
index
- the index of the value- Returns:
- true if the value at position
index
is an ECI - Throws:
IndexOutOfBoundsException
- if theindex
argument is negative or not less thanlength()
-
isFNC1
public boolean isFNC1(int index) Determines if a value is the FNC1 character- Parameters:
index
- the index of the value- Returns:
- true if the value at position
index
is the FNC1 character - Throws:
IndexOutOfBoundsException
- if theindex
argument is negative or not less thanlength()
-
getECIValue
public int getECIValue(int index) Returns theint
ECI value at the specified index. An index ranges from zero tolength() - 1
. The firstbyte
value of the sequence is at index zero, the next at index one, and so on, as for array indexing.- Specified by:
getECIValue
in interfaceECIInput
- Parameters:
index
- the index of theint
value to be returned- Returns:
- the specified
int
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. - Throws:
IndexOutOfBoundsException
- if theindex
argument is negative or not less thanlength()
IllegalArgumentException
- if the value at theindex
argument is not an ECI (@see #isECI)
-
toString
-