Class MinimalECIInput
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
public class MinimalECIInput : ECIInput
- Inheritance
-
MinimalECIInput
- Implements
- Inherited Members
Constructors
MinimalECIInput(string, Encoding, int)
Constructs a minimal input
public MinimalECIInput(string stringToEncode, Encoding priorityCharset, int fnc1)
Parameters
stringToEncode
stringthe character string to encode
priorityCharset
EncodingThe preferred {@link 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
intdenotes the character in the input that represents the FNC1 character or -1 if this is not GS1 input.
Properties
Length
Returns the length of this input. The length is the number of {@code byte}s, FNC1 characters or ECIs in the sequence.
public int Length { get; }
Property Value
Methods
ToString()
public override string ToString()
Returns
charAt(int)
Returns the {@code byte} value at the specified index. An index ranges from zero to {@code length() - 1}. The first {@code byte} value of the sequence is at index zero, the next at index one, and so on, as for array indexing.
public char charAt(int index)
Parameters
index
intthe index of the {@code byte} value to be returned
Returns
- char
the specified {@code byte} value as character or the FNC1 character
Exceptions
- IndexOutOfRangeException
if the {@code index} argument is negative or not less than {@code length()}
- ArgumentException
if the value at the {@code index} argument is an ECI (@see #isECI)
getECIValue(int)
Returns the {@code int} ECI value at the specified index. An index ranges from zero to {@code length() - 1}. The first {@code byte} value of the sequence is at index zero, the next at index one, and so on, as for array indexing.
public int getECIValue(int index)
Parameters
index
intthe index of the {@code int} value to be returned
Returns
- int
the specified {@code 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.
Exceptions
- IndexOutOfRangeException
if the {@code index} argument is negative or not less than {@code length()}
- ArgumentException
if the value at the {@code index} argument is not an ECI (@see #isECI)
getFNC1Character()
public int getFNC1Character()
Returns
haveNCharacters(int, int)
public bool haveNCharacters(int index, int n)
Parameters
Returns
isECI(int)
Determines if a value is an ECI
public bool isECI(int index)
Parameters
index
intthe index of the value
Returns
- bool
true if the value at position {@code index} is an ECI
Exceptions
- IndexOutOfRangeException
if the {@code index} argument is negative or not less than {@code length()}
isFNC1(int)
Determines if a value is the FNC1 character
public bool isFNC1(int index)
Parameters
index
intthe index of the value
Returns
- bool
true if the value at position {@code index} is the FNC1 character
Exceptions
- IndexOutOfRangeException
if the {@code index} argument is negative or not less than {@code length()}
subSequence(int, int)
Returns a {@code CharSequence} that is a subsequence of this sequence. The subsequence starts with the {@code char} value at the specified index and ends with the {@code char} value at index {@code end - 1}. The length (in {@code char}s) of the returned sequence is {@code end - start}, so if {@code start == end} then an empty sequence is returned.
public string subSequence(int start, int end)
Parameters
Returns
- string
the specified subsequence
Exceptions
- IndexOutOfRangeException
if {@code start} or {@code end} are negative, if {@code end} is greater than {@code length()}, or if {@code start} is greater than {@code end}
- ArgumentException
if a value in the range {@code start}-{@code end} is an ECI (@see #isECI)