Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/scripts/generate-quality-report.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,8 @@ def main() -> None:
"SA_FIELD_SELF_ASSIGNMENT",
"UC_USELESS_CONDITION",
"EC_UNRELATED_TYPES",
"EQ_ALWAYS_FALSE"
"EQ_ALWAYS_FALSE",
"SBSC_USE_STRINGBUFFER_CONCATENATION"
}
violations = [
f for f in spotbugs.findings
Expand Down
6 changes: 3 additions & 3 deletions CodenameOne/src/com/codename1/ads/InnerActive.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ public void initService(Ads ads) {
String[] keywords = ads.getKeywords();
if (keywords != null && keywords.length > 0) {
int klen = keywords.length;
String k = "";
StringBuilder k = new StringBuilder();
for (int i = 0; i < klen; i++) {
k += "," + keywords[i];
k.append(",").append(keywords[i]);
}
addParam(this, "k", k.substring(1));
addParam(this, "k", k.toString().substring(1));
}
if (testAds) {
addParam(this, "test", "1");
Expand Down
16 changes: 9 additions & 7 deletions CodenameOne/src/com/codename1/facebook/FaceBookAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,12 @@ public Oauth2 createOAuth() {
String scope = "";
if (permissions != null && permissions.length > 0) {
int plen = permissions.length;
StringBuilder scopeBuilder = new StringBuilder();
for (int i = 0; i < plen; i++) {
String permission = permissions[i];
scope += permission + ",";
scopeBuilder.append(permission).append(",");
}
scope = scopeBuilder.toString();
scope = scope.substring(0, scope.length() - 1);
}
Hashtable additionalParams = new Hashtable();
Expand Down Expand Up @@ -1221,21 +1223,21 @@ public void getUsersDetails(String[] usersIds, String[] fields, final ActionList
checkAuthentication();

final FacebookRESTService con = new FacebookRESTService(token, "https://api.facebook.com/method/users.getInfo", false);
String ids = usersIds[0];
StringBuilder ids = new StringBuilder(usersIds[0]);
int ulen = usersIds.length;
for (int i = 1; i < ulen; i++) {
ids += "," + usersIds[i];
ids.append(",").append(usersIds[i]);

}
con.addArgumentNoEncoding("uids", ids);
con.addArgumentNoEncoding("uids", ids.toString());

String fieldsStr = fields[0];
StringBuilder fieldsStr = new StringBuilder(fields[0]);
int flen = fields.length;
for (int i = 1; i < flen; i++) {
fieldsStr += "," + fields[i];
fieldsStr.append(",").append(fields[i]);

}
con.addArgumentNoEncoding("fields", fieldsStr);
con.addArgumentNoEncoding("fields", fieldsStr.toString());
con.addArgument("format", "json");

con.addResponseListener(new ActionListener() {
Expand Down
4 changes: 3 additions & 1 deletion CodenameOne/src/com/codename1/io/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,12 @@ public static String getLogContent() {
Reader r = Util.getReader(FileSystemStorage.getInstance().openInputStream(instance.getFileURL()));
char[] buffer = new char[1024];
int size = r.read(buffer);
StringBuilder textBuilder = new StringBuilder();
while (size > -1) {
text += new String(buffer, 0, size);
textBuilder.append(new String(buffer, 0, size));
size = r.read(buffer);
}
text = textBuilder.toString();
r.close();
}
return text;
Expand Down
14 changes: 7 additions & 7 deletions CodenameOne/src/com/codename1/io/Oauth2.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,26 +385,26 @@ public void actionPerformed(ActionEvent ev) {
}

private String buildURL() {
String URL = oauth2URL + "?client_id=" + Util.encodeUrl(clientId)
+ "&redirect_uri=" + Util.encodeUrl(redirectURI);
StringBuilder URL = new StringBuilder(oauth2URL + "?client_id=" + Util.encodeUrl(clientId)
+ "&redirect_uri=" + Util.encodeUrl(redirectURI));
if (scope != null) {
URL += "&scope=" + Util.encodeUrl(scope);
URL.append("&scope=").append(Util.encodeUrl(scope));
}
if (clientSecret != null) {
URL += "&response_type=code";
URL.append("&response_type=code");
} else {
URL += "&response_type=token";
URL.append("&response_type=token");
}

if (additionalParams != null) {
Enumeration e = additionalParams.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
String val = additionalParams.get(key).toString();
URL += "&" + Util.encodeUrl(key) + "=" + Util.encodeUrl(val);
URL.append("&").append(Util.encodeUrl(key)).append("=").append(Util.encodeUrl(val));
}
}
return URL;
return URL.toString();
}

private Component createLoginComponent(final ActionListener al, final Form frm, final Form backToForm, final Dialog progress) {
Expand Down
11 changes: 6 additions & 5 deletions CodenameOne/src/com/codename1/io/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -2492,11 +2492,12 @@ private static String append(String a, int in) {

private static String append(String a, long in, int length) {
int lim = (length << 2) - 4;
StringBuilder sb = new StringBuilder(a);
while (lim >= 0) {
a += (DIGITS[(byte) (in >> lim) & 0x0f]);
sb.append((DIGITS[(byte) (in >> lim) & 0x0f]));
lim -= 4;
}
return a;
return sb.toString();
}

private static long getUniqueDeviceID() {
Expand Down Expand Up @@ -2537,13 +2538,13 @@ private static long generateLongFromDeviceInfo() {
* @return
*/
private static String sanitizeString(String input) {
String result = "";
StringBuilder result = new StringBuilder();
for (char myChar : input.toCharArray()) {
if ((myChar >= '0' && myChar <= '9') || (myChar >= 'a' && myChar <= 'z') || (myChar >= 'A' && myChar <= 'Z')) {
result += myChar;
result.append(myChar);
}
}
return result.substring(0, Math.min(10, result.length())).toUpperCase();
return result.toString().substring(0, Math.min(10, result.length())).toUpperCase();
}

/**
Expand Down
14 changes: 7 additions & 7 deletions CodenameOne/src/com/codename1/properties/PropertyXMLElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,22 +372,22 @@ public String toString() {
@Override
public String toString(String spacing) {

String str = spacing;
str += "<" + getTagName();
StringBuilder str = new StringBuilder(spacing);
str.append("<").append(getTagName());
Hashtable attributes = getAttributes();
if (attributes != null) {
for (Enumeration e = attributes.keys(); e.hasMoreElements(); ) {
String attrStr = (String) e.nextElement();
String val = (String) attributes.get(attrStr);
str += " " + attrStr + "='" + val + "'";
str.append(" ").append(attrStr).append("='").append(val).append("'");
}
}
str += ">\n";
str.append(">\n");
Vector children = getChildren();
for (int i = 0; i < children.size(); i++) {
str += ((Element) children.get(i)).toString(spacing + ' ');
str.append(((Element) children.get(i)).toString(spacing + ' '));
}
str += spacing + "</" + getTagName() + ">\n";
return str;
str.append(spacing).append("</").append(getTagName()).append(">\n");
return str.toString();
}
}
6 changes: 3 additions & 3 deletions CodenameOne/src/com/codename1/testing/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ private static String toString(int[] p) {
if (p.length == 0) {
return "{}";
}
String s = "{" + p[0];
StringBuilder s = new StringBuilder("{" + p[0]);
for (int iter = 1; iter < p.length; iter++) {
s += ", " + p[iter];
s.append(", ").append(p[iter]);

}
return s + "}";
return s.append("}").toString();
}

/**
Expand Down
12 changes: 7 additions & 5 deletions CodenameOne/src/com/codename1/ui/ComponentSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -2229,12 +2229,13 @@ public ComponentSelector addTags(String... tags) {
existing = "";
}

StringBuilder existingBuilder = new StringBuilder(existing);
for (String tag : tags) {
if (existing.indexOf(" " + tag + " ") == -1) {
existing += " " + tag + " ";
if (existingBuilder.toString().indexOf(" " + tag + " ") == -1) {
existingBuilder.append(" ").append(tag).append(" ");
}
}
c.putClientProperty(PROPERTY_TAG, existing);
c.putClientProperty(PROPERTY_TAG, existingBuilder.toString());

}
return this;
Expand Down Expand Up @@ -2266,10 +2267,11 @@ public ComponentSelector removeTags(String... tags) {
c.putClientProperty(PROPERTY_TAG, null);
continue;
}
StringBuilder existingBuilder = new StringBuilder(existing);
for (String tag : existingSet) {
existing += " " + tag + " ";
existingBuilder.append(" ").append(tag).append(" ");
}
c.putClientProperty(PROPERTY_TAG, existing);
c.putClientProperty(PROPERTY_TAG, existingBuilder.toString());
}
return this;
}
Expand Down
10 changes: 5 additions & 5 deletions CodenameOne/src/com/codename1/ui/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -3095,18 +3095,18 @@ protected String paramString() {
* @return the container components objects as list of Strings
*/
private String getComponentsNames() {
String ret = "[";
StringBuilder ret = new StringBuilder("[");
int componentCount = components.size();
for (int iter = 0; iter < componentCount; iter++) {
Component cmp = components.get(iter);
String className = cmp.getClass().getName();
ret += className.substring(className.lastIndexOf('.') + 1) + ", ";
ret.append(className.substring(className.lastIndexOf('.') + 1)).append(", ");
}
if (ret.length() > 1) {
ret = ret.substring(0, ret.length() - 2);
ret.setLength(ret.length() - 2);
}
ret = ret + "]";
return ret;
ret.append("]");
return ret.toString();
}

/**
Expand Down
10 changes: 5 additions & 5 deletions CodenameOne/src/com/codename1/ui/TextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -1137,25 +1137,25 @@ private void initRowString() {
if (useStringWidth || actAsLabel) {
// fix for an infinite loop issue: http://forums.java.net/jive/thread.jspa?messageID=482802
//currentRowWidth = 0;
String currentRow = "";
StringBuilder currentRowBuilder = new StringBuilder();

// search for "space" character at close as possible to the end of the row
for (i = to; i < textLength && fastCharWidthCheck(text, from, i - from + 1, textAreaWidth, charWidth, font); i++) {
char c = text[i];
/*if(updateRowWidth(c, font) >= textAreaWidth) {
break;
}*/
currentRow += c;
currentRowBuilder.append(c);
if (i < textLength - 1 && Character.isSurrogatePair(c, text[i + 1])) {
// Surrogate pairs (e.g. emojis) shouldn't be split up.
currentRow += text[++i];
currentRowBuilder.append(text[++i]);
maxLength += 2;
if (font.stringWidth(currentRow) >= textAreaWidth) {
if (font.stringWidth(currentRowBuilder.toString()) >= textAreaWidth) {
break;
}
continue;
}
if (font.stringWidth(currentRow) >= textAreaWidth) {
if (font.stringWidth(currentRowBuilder.toString()) >= textAreaWidth) {
break;
}
if (unsupported.indexOf(c) > -1) {
Expand Down
24 changes: 12 additions & 12 deletions CodenameOne/src/com/codename1/ui/html/CSSEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ private void setTextTransformRecursive(Component cmp, int transformType) {

String text = label.getText();

String newText = "";
StringBuilder newText = new StringBuilder();
boolean capNextLetter = true;
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
Expand All @@ -634,9 +634,9 @@ private void setTextTransformRecursive(Component cmp, int transformType) {
}
capNextLetter = false;
}
newText += c;
newText.append(c);
}
label.setText(newText);
label.setText(newText.toString());
break;
default:
break;
Expand Down Expand Up @@ -803,25 +803,25 @@ private void setNowrapRecursive(final HTMLElement element) {
String text = element.getText();
final Vector ui = element.getUi();
if ((text != null) && (ui != null) && (ui.size() > 1)) { //If it's just one word or already no-wrapped, no need to process
String word = "";
String newText = "";
StringBuilder word = new StringBuilder();
StringBuilder newText = new StringBuilder();
for (int c = 0; c < text.length(); c++) {
char ch = text.charAt(c);
if ((ch == ' ') || (ch == '\n') || (ch == '\r') || (ch == '\t')) {
if (!word.equals("")) {
newText += word + " ";
word = "";
if (word.length() > 0) {
newText.append(word).append(" ");
word.setLength(0);
}
} else {
word += ch;
word.append(ch);
}
}
if (!word.equals("")) {
newText += word + " ";
if (word.length() > 0) {
newText.append(word).append(" ");
}

final Label label = (Label) ui.elementAt(0);
setNowrapText(label, ui, newText, element);
setNowrapText(label, ui, newText.toString(), element);
}
}

Expand Down
Loading
Loading