mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
We can finally use isEmpty(), given Android 2.3.3+ is required
git-svn-id: https://zxing.googlecode.com/svn/trunk@2819 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
03354c4757
commit
f6df6000d5
|
@ -116,7 +116,7 @@ final class DecodeHintManager {
|
|||
|
||||
static Map<DecodeHintType,?> parseDecodeHints(Uri inputUri) {
|
||||
String query = inputUri.getEncodedQuery();
|
||||
if (query == null || query.length() == 0) {
|
||||
if (query == null || query.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ final class DecodeHintManager {
|
|||
if (hintType.getValueType().equals(Boolean.class)) {
|
||||
// A boolean hint: a few values for false, everything else is true.
|
||||
// An empty parameter is simply a flag-style parameter, assuming true
|
||||
if (parameterText.length() == 0) {
|
||||
if (parameterText.isEmpty()) {
|
||||
hints.put(hintType, Boolean.TRUE);
|
||||
} else if ("0".equals(parameterText) ||
|
||||
"false".equalsIgnoreCase(parameterText) ||
|
||||
|
|
|
@ -76,7 +76,7 @@ public final class HelpActivity extends Activity {
|
|||
webView.restoreState(icicle);
|
||||
} else if (intent != null) {
|
||||
String page = intent.getStringExtra(REQUESTED_PAGE_KEY);
|
||||
if (page != null && page.length() > 0) {
|
||||
if (page != null && !page.isEmpty()) {
|
||||
webView.loadUrl(BASE_URL + page);
|
||||
} else {
|
||||
webView.loadUrl(BASE_URL + DEFAULT_PAGE);
|
||||
|
@ -94,7 +94,7 @@ public final class HelpActivity extends Activity {
|
|||
@Override
|
||||
protected void onSaveInstanceState(Bundle state) {
|
||||
String url = webView.getUrl();
|
||||
if (url != null && url.length() > 0) {
|
||||
if (url != null && !url.isEmpty()) {
|
||||
webView.saveState(state);
|
||||
state.putBoolean(WEBVIEW_STATE_PRESENT, true);
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ public final class LocaleManager {
|
|||
public static String getCountry(Context context) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
String countryOverride = prefs.getString(PreferencesActivity.KEY_SEARCH_COUNTRY, null);
|
||||
if (countryOverride != null && countryOverride.length() > 0 && !"-".equals(countryOverride)) {
|
||||
if (countryOverride != null && !countryOverride.isEmpty() && !"-".equals(countryOverride)) {
|
||||
return countryOverride;
|
||||
}
|
||||
return getSystemCountry();
|
||||
|
|
|
@ -46,7 +46,7 @@ final class BrowseBookListener implements AdapterView.OnItemClickListener {
|
|||
}
|
||||
String pageId = items.get(itemOffset).getPageId();
|
||||
String query = SearchBookContentsResult.getQuery();
|
||||
if (LocaleManager.isBookSearchUrl(activity.getISBN()) && pageId.length() > 0) {
|
||||
if (LocaleManager.isBookSearchUrl(activity.getISBN()) && !pageId.isEmpty()) {
|
||||
String uri = activity.getISBN();
|
||||
int equals = uri.indexOf('=');
|
||||
String volumeId = uri.substring(equals + 1);
|
||||
|
|
|
@ -121,7 +121,7 @@ public final class SearchBookContentsActivity extends Activity {
|
|||
queryTextView = (EditText) findViewById(R.id.query_text_view);
|
||||
|
||||
String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
|
||||
if (initialQuery != null && initialQuery.length() > 0) {
|
||||
if (initialQuery != null && !initialQuery.isEmpty()) {
|
||||
// Populate the search box but don't trigger the search
|
||||
queryTextView.setText(initialQuery);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ public final class SearchBookContentsActivity extends Activity {
|
|||
|
||||
private void launchSearch() {
|
||||
String query = queryTextView.getText().toString();
|
||||
if (query != null && query.length() > 0) {
|
||||
if (query != null && !query.isEmpty()) {
|
||||
NetworkTask oldTask = networkTask;
|
||||
if (oldTask != null) {
|
||||
oldTask.cancel(true);
|
||||
|
@ -244,25 +244,25 @@ public final class SearchBookContentsActivity extends Activity {
|
|||
try {
|
||||
String pageId = json.getString("page_id");
|
||||
String pageNumber = json.getString("page_number");
|
||||
if (pageNumber.length() > 0) {
|
||||
pageNumber = getString(R.string.msg_sbc_page) + ' ' + pageNumber;
|
||||
} else {
|
||||
if (pageNumber.isEmpty()) {
|
||||
// This can happen for text on the jacket, and possibly other reasons.
|
||||
pageNumber = getString(R.string.msg_sbc_unknown_page);
|
||||
} else {
|
||||
pageNumber = getString(R.string.msg_sbc_page) + ' ' + pageNumber;
|
||||
}
|
||||
|
||||
// Remove all HTML tags and encoded characters. Ideally the server would do this.
|
||||
String snippet = json.optString("snippet_text");
|
||||
boolean valid = true;
|
||||
if (snippet.length() > 0) {
|
||||
if (snippet.isEmpty()) {
|
||||
snippet = '(' + getString(R.string.msg_sbc_snippet_unavailable) + ')';
|
||||
valid = false;
|
||||
} else {
|
||||
snippet = TAG_PATTERN.matcher(snippet).replaceAll("");
|
||||
snippet = LT_ENTITY_PATTERN.matcher(snippet).replaceAll("<");
|
||||
snippet = GT_ENTITY_PATTERN.matcher(snippet).replaceAll(">");
|
||||
snippet = QUOTE_ENTITY_PATTERN.matcher(snippet).replaceAll("'");
|
||||
snippet = QUOT_ENTITY_PATTERN.matcher(snippet).replaceAll("\"");
|
||||
} else {
|
||||
snippet = '(' + getString(R.string.msg_sbc_snippet_unavailable) + ')';
|
||||
valid = false;
|
||||
}
|
||||
return new SearchBookContentsResult(pageId, pageNumber, snippet, valid);
|
||||
} catch (JSONException e) {
|
||||
|
|
|
@ -56,7 +56,9 @@ public final class SearchBookContentsListItem extends LinearLayout {
|
|||
public void set(SearchBookContentsResult result) {
|
||||
pageNumberView.setText(result.getPageNumber());
|
||||
String snippet = result.getSnippet();
|
||||
if (snippet.length() > 0) {
|
||||
if (snippet.isEmpty()) {
|
||||
snippetView.setText("");
|
||||
} else {
|
||||
if (result.getValidSnippet()) {
|
||||
String lowerQuery = SearchBookContentsResult.getQuery().toLowerCase(Locale.getDefault());
|
||||
String lowerSnippet = snippet.toLowerCase(Locale.getDefault());
|
||||
|
@ -77,8 +79,6 @@ public final class SearchBookContentsListItem extends LinearLayout {
|
|||
// This may be an error message, so don't try to bold the query terms within it
|
||||
snippetView.setText(snippet);
|
||||
}
|
||||
} else {
|
||||
snippetView.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ abstract class ContactEncoder {
|
|||
return null;
|
||||
}
|
||||
String result = s.trim();
|
||||
return result.length() == 0 ? null : result;
|
||||
return result.isEmpty() ? null : result;
|
||||
}
|
||||
|
||||
static void doAppend(StringBuilder newContents,
|
||||
|
@ -78,7 +78,7 @@ abstract class ContactEncoder {
|
|||
Collection<String> uniques = new HashSet<String>(2);
|
||||
for (String value : values) {
|
||||
String trimmed = trim(value);
|
||||
if (trimmed != null && trimmed.length() > 0 && !uniques.contains(trimmed)) {
|
||||
if (trimmed != null && !trimmed.isEmpty() && !uniques.contains(trimmed)) {
|
||||
newContents.append(prefix).append(':').append(fieldFormatter.format(trimmed)).append(terminator);
|
||||
String display = formatter == null ? trimmed : formatter.format(trimmed);
|
||||
newDisplayContents.append(display).append('\n');
|
||||
|
|
|
@ -112,20 +112,20 @@ final class QRCodeEncoder {
|
|||
}
|
||||
if (format == null || format == BarcodeFormat.QR_CODE) {
|
||||
String type = intent.getStringExtra(Intents.Encode.TYPE);
|
||||
if (type == null || type.length() == 0) {
|
||||
if (type == null || type.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
this.format = BarcodeFormat.QR_CODE;
|
||||
encodeQRCodeContents(intent, type);
|
||||
} else {
|
||||
String data = intent.getStringExtra(Intents.Encode.DATA);
|
||||
if (data != null && data.length() > 0) {
|
||||
if (data != null && !data.isEmpty()) {
|
||||
contents = data;
|
||||
displayContents = data;
|
||||
title = activity.getString(R.string.contents_text);
|
||||
}
|
||||
}
|
||||
return contents != null && contents.length() > 0;
|
||||
return contents != null && !contents.isEmpty();
|
||||
}
|
||||
|
||||
// Handles send intents from multitude of Android applications
|
||||
|
@ -158,7 +158,7 @@ final class QRCodeEncoder {
|
|||
}
|
||||
|
||||
// Trim text to avoid URL breaking.
|
||||
if (theContents == null || theContents.length() == 0) {
|
||||
if (theContents == null || theContents.isEmpty()) {
|
||||
throw new WriterException("Empty EXTRA_TEXT");
|
||||
}
|
||||
contents = theContents;
|
||||
|
@ -208,7 +208,7 @@ final class QRCodeEncoder {
|
|||
throw new WriterException("Result was not an address");
|
||||
}
|
||||
encodeQRCodeContents((AddressBookParsedResult) parsedResult);
|
||||
if (contents == null || contents.length() == 0) {
|
||||
if (contents == null || contents.isEmpty()) {
|
||||
throw new WriterException("No content to encode");
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ final class QRCodeEncoder {
|
|||
private void encodeQRCodeContents(Intent intent, String type) {
|
||||
if (type.equals(Contents.Type.TEXT)) {
|
||||
String data = intent.getStringExtra(Intents.Encode.DATA);
|
||||
if (data != null && data.length() > 0) {
|
||||
if (data != null && !data.isEmpty()) {
|
||||
contents = data;
|
||||
displayContents = data;
|
||||
title = activity.getString(R.string.contents_text);
|
||||
|
@ -271,7 +271,7 @@ final class QRCodeEncoder {
|
|||
urls,
|
||||
note);
|
||||
// Make sure we've encoded at least one field.
|
||||
if (encoded[1].length() > 0) {
|
||||
if (!encoded[1].isEmpty()) {
|
||||
contents = encoded[0];
|
||||
displayContents = encoded[1];
|
||||
title = activity.getString(R.string.contents_contact);
|
||||
|
@ -304,7 +304,7 @@ final class QRCodeEncoder {
|
|||
toIterable(contact.getURLs()),
|
||||
null);
|
||||
// Make sure we've encoded at least one field.
|
||||
if (encoded[1].length() > 0) {
|
||||
if (!encoded[1].isEmpty()) {
|
||||
contents = encoded[0];
|
||||
displayContents = encoded[1];
|
||||
title = activity.getString(R.string.contents_contact);
|
||||
|
|
|
@ -36,12 +36,12 @@ public final class HistoryItem {
|
|||
|
||||
public String getDisplayAndDetails() {
|
||||
StringBuilder displayResult = new StringBuilder();
|
||||
if (display == null || display.length() == 0) {
|
||||
if (display == null || display.isEmpty()) {
|
||||
displayResult.append(result.getText());
|
||||
} else {
|
||||
displayResult.append(display);
|
||||
}
|
||||
if (details != null && details.length() > 0) {
|
||||
if (details != null && !details.isEmpty()) {
|
||||
displayResult.append(" : ").append(details);
|
||||
}
|
||||
return displayResult.toString();
|
||||
|
|
|
@ -82,7 +82,7 @@ public final class AddressBookResultHandler extends ResultHandler {
|
|||
super(activity, result);
|
||||
AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
|
||||
String[] addresses = addressResult.getAddresses();
|
||||
boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && addresses[0].length() > 0;
|
||||
boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
|
||||
String[] phoneNumbers = addressResult.getPhoneNumbers();
|
||||
boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
|
||||
String[] emails = addressResult.getEmails();
|
||||
|
@ -175,7 +175,7 @@ public final class AddressBookResultHandler extends ResultHandler {
|
|||
int namesLength = contents.length();
|
||||
|
||||
String pronunciation = result.getPronunciation();
|
||||
if (pronunciation != null && pronunciation.length() > 0) {
|
||||
if (pronunciation != null && !pronunciation.isEmpty()) {
|
||||
contents.append("\n(");
|
||||
contents.append(pronunciation);
|
||||
contents.append(')');
|
||||
|
@ -196,7 +196,7 @@ public final class AddressBookResultHandler extends ResultHandler {
|
|||
ParsedResult.maybeAppend(result.getURLs(), contents);
|
||||
|
||||
String birthday = result.getBirthday();
|
||||
if (birthday != null && birthday.length() > 0) {
|
||||
if (birthday != null && !birthday.isEmpty()) {
|
||||
Date date = parseDate(birthday);
|
||||
if (date != null) {
|
||||
ParsedResult.maybeAppend(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date.getTime()), contents);
|
||||
|
|
|
@ -262,7 +262,7 @@ public abstract class ResultHandler {
|
|||
StringBuilder aggregatedNotes = new StringBuilder();
|
||||
if (urls != null) {
|
||||
for (String url : urls) {
|
||||
if (url != null && url.length() > 0) {
|
||||
if (url != null && !url.isEmpty()) {
|
||||
aggregatedNotes.append('\n').append(url);
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ public abstract class ResultHandler {
|
|||
}
|
||||
if (nicknames != null) {
|
||||
for (String nickname : nicknames) {
|
||||
if (nickname != null && nickname.length() > 0) {
|
||||
if (nickname != null && !nickname.isEmpty()) {
|
||||
aggregatedNotes.append('\n').append(nickname);
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ public abstract class ResultHandler {
|
|||
final void sendMMSFromUri(String uri, String subject, String body) {
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
|
||||
// The Messaging app needs to see a valid subject or else it will treat this an an SMS.
|
||||
if (subject == null || subject.length() == 0) {
|
||||
if (subject == null || subject.isEmpty()) {
|
||||
putExtra(intent, "subject", activity.getString(R.string.msg_default_mms_subject));
|
||||
} else {
|
||||
putExtra(intent, "subject", subject);
|
||||
|
@ -399,9 +399,9 @@ public abstract class ResultHandler {
|
|||
* @param address The address to find
|
||||
* @param title An optional title, e.g. the name of the business at this address
|
||||
*/
|
||||
final void searchMap(String address, CharSequence title) {
|
||||
final void searchMap(String address, String title) {
|
||||
String query = address;
|
||||
if (title != null && title.length() > 0) {
|
||||
if (title != null && !title.isEmpty()) {
|
||||
query += " (" + title + ')';
|
||||
}
|
||||
launchIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + Uri.encode(query))));
|
||||
|
@ -510,7 +510,7 @@ public abstract class ResultHandler {
|
|||
}
|
||||
|
||||
private static void putExtra(Intent intent, String key, String value) {
|
||||
if (value != null && value.length() > 0) {
|
||||
if (value != null && !value.isEmpty()) {
|
||||
intent.putExtra(key, value);
|
||||
}
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ public abstract class ResultHandler {
|
|||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
String customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH,
|
||||
null);
|
||||
if (customProductSearch != null && customProductSearch.trim().length() == 0) {
|
||||
if (customProductSearch != null && customProductSearch.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return customProductSearch;
|
||||
|
|
|
@ -94,7 +94,7 @@ final class BookResultInfoRetriever extends SupplementalInfoRetriever {
|
|||
Collection<String> newTexts = new ArrayList<String>();
|
||||
maybeAddText(title, newTexts);
|
||||
maybeAddTextSeries(authors, newTexts);
|
||||
maybeAddText(pages == null || pages.length() == 0 ? null : pages + "pp.", newTexts);
|
||||
maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts);
|
||||
|
||||
String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context)
|
||||
+ "/search?tbm=bks&source=zxing&q=";
|
||||
|
|
|
@ -156,7 +156,7 @@ public abstract class SupplementalInfoRetriever extends AsyncTask<Object,Object,
|
|||
}
|
||||
|
||||
static void maybeAddText(String text, Collection<String> texts) {
|
||||
if (text != null && text.length() > 0) {
|
||||
if (text != null && !text.isEmpty()) {
|
||||
texts.add(text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ final class TitleRetriever extends SupplementalInfoRetriever {
|
|||
Matcher m = TITLE_PATTERN.matcher(contents);
|
||||
if (m.find()) {
|
||||
String title = m.group(1);
|
||||
if (title != null && title.length() > 0) {
|
||||
if (title != null && !title.isEmpty()) {
|
||||
if (title.length() > MAX_TITLE_LEN) {
|
||||
title = title.substring(0, MAX_TITLE_LEN) + "...";
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ public final class ShareActivity extends Activity {
|
|||
|
||||
// Don't require a name to be present, this contact might be just a phone number.
|
||||
Bundle bundle = new Bundle();
|
||||
if (name != null && name.length() > 0) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
bundle.putString(ContactsContract.Intents.Insert.NAME, massageContactData(name));
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ public final class ShareActivity extends Activity {
|
|||
int phonesNumberColumn = phonesCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
|
||||
while (phonesCursor.moveToNext() && foundPhone < Contents.PHONE_KEYS.length) {
|
||||
String number = phonesCursor.getString(phonesNumberColumn);
|
||||
if (number != null && number.length() > 0) {
|
||||
if (number != null && !number.isEmpty()) {
|
||||
bundle.putString(Contents.PHONE_KEYS[foundPhone], massageContactData(number));
|
||||
}
|
||||
foundPhone++;
|
||||
|
@ -245,7 +245,7 @@ public final class ShareActivity extends Activity {
|
|||
if (methodsCursor.moveToNext()) {
|
||||
String data = methodsCursor.getString(
|
||||
methodsCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS));
|
||||
if (data != null && data.length() > 0) {
|
||||
if (data != null && !data.isEmpty()) {
|
||||
bundle.putString(ContactsContract.Intents.Insert.POSTAL, massageContactData(data));
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ public final class ShareActivity extends Activity {
|
|||
int emailColumn = emailCursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA);
|
||||
while (emailCursor.moveToNext() && foundEmail < Contents.EMAIL_KEYS.length) {
|
||||
String email = emailCursor.getString(emailColumn);
|
||||
if (email != null && email.length() > 0) {
|
||||
if (email != null && !email.isEmpty()) {
|
||||
bundle.putString(Contents.EMAIL_KEYS[foundEmail], massageContactData(email));
|
||||
}
|
||||
foundEmail++;
|
||||
|
|
|
@ -82,7 +82,7 @@ public final class WifiConfigManager extends AsyncTask<WifiParsedResult,Object,O
|
|||
changeNetworkUnEncrypted(wifiManager, theWifiResult);
|
||||
} else {
|
||||
String password = theWifiResult.getPassword();
|
||||
if (password != null && password.length() != 0) {
|
||||
if (password != null && !password.isEmpty()) {
|
||||
if (networkType == NetworkType.WEP) {
|
||||
changeNetworkWEP(wifiManager, theWifiResult);
|
||||
} else if (networkType == NetworkType.WPA) {
|
||||
|
@ -186,19 +186,19 @@ public final class WifiConfigManager extends AsyncTask<WifiParsedResult,Object,O
|
|||
|
||||
/**
|
||||
* Encloses the incoming string inside double quotes, if it isn't already quoted.
|
||||
* @param string the input string
|
||||
* @param s the input string
|
||||
* @return a quoted string, of the form "input". If the input string is null, it returns null
|
||||
* as well.
|
||||
*/
|
||||
private static String convertToQuotedString(String string) {
|
||||
if (string == null || string.length() == 0) {
|
||||
private static String convertToQuotedString(String s) {
|
||||
if (s == null || s.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
// If already quoted, return as-is
|
||||
if (string.charAt(0) == '"' && string.charAt(string.length() - 1) == '"') {
|
||||
return string;
|
||||
if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') {
|
||||
return s;
|
||||
}
|
||||
return '\"' + string + '\"';
|
||||
return '\"' + s + '\"';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ public final class EmailAddressResultParser extends ResultParser {
|
|||
String subject = null;
|
||||
String body = null;
|
||||
if (nameValues != null) {
|
||||
if (emailAddress.length() == 0) {
|
||||
if (emailAddress.isEmpty()) {
|
||||
emailAddress = nameValues.get("to");
|
||||
}
|
||||
subject = nameValues.get("subject");
|
||||
|
|
|
@ -47,7 +47,7 @@ public abstract class ParsedResult {
|
|||
}
|
||||
|
||||
public static void maybeAppend(String value, StringBuilder result) {
|
||||
if (value != null && value.length() > 0) {
|
||||
if (value != null && !value.isEmpty()) {
|
||||
// Don't add a newline before the first value
|
||||
if (result.length() > 0) {
|
||||
result.append('\n');
|
||||
|
|
|
@ -230,7 +230,7 @@ public abstract class ResultParser {
|
|||
if (trim) {
|
||||
element = element.trim();
|
||||
}
|
||||
if (element.length() > 0) {
|
||||
if (!element.isEmpty()) {
|
||||
matches.add(element);
|
||||
}
|
||||
i++;
|
||||
|
|
|
@ -278,7 +278,7 @@ public final class VCardResultParser extends ResultParser {
|
|||
List<String> result = new ArrayList<String>(lists.size());
|
||||
for (List<String> list : lists) {
|
||||
String value = list.get(0);
|
||||
if (value != null && value.length() > 0) {
|
||||
if (value != null && !value.isEmpty()) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public final class WifiResultParser extends ResultParser {
|
|||
return null;
|
||||
}
|
||||
String ssid = matchSinglePrefixedField("S:", rawText, ';', false);
|
||||
if (ssid == null || ssid.length() == 0) {
|
||||
if (ssid == null || ssid.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String pass = matchSinglePrefixedField("P:", rawText, ';', false);
|
||||
|
|
|
@ -46,7 +46,7 @@ public final class DataMatrixWriter implements Writer {
|
|||
@Override
|
||||
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {
|
||||
|
||||
if (contents.length() == 0) {
|
||||
if (contents.isEmpty()) {
|
||||
throw new IllegalArgumentException("Found empty contents");
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public abstract class OneDimensionalCodeWriter implements Writer {
|
|||
int width,
|
||||
int height,
|
||||
Map<EncodeHintType,?> hints) throws WriterException {
|
||||
if (contents.length() == 0) {
|
||||
if (contents.isEmpty()) {
|
||||
throw new IllegalArgumentException("Found empty contents");
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ final class FieldParser {
|
|||
}
|
||||
|
||||
static String parseFieldsInGeneralPurpose(String rawInformation) throws NotFoundException{
|
||||
if(rawInformation.length() == 0) {
|
||||
if (rawInformation.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public final class QRCodeWriter implements Writer {
|
|||
int height,
|
||||
Map<EncodeHintType,?> hints) throws WriterException {
|
||||
|
||||
if (contents.length() == 0) {
|
||||
if (contents.isEmpty()) {
|
||||
throw new IllegalArgumentException("Found empty contents");
|
||||
}
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ public final class CalendarEventGenerator implements GeneratorSource {
|
|||
|
||||
private String getEventNameField() throws GeneratorException {
|
||||
String inputName = eventName.getText();
|
||||
if (inputName.length() < 1) {
|
||||
if (inputName.isEmpty()) {
|
||||
throw new GeneratorException("Event name must be at least 1 character.");
|
||||
}
|
||||
if (inputName.contains("\n")) {
|
||||
|
@ -216,7 +216,7 @@ public final class CalendarEventGenerator implements GeneratorSource {
|
|||
|
||||
private String getLocationField() throws GeneratorException {
|
||||
String locationString = location.getText();
|
||||
if (locationString.length() < 1) {
|
||||
if (locationString.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
if (locationString.contains("\n")) {
|
||||
|
@ -228,7 +228,7 @@ public final class CalendarEventGenerator implements GeneratorSource {
|
|||
|
||||
private String getDescriptionField() throws GeneratorException {
|
||||
String descriptionString = description.getText();
|
||||
if (descriptionString.length() < 1) {
|
||||
if (descriptionString.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
if (descriptionString.contains("\n")) {
|
||||
|
|
|
@ -170,7 +170,7 @@ public final class ContactInfoGenerator implements GeneratorSource {
|
|||
|
||||
private String getNameField() throws GeneratorException {
|
||||
String input = name.getText();
|
||||
if (input.length() < 1) {
|
||||
if (input.isEmpty()) {
|
||||
throw new GeneratorException("Name must be at least 1 character.");
|
||||
}
|
||||
return input;
|
||||
|
@ -186,7 +186,7 @@ public final class ContactInfoGenerator implements GeneratorSource {
|
|||
|
||||
private String getTelField() throws GeneratorException {
|
||||
String input = Validators.filterNumber(tel.getText());
|
||||
if (input.length() < 1) {
|
||||
if (input.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
Validators.validateNumber(input);
|
||||
|
@ -206,7 +206,7 @@ public final class ContactInfoGenerator implements GeneratorSource {
|
|||
|
||||
private String getEmailField() throws GeneratorException {
|
||||
String input = email.getText();
|
||||
if (input.length() < 1) {
|
||||
if (input.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
Validators.validateEmail(input);
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class EmailGenerator implements GeneratorSource {
|
|||
|
||||
private String getEmailField() throws GeneratorException {
|
||||
String input = email.getText();
|
||||
if (input.length() < 1) {
|
||||
if (input.isEmpty()) {
|
||||
throw new GeneratorException("Email must be present.");
|
||||
}
|
||||
Validators.validateEmail(input);
|
||||
|
|
|
@ -57,7 +57,7 @@ public final class GeoLocationGenerator implements GeneratorSource {
|
|||
@Override
|
||||
public String getText() throws GeneratorException {
|
||||
String que = getQueryField();
|
||||
if (que != null && que.length() > 0) {
|
||||
if (que != null && !que.isEmpty()) {
|
||||
if (getLatitudeField() == null) {
|
||||
latitude.setText("0");
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public final class GeoLocationGenerator implements GeneratorSource {
|
|||
String lat = getLatitudeField();
|
||||
String lon = getLongitudeField();
|
||||
|
||||
if (que != null && que.length() > 0) {
|
||||
if (que != null && !que.isEmpty()) {
|
||||
return "geo:" + lat + ',' + lon + "?q=" + que;
|
||||
}
|
||||
return "geo:" + lat + ',' + lon;
|
||||
|
|
|
@ -51,7 +51,7 @@ public final class PhoneNumberGenerator implements GeneratorSource {
|
|||
|
||||
private String getTelField() throws GeneratorException {
|
||||
String input = number.getText();
|
||||
if (input.length() < 1) {
|
||||
if (input.isEmpty()) {
|
||||
throw new GeneratorException("Phone number must be present.");
|
||||
}
|
||||
input = Validators.filterNumber(input);
|
||||
|
|
|
@ -54,7 +54,7 @@ public final class SmsAddressGenerator implements GeneratorSource {
|
|||
|
||||
String output = inputNumber;
|
||||
// we add the text only if there actually is something in the field.
|
||||
if (inputMessage.length() > 0) {
|
||||
if (!inputMessage.isEmpty()) {
|
||||
output += ':' + inputMessage;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public final class SmsAddressGenerator implements GeneratorSource {
|
|||
|
||||
private String getTelField() throws GeneratorException {
|
||||
String input = number.getText();
|
||||
if (input.length() < 1) {
|
||||
if (input.isEmpty()) {
|
||||
throw new GeneratorException("Phone number must be present.");
|
||||
}
|
||||
input = Validators.filterNumber(input);
|
||||
|
|
|
@ -49,7 +49,7 @@ public final class TextGenerator implements GeneratorSource {
|
|||
|
||||
String getTextField() throws GeneratorException {
|
||||
String input = text.getText();
|
||||
if (input.length() == 0) {
|
||||
if (input.isEmpty()) {
|
||||
throw new GeneratorException("Text should be at least 1 character.");
|
||||
}
|
||||
return input;
|
||||
|
|
|
@ -69,7 +69,7 @@ public final class WifiGenerator implements GeneratorSource {
|
|||
StringBuilder output = new StringBuilder(100);
|
||||
output.append("WIFI:");
|
||||
output.append("S:").append(ssid).append(';');
|
||||
if (type != null && type.length() > 0 && !"nopass".equals(type)) {
|
||||
if (type != null && !type.isEmpty() && !"nopass".equals(type)) {
|
||||
maybeAppend(output, "T:", type);
|
||||
}
|
||||
maybeAppend(output, "P:", password);
|
||||
|
@ -81,14 +81,14 @@ public final class WifiGenerator implements GeneratorSource {
|
|||
}
|
||||
|
||||
private static void maybeAppend(StringBuilder output, String prefix, String value) {
|
||||
if (value != null && value.length() > 0) {
|
||||
if (value != null && !value.isEmpty()) {
|
||||
output.append(prefix).append(value).append(';');
|
||||
}
|
||||
}
|
||||
|
||||
private static String parseTextField(String name, HasText textBox) throws GeneratorException {
|
||||
String input = textBox.getText();
|
||||
if (input.length() < 1) {
|
||||
if (input.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
if (input.contains("\n")) {
|
||||
|
@ -99,7 +99,7 @@ public final class WifiGenerator implements GeneratorSource {
|
|||
|
||||
private String getSsidField() throws GeneratorException {
|
||||
String input = ssid.getText();
|
||||
if (input.length() < 1) {
|
||||
if (input.isEmpty()) {
|
||||
throw new GeneratorException("SSID must be at least 1 character.");
|
||||
}
|
||||
String parsed = parseTextField("SSID", ssid);
|
||||
|
|
Loading…
Reference in a new issue