diff --git a/java/src/main/java/io/nayuki/qrcodegen/DataTooLongException.java b/java/src/main/java/io/nayuki/qrcodegen/DataTooLongException.java index 0cbefc7..f1453ef 100644 --- a/java/src/main/java/io/nayuki/qrcodegen/DataTooLongException.java +++ b/java/src/main/java/io/nayuki/qrcodegen/DataTooLongException.java @@ -33,17 +33,17 @@ package io.nayuki.qrcodegen; * if it was less than {@link QrCode#MAX_VERSION}. (This advice does not apply to the other * factory functions because they search all versions up to {@code QrCode.MAX_VERSION}.)
*Split the text data into better or optimal segments in order to reduce the number of - * bits required. (See {@link QrSegmentAdvanced#makeSegmentsOptimally(String,QrCode.Ecc,int,int) + * bits required. (See {@link QrSegmentAdvanced#makeSegmentsOptimally(CharSequence,QrCode.Ecc,int,int) * QrSegmentAdvanced.makeSegmentsOptimally()}.)
Change the text or binary data to be shorter.
Change the text to fit the character set of a particular segment mode (e.g. alphanumeric).
Propagate the error upward to the caller/user.
Ways to create a QR Code object:
*High level: Take the payload data and call {@link QrCode#encodeText(String,Ecc)} + *
High level: Take the payload data and call {@link QrCode#encodeText(CharSequence,Ecc)} * or {@link QrCode#encodeBinary(byte[],Ecc)}.
Mid level: Custom-make the list of {@link QrSegment segments}
* and call {@link QrCode#encodeSegments(List,Ecc)} or
@@ -66,7 +66,7 @@ public final class QrCode {
* @throws DataTooLongException if the text fails to fit in the
* largest version QR Code at the ECL, which means it is too long
*/
- public static QrCode encodeText(String text, Ecc ecl) {
+ public static QrCode encodeText(CharSequence text, Ecc ecl) {
Objects.requireNonNull(text);
Objects.requireNonNull(ecl);
List This function allows the user to create a custom sequence of segments that switches
* between modes (such as alphanumeric and byte) to encode text in less space.
- * This is a mid-level API; the high-level API is {@link #encodeText(String,Ecc)}
+ * This is a mid-level API; the high-level API is {@link #encodeText(CharSequence,Ecc)}
* and {@link #encodeBinary(byte[],Ecc)}. This function allows the user to create a custom sequence of segments that switches
* between modes (such as alphanumeric and byte) to encode text in less space.
- * This is a mid-level API; the high-level API is {@link #encodeText(String,Ecc)}
+ * This is a mid-level API; the high-level API is {@link #encodeText(CharSequence,Ecc)}
* and {@link #encodeBinary(byte[],Ecc)}. The mid-level way to create a segment is to take the payload data and call a
- * static factory function such as {@link QrSegment#makeNumeric(String)}. The low-level
+ * static factory function such as {@link QrSegment#makeNumeric(CharSequence)}. The low-level
* way to create a segment is to custom-make the bit buffer and call the {@link
* QrSegment#QrSegment(Mode,int,BitBuffer) constructor} with appropriate values. This segment class imposes no length restrictions, but QR Codes have restrictions.
@@ -72,7 +72,7 @@ public final class QrSegment {
* @throws NullPointerException if the string is {@code null}
* @throws IllegalArgumentException if the string contains non-digit characters
*/
- public static QrSegment makeNumeric(String digits) {
+ public static QrSegment makeNumeric(CharSequence digits) {
Objects.requireNonNull(digits);
if (!isNumeric(digits))
throw new IllegalArgumentException("String contains non-numeric characters");
@@ -80,7 +80,7 @@ public final class QrSegment {
BitBuffer bb = new BitBuffer();
for (int i = 0; i < digits.length(); ) { // Consume up to 3 digits per iteration
int n = Math.min(digits.length() - i, 3);
- bb.appendBits(Integer.parseInt(digits.substring(i, i + n)), n * 3 + 1);
+ bb.appendBits(Integer.parseInt(digits.subSequence(i, i + n).toString()), n * 3 + 1);
i += n;
}
return new QrSegment(Mode.NUMERIC, digits.length(), bb);
@@ -96,7 +96,7 @@ public final class QrSegment {
* @throws NullPointerException if the string is {@code null}
* @throws IllegalArgumentException if the string contains non-encodable characters
*/
- public static QrSegment makeAlphanumeric(String text) {
+ public static QrSegment makeAlphanumeric(CharSequence text) {
Objects.requireNonNull(text);
if (!isAlphanumeric(text))
throw new IllegalArgumentException("String contains unencodable characters in alphanumeric mode");
@@ -121,7 +121,7 @@ public final class QrSegment {
* @return a new mutable list (not {@code null}) of segments (not {@code null}) containing the text
* @throws NullPointerException if the text is {@code null}
*/
- public static List This function can utilize all four text encoding modes: numeric, alphanumeric, byte (UTF-8),
* and kanji. This can be considered as a sophisticated but slower replacement for {@link
- * QrSegment#makeSegments(String)}. This requires more input parameters because it searches a
+ * QrSegment#makeSegments(CharSequence)}. This requires more input parameters because it searches a
* range of versions, like {@link QrCode#encodeSegments(List,QrCode.Ecc,int,int,int,boolean)}.