public final class QrSegment extends Object
This segment class imposes no length restrictions, but QR Codes have restrictions. Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. Any segment longer than this is meaningless for the purpose of generating QR Codes.
| Modifier and Type | Class and Description |
|---|---|
static class |
QrSegment.Mode
The mode field of a segment.
|
| Modifier and Type | Field and Description |
|---|---|
static Pattern |
ALPHANUMERIC_REGEX
Can test whether a string is encodable in alphanumeric mode (such as by using
makeAlphanumeric(String)). |
QrSegment.Mode |
mode
The mode indicator for this segment.
|
int |
numChars
The length of this segment's unencoded data, measured in characters.
|
static Pattern |
NUMERIC_REGEX
Can test whether a string is encodable in numeric mode (such as by using
makeNumeric(String)). |
| Constructor and Description |
|---|
QrSegment(QrSegment.Mode md,
int numCh,
BitBuffer data)
Creates a new QR Code data segment with the specified parameters and data.
|
| Modifier and Type | Method and Description |
|---|---|
BitBuffer |
getBits()
Returns the data bits of this segment.
|
static QrSegment |
makeAlphanumeric(String text)
Returns a segment representing the specified text string encoded in alphanumeric mode.
|
static QrSegment |
makeBytes(byte[] data)
Returns a segment representing the specified binary data encoded in byte mode.
|
static QrSegment |
makeEci(int assignVal)
Returns a segment representing an Extended Channel Interpretation
(ECI) designator with the specified assignment value.
|
static QrSegment |
makeNumeric(String digits)
Returns a segment representing the specified string of decimal digits encoded in numeric mode.
|
static List<QrSegment> |
makeSegments(String text)
Returns a new mutable list of zero or more segments to represent the specified Unicode text string.
|
public final QrSegment.Mode mode
null.public final int numChars
public static final Pattern NUMERIC_REGEX
makeNumeric(String)).public static final Pattern ALPHANUMERIC_REGEX
makeAlphanumeric(String)).public QrSegment(QrSegment.Mode md, int numCh, BitBuffer data)
md - the mode, which is not nullnumCh - the data length in characters, which is non-negativedata - the data bits of this segment, which is not nullNullPointerException - if the mode or bit buffer is nullIllegalArgumentException - if the character count is negativepublic static QrSegment makeBytes(byte[] data)
data - the binary dataNullPointerException - if the array is nullpublic static QrSegment makeNumeric(String digits)
digits - a string consisting of digits from 0 to 9NullPointerException - if the string is nullIllegalArgumentException - if the string contains non-digit characterspublic static QrSegment makeAlphanumeric(String text)
text - a string of text, with only certain characters allowedNullPointerException - if the string is nullIllegalArgumentException - if the string contains non-encodable characterspublic static List<QrSegment> makeSegments(String text)
text - the text to be encoded, which can be any Unicode stringNullPointerException - if the text is nullpublic static QrSegment makeEci(int assignVal)
assignVal - the ECI assignment number (see the AIM ECI specification)IllegalArgumentException - if the value is outside the range [0, 106)public BitBuffer getBits()
null)Copyright © 2018. All rights reserved.