llm mig 8to17 core

This commit is contained in:
Anjali Sridhar 2024-10-14 16:37:16 -07:00
parent 9598db91c7
commit b4e0e54b6b
10 changed files with 39 additions and 52 deletions

View file

@ -42,8 +42,7 @@ public final class Dimension {
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof Dimension) { if (other instanceof Dimension d) {
Dimension d = (Dimension) other;
return width == d.width && height == d.height; return width == d.width && height == d.height;
} }
return false; return false;
@ -59,4 +58,4 @@ public final class Dimension {
return width + "x" + height; return width + "x" + height;
} }
} }

View file

@ -159,10 +159,8 @@ public final class MultiFormatReader implements Reader {
@Override @Override
public void reset() { public void reset() {
if (readers != null) { for (Reader reader : readers) {
for (Reader reader : readers) { reader.reset();
reader.reset();
}
} }
} }
@ -196,4 +194,4 @@ public final class MultiFormatReader implements Reader {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
} }

View file

@ -89,9 +89,7 @@ public final class AztecReader implements Reader {
} }
} }
if (hints != null) { if (hints != null && hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK) instanceof ResultPointCallback rpcb) {
ResultPointCallback rpcb = (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
if (rpcb != null) {
for (ResultPoint point : points) { for (ResultPoint point : points) {
rpcb.foundPossibleResultPoint(point); rpcb.foundPossibleResultPoint(point);
} }
@ -125,4 +123,4 @@ public final class AztecReader implements Reader {
// do nothing // do nothing
} }
} }

View file

@ -134,8 +134,7 @@ public final class Encoder {
compact = userSpecifiedLayers < 0; compact = userSpecifiedLayers < 0;
layers = Math.abs(userSpecifiedLayers); layers = Math.abs(userSpecifiedLayers);
if (layers > (compact ? MAX_NB_BITS_COMPACT : MAX_NB_BITS)) { if (layers > (compact ? MAX_NB_BITS_COMPACT : MAX_NB_BITS)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(String.format("Illegal value %s for layers", userSpecifiedLayers));
String.format("Illegal value %s for layers", userSpecifiedLayers));
} }
totalBitsInLayer = totalBitsInLayer(layers, compact); totalBitsInLayer = totalBitsInLayer(layers, compact);
wordSize = WORD_SIZE[layers]; wordSize = WORD_SIZE[layers];
@ -401,4 +400,4 @@ public final class Encoder {
private static int totalBitsInLayer(int layers, boolean compact) { private static int totalBitsInLayer(int layers, boolean compact) {
return ((compact ? 88 : 112) + 16 * layers) * layers; return ((compact ? 88 : 112) + 16 * layers) * layers;
} }
} }

View file

@ -42,7 +42,7 @@ public final class AddressBookDoCoMoResultParser extends AbstractDoCoMoResultPar
return null; return null;
} }
String[] rawName = matchDoCoMoPrefixedField("N:", rawText); String[] rawName = matchDoCoMoPrefixedField("N:", rawText);
if (rawName == null) { if (rawName == null || rawName.length == 0) {
return null; return null;
} }
String name = parseName(rawName[0]); String name = parseName(rawName[0]);
@ -89,4 +89,4 @@ public final class AddressBookDoCoMoResultParser extends AbstractDoCoMoResultPar
return name; return name;
} }
} }

View file

@ -93,25 +93,22 @@ public final class ExpandedProductParsedResult extends ParsedResult {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (!(o instanceof ExpandedProductParsedResult)) { if (o instanceof ExpandedProductParsedResult other) {
return false; return Objects.equals(productID, other.productID)
&& Objects.equals(sscc, other.sscc)
&& Objects.equals(lotNumber, other.lotNumber)
&& Objects.equals(productionDate, other.productionDate)
&& Objects.equals(bestBeforeDate, other.bestBeforeDate)
&& Objects.equals(expirationDate, other.expirationDate)
&& Objects.equals(weight, other.weight)
&& Objects.equals(weightType, other.weightType)
&& Objects.equals(weightIncrement, other.weightIncrement)
&& Objects.equals(price, other.price)
&& Objects.equals(priceIncrement, other.priceIncrement)
&& Objects.equals(priceCurrency, other.priceCurrency)
&& Objects.equals(uncommonAIs, other.uncommonAIs);
} }
return false;
ExpandedProductParsedResult other = (ExpandedProductParsedResult) o;
return Objects.equals(productID, other.productID)
&& Objects.equals(sscc, other.sscc)
&& Objects.equals(lotNumber, other.lotNumber)
&& Objects.equals(productionDate, other.productionDate)
&& Objects.equals(bestBeforeDate, other.bestBeforeDate)
&& Objects.equals(expirationDate, other.expirationDate)
&& Objects.equals(weight, other.weight)
&& Objects.equals(weightType, other.weightType)
&& Objects.equals(weightIncrement, other.weightIncrement)
&& Objects.equals(price, other.price)
&& Objects.equals(priceIncrement, other.priceIncrement)
&& Objects.equals(priceCurrency, other.priceCurrency)
&& Objects.equals(uncommonAIs, other.uncommonAIs);
} }
@Override @Override
@ -196,4 +193,4 @@ public final class ExpandedProductParsedResult extends ParsedResult {
public String getDisplayResult() { public String getDisplayResult() {
return String.valueOf(rawText); return String.valueOf(rawText);
} }
} }

View file

@ -174,7 +174,7 @@ public final class ExpandedProductResultParser extends ResultParser {
private static String findAIvalue(int i, String rawText) { private static String findAIvalue(int i, String rawText) {
char c = rawText.charAt(i); char c = rawText.charAt(i);
// First character must be a open parenthesis.If not, ERROR // First character must be a open parenthesis. If not, ERROR
if (c != '(') { if (c != '(') {
return null; return null;
} }
@ -214,4 +214,4 @@ public final class ExpandedProductResultParser extends ResultParser {
} }
return buf.toString(); return buf.toString();
} }
} }

View file

@ -39,7 +39,6 @@ import java.util.regex.Pattern;
*/ */
public abstract class ResultParser { public abstract class ResultParser {
private static final ResultParser[] PARSERS = {
new BookmarkDoCoMoResultParser(), new BookmarkDoCoMoResultParser(),
new AddressBookDoCoMoResultParser(), new AddressBookDoCoMoResultParser(),
new EmailDoCoMoResultParser(), new EmailDoCoMoResultParser(),
@ -61,9 +60,7 @@ public abstract class ResultParser {
new ExpandedProductResultParser(), new ExpandedProductResultParser(),
new VINResultParser(), new VINResultParser(),
}; };
private static final Pattern EQUALS = Pattern.compile("=");
private static final Pattern DIGITS = Pattern.compile("\\d+");
private static final Pattern AMPERSAND = Pattern.compile("&");
private static final Pattern EQUALS = Pattern.compile("="); private static final Pattern EQUALS = Pattern.compile("=");
private static final String BYTE_ORDER_MARK = "\ufeff"; private static final String BYTE_ORDER_MARK = "\ufeff";
@ -114,7 +111,7 @@ public abstract class ResultParser {
} }
protected static String[] maybeWrap(String value) { protected static String[] maybeWrap(String value) {
return value == null ? null : new String[] { value }; return value == null ? null : new String[] {value};
} }
protected static String unescapeBackslash(String escaped) { protected static String unescapeBackslash(String escaped) {
@ -152,7 +149,7 @@ public abstract class ResultParser {
} }
protected static boolean isStringOfDigits(CharSequence value, int length) { protected static boolean isStringOfDigits(CharSequence value, int length) {
return value != null && length > 0 && length == value.length() && DIGITS.matcher(value).matches(); return value != null && length > 0 && length == value.length() && Pattern.matches("\\\\d+", value);
} }
protected static boolean isSubstringOfDigits(CharSequence value, int offset, int length) { protected static boolean isSubstringOfDigits(CharSequence value, int offset, int length) {
@ -160,7 +157,7 @@ public abstract class ResultParser {
return false; return false;
} }
int max = offset + length; int max = offset + length;
return value.length() >= max && DIGITS.matcher(value.subSequence(offset, max)).matches(); return value.length() >= max && Pattern.matches("\\\\d+", value.subSequence(offset, max));
} }
static Map<String,String> parseNameValuePairs(String uri) { static Map<String,String> parseNameValuePairs(String uri) {
@ -169,7 +166,7 @@ public abstract class ResultParser {
return null; return null;
} }
Map<String,String> result = new HashMap<>(3); Map<String,String> result = new HashMap<>(3);
for (String keyValue : AMPERSAND.split(uri.substring(paramStart + 1))) { for (String keyValue : uri.substring(paramStart + 1).split("&")) {
appendKeyValue(keyValue, result); appendKeyValue(keyValue, result);
} }
return result; return result;
@ -254,8 +251,7 @@ public abstract class ResultParser {
} }
static String matchSinglePrefixedField(String prefix, String rawText, char endChar, boolean trim) { static String matchSinglePrefixedField(String prefix, String rawText, char endChar, boolean trim) {
String[] matches = matchPrefixedField(prefix, rawText, endChar, trim); String[] matches = matchPrefixedField(prefix, rawText, endChar, trim);\n return matches == null ? null : matches[0];
return matches == null ? null : matches[0];
} }
} }

View file

@ -80,7 +80,7 @@ public final class SMSParsedResult extends ParsedResult {
result.append('&'); result.append('&');
} }
result.append("subject="); result.append("subject=");
result.append(subject); result.append(subject);\n }\n }
} }
} }
return result.toString(); return result.toString();

View file

@ -21,13 +21,13 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class TelParsedResult extends ParsedResult { public final class TelResult extends ParsedResult {
private final String number; private final String number;
private final String telURI; private final String telURI;
private final String title; private final String title;
public TelParsedResult(String number, String telURI, String title) { public TelResult(String number, String telURI, String title) {
super(ParsedResultType.TEL); super(ParsedResultType.TEL);
this.number = number; this.number = number;
this.telURI = telURI; this.telURI = telURI;