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 TypeMethodDescriptioncharcharAt(int index) Returns thebytevalue at the specified index.intgetECIValue(int index) Returns theintECI value at the specified index.intbooleanhaveNCharacters(int index, int n) booleanisECI(int index) Determines if a value is an ECIbooleanisFNC1(int index) Determines if a value is the FNC1 characterintlength()Returns the length of this input.subSequence(int start, int end) Returns aCharSequencethat 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 ofbytes, FNC1 characters or ECIs in the sequence. -
haveNCharacters
public boolean haveNCharacters(int index, int n) - Specified by:
haveNCharactersin interfaceECIInput
-
charAt
public char charAt(int index) Returns thebytevalue at the specified index. An index ranges from zero tolength() - 1. The firstbytevalue of the sequence is at index zero, the next at index one, and so on, as for array indexing.- Specified by:
charAtin interfaceECIInput- Parameters:
index- the index of thebytevalue to be returned- Returns:
- the specified
bytevalue as character or the FNC1 character - Throws:
IndexOutOfBoundsException- if theindexargument is negative or not less thanlength()IllegalArgumentException- if the value at theindexargument is an ECI (@see #isECI)
-
subSequence
Returns aCharSequencethat is a subsequence of this sequence. The subsequence starts with thecharvalue at the specified index and ends with thecharvalue at indexend - 1. The length (inchars) of the returned sequence isend - start, so ifstart == endthen an empty sequence is returned.- Specified by:
subSequencein interfaceECIInput- Parameters:
start- the start index, inclusiveend- the end index, exclusive- Returns:
- the specified subsequence
- Throws:
IndexOutOfBoundsException- ifstartorendare negative, ifendis greater thanlength(), or ifstartis greater thanendIllegalArgumentException- if a value in the rangestart-endis an ECI (@see #isECI)
-
isECI
public boolean isECI(int index) Determines if a value is an ECI- Specified by:
isECIin interfaceECIInput- Parameters:
index- the index of the value- Returns:
- true if the value at position
indexis an ECI - Throws:
IndexOutOfBoundsException- if theindexargument 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
indexis the FNC1 character - Throws:
IndexOutOfBoundsException- if theindexargument is negative or not less thanlength()
-
getECIValue
public int getECIValue(int index) Returns theintECI value at the specified index. An index ranges from zero tolength() - 1. The firstbytevalue of the sequence is at index zero, the next at index one, and so on, as for array indexing.- Specified by:
getECIValuein interfaceECIInput- Parameters:
index- the index of theintvalue to be returned- Returns:
- the specified
intECI 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 theindexargument is negative or not less thanlength()IllegalArgumentException- if the value at theindexargument is not an ECI (@see #isECI)
-
toString
-