Skip to content

Commit

Permalink
Merge pull request apache#5319 from tbw777/substring
Browse files Browse the repository at this point in the history
Simplified usage String.substring() method from two arguments to one.
  • Loading branch information
mbien authored Feb 4, 2023
2 parents 8d16de8 + b02e217 commit 570e74a
Show file tree
Hide file tree
Showing 142 changed files with 193 additions and 197 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public static String getMethodName(String fieldName, boolean get) {
// }
// String prefix = methodName.substring(0, 3);
// if (prefix.equals("set") || prefix.equals("get")) {
// return lower(methodName.substring(3, methodName.length()));
// return lower(methodName.substring(3));
// }
// return null;
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@ private JdbcConnectionPool setAdditionalProps(String vendorName, String url, Jdb
if(vendorName.equals("sybase2")){ //NOI18N
int index = url.indexOf("Tds:"); //NOI18N
if(index != -1){
workingUrl = url.substring(index + 4, url.length()); //NOI18N
workingUrl = url.substring(index + 4); //NOI18N
} else {
return jdbcConnectionPool;
}
}else {
workingUrl = url.substring(url.indexOf("//") + 2, url.length()); //NOI18N
workingUrl = url.substring(url.indexOf("//") + 2); //NOI18N
}
PropertyElement servName = jdbcConnectionPool.newPropertyElement();
servName.setName(WizardConstants.__ServerName);
Expand Down Expand Up @@ -652,7 +652,7 @@ public String getDerbyDatabaseName(String url){
if(colonIndex != -1) {
databaseName = url.substring(index + 1, colonIndex);
} else {
databaseName = url.substring(index + 1, url.length());
databaseName = url.substring(index + 1);
}
}
return databaseName;
Expand All @@ -662,7 +662,7 @@ private String getDerbyConnAttrs(String url){
String connAttr = ""; //NOI18N
int colonIndex = url.indexOf(";"); //NOI18N
if(colonIndex != -1) {
connAttr = url.substring(colonIndex, url.length());
connAttr = url.substring(colonIndex);
}
return connAttr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void setAddressValue(String portNumber){
String inMiddle = debugOptionsVal.substring(debugOptionsVal.indexOf(DEBUG_OPTIONS_ADDRESS) + DEBUG_OPTIONS_ADDRESS.length(), debugOptionsVal.length());
int hasMore = inMiddle.indexOf(","); //NOI18N
if(hasMore != -1){
String debugOptionsEnd = inMiddle.substring(hasMore, inMiddle.length());
String debugOptionsEnd = inMiddle.substring(hasMore);
debugOptionsStart = debugOptionsStart + debugOptionsEnd;
}
Attribute newAttr = new Attribute(DEBUG_OPTIONS, debugOptionsStart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static String getCorrectedLabel(ResourceBundle bundle, String key){
// some locales do not have mnemonics?
if (i > -1) {
result = val.substring(0, i);
result = result.concat(val.substring(i+1, val.length()));
result = result.concat(val.substring(i+1));
} else {
result = val;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public boolean canFileDeploy(Target target, J2eeModule deployable) {
public File getDirectoryForNewApplication(Target target, J2eeModule app, ModuleConfiguration configuration) {
String baseName = app.getUrl();
if(baseName.indexOf(File.separatorChar) >= 0) {
baseName = baseName.substring(baseName.lastIndexOf(File.separatorChar) +1, baseName.length());
baseName = baseName.substring(baseName.lastIndexOf(File.separatorChar) +1);
}
String extension = getExtension(app.getType());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ String resolveBundleDir() {

// Remove '/' prefix if any so that directory is a relative path
if (toRet.startsWith("/")) { //NOI18N
toRet = toRet.substring(1, toRet.length());
toRet = toRet.substring(1);
}

if (toRet.length() > 0 && !toRet.endsWith("/")) { //NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static String encodeAndHighlight(String text, OffsetRange expressionOffset, Offs
String expression = text.substring(expressionOffset.getStart(), expressionOffset.getEnd());
result.append(encodeAngleBrackets(text.substring(0, expressionOffset.getStart())));
result.append(highlight(expression, nodeOffset));
result.append(encodeAngleBrackets(text.substring(expressionOffset.getEnd(), text.length())));
result.append(encodeAngleBrackets(text.substring(expressionOffset.getEnd())));
return result.toString();
}

Expand All @@ -68,7 +68,7 @@ private static String highlight(String text, OffsetRange offsetRange) {
result.append("<b>");
result.append(encodeAngleBrackets(text.subSequence(offsetRange.getStart(), offsetRange.getEnd()).toString()));
result.append("</b>");
result.append(text.substring(offsetRange.getEnd(), text.length()));
result.append(text.substring(offsetRange.getEnd()));
return result.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public static String findSessionID(String cookieStr) {

String name = token.substring(0, i).trim();
if(name.equals(JSESSIONID)) {
String value = token.substring(i+1, token.length()).trim();
String value = token.substring(i+1).trim();
return value=stripQuote(value);
}
}
Expand Down Expand Up @@ -285,7 +285,7 @@ public Param[] getCookiesAsParams() {
if (i > -1) {

String name = token.substring(0, i).trim();
String value = token.substring(i+1, token.length()).trim();
String value = token.substring(i+1).trim();
value=stripQuote(value);
cookies.addElement(new Param(name, value));
if(debug) log(name + "=" + value);
Expand Down Expand Up @@ -437,7 +437,7 @@ public void deleteCookie(String ckname, String ckvalue) {
if (j > -1) {

String name = token.substring(0, j).trim();
String value = token.substring(j+1, token.length()).trim();
String value = token.substring(j+1).trim();
value=stripQuote(value);

if(debug) log("Processing cookie: " + //NOI18N
Expand Down Expand Up @@ -505,7 +505,7 @@ public void deleteCookie(String ckname) {
else {
if(debug) log("Keep this cookie");//NOI18N
String value =
token.substring(j+1, token.length()).trim();
token.substring(j+1).trim();
value=stripQuote(value);
buf.append(name);
buf.append("=");//NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static String constructNewName(FileObject javaFile, RenameRefactoring ren
final String newName = buildName(prefix, rename.getNewName());
final int oldNameIndex = fqn.lastIndexOf(oldName) + oldName.length();

return newName + fqn.substring(oldNameIndex, fqn.length());
return newName + fqn.substring(oldNameIndex);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private void findResourcePath(String path, BaseDocument doc){
servletMapping = servletMapping.trim();
String prefix = servletMapping.substring(0, servletMapping.length()-2);
if (path.startsWith(prefix))
actionPath = path.substring(prefix.length(), path.length());
actionPath = path.substring(prefix.length());
else
actionPath = path;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private String capitalize(String str ){
return str;
}
char first = str.charAt(0);
return Character.toUpperCase(first) + str.substring(1 , str.length());
return Character.toUpperCase(first) + str.substring(1);
}

private String getPostfix( String path ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ public void run( final WorkingCopy working )
}

private static String capitalizeFirstLetter(String str) {
return str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
return str.substring(0, 1).toUpperCase() + str.substring(1);
}

private static void addXmlTransientAnnotation(WorkingCopy workingCopy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void flushLines (boolean flushEverything) throws IOException {
break MAIN;
}
if (flushEverything) {
flushLine(buffer.substring (0, buffer.length()));
flushLine(buffer.substring(0));
buffer.delete(0, buffer.length());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public static List<ASTNode> children(ASTNode root) {

if (fieldName.length() > 0 && !field.isStatic() && (field.getModifiers() & Opcodes.ACC_PRIVATE) != 0) {

fieldName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1, fieldName.length());
fieldName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
if (!field.isFinal()) {
possibleMethods.add("set" + fieldName); // NOI18N
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private boolean sanitizeSource(Context context, Sanitize sanitizing) {
sb.append(doc.substring(0, removeStart));
sb.append(' ');
if (removeEnd < doc.length()) {
sb.append(doc.substring(removeEnd, doc.length()));
sb.append(doc.substring(removeEnd));
}
assert sb.length() == doc.length();
context.sanitizedRange = new OffsetRange(removeStart, removeEnd);
Expand All @@ -286,7 +286,7 @@ private boolean sanitizeSource(Context context, Sanitize sanitizing) {
sb.append("//");
int rest = lineStart + 2;
if (rest < doc.length()) {
sb.append(doc.substring(rest, doc.length()));
sb.append(doc.substring(rest));
}
} else {
// A line with just one character - can't replace with a comment
Expand All @@ -295,7 +295,7 @@ private boolean sanitizeSource(Context context, Sanitize sanitizing) {
sb.append(" ");
int rest = lineStart + 1;
if (rest < doc.length()) {
sb.append(doc.substring(rest, doc.length()));
sb.append(doc.substring(rest));
}

}
Expand All @@ -320,7 +320,7 @@ private boolean sanitizeSource(Context context, Sanitize sanitizing) {
sb.append("//");
int rest = lineStart + 2;
if (rest < doc.length()) {
sb.append(doc.substring(rest, doc.length()));
sb.append(doc.substring(rest));
}
} else {
// A line with just one character - can't replace with a comment
Expand All @@ -329,7 +329,7 @@ private boolean sanitizeSource(Context context, Sanitize sanitizing) {
sb.append(" ");
int rest = lineStart + 1;
if (rest < doc.length()) {
sb.append(doc.substring(rest, doc.length()));
sb.append(doc.substring(rest));
}

}
Expand Down Expand Up @@ -401,7 +401,7 @@ private boolean sanitizeSource(Context context, Sanitize sanitizing) {
}

if (removeEnd < doc.length()) {
sb.append(doc.substring(removeEnd, doc.length()));
sb.append(doc.substring(removeEnd));
}
assert sb.length() == doc.length();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static String stripPackage(String fqn) {
if (last > first) {
return stripPackage(fqn.substring(0, first)) + "<" +
stripPackageFromTypeParams(fqn.substring(first + 1, last)) + ">" +
fqn.substring(last + 1, fqn.length());
fqn.substring(last + 1);
}
}
if (fqn.contains(".")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private String getExpandedSourcePath() {
}

private String firstLetterToLowerCase(String className) {
return Character.toLowerCase(className.charAt(0)) + className.substring(1, className.length());
return Character.toLowerCase(className.charAt(0)) + className.substring(1);
}

protected String getBasicSourcePath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static String trimStart(String s) {
if (Character.isWhitespace(s.charAt(x))) {
continue;
} else {
return s.substring(x, s.length());
return s.substring(x);
}
}
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static String constructNewName(FileObject file, RenameRefactoring rename)
String oldName = buildName(prefix, folder.getName());
String newName = buildName(prefix, rename.getNewName());
int oldNameIndex = fqn.lastIndexOf(oldName) + oldName.length();
return newName + fqn.substring(oldNameIndex, fqn.length());
return newName + fqn.substring(oldNameIndex);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static String replaceString(String original, String begin, String end, St
break;
to += end.length();
}
original = original.substring(0, from) + replace + original.substring(to, original.length());
original = original.substring(0, from) + replace + original.substring(to);
offset = from + replace.length();
} while (replaceAll);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private static String highLight(String s, Pattern pattern) {
idx = matcher.end();
}
if(sb.length() > 0) {
sb.append(idx < s.length() ? s.substring(idx, s.length()) : "");
sb.append(idx < s.length() ? s.substring(idx) : "");
s = sb.toString();
}
return s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public String highlite(String text, String displayText) {
idx = displayTextLower.indexOf(displayTextLower, lastIdx);
}
if(lastIdx < displayText.length()) {
sb.append(displayText.substring(lastIdx, displayText.length()));
sb.append(displayText.substring(lastIdx));
}
sb.append("</table></html>"); // NOI18N
return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3391,7 +3391,7 @@ private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
idx = comment.indexOf(s);
if(idx > 0) {
idx += s.length() + 1;
comment = comment.substring(0, idx) + "\n\n" + repro + comment.substring(idx, comment.length()); // NOI18N
comment = comment.substring(0, idx) + "\n\n" + repro + comment.substring(idx); // NOI18N
} else {
comment = repro + "\n\n" + comment; // NOI18N
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ private void setParameters(String urlParameters) {
int idx = p.indexOf("="); // NOI18N
if(idx > -1) {
String parameter = p.substring(0, idx);
String value = p.substring(idx + 1, p.length());
String value = p.substring(idx + 1);

ParameterValue pv = new ParameterValue(value, value);
List<ParameterValue> values = normalizedParams.get(parameter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void assertParameters(LogHandler h, String parametersUrl, QueryControlle
String[] parametersGiven = parametersUrl.split("&");
String params = c.getUrlParameters(true);
assertTrue(params.startsWith("&"));
params = params.substring(1, params.length());
params = params.substring(1);
String[] parametersReturned = params.split("&");
// assertEquals(parametersGiven.length, parametersReturned.length);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public static Node query(Node base, String path, boolean caseInsensitive) {
if (caseInsensitive) {
nodeName = nodeName.toLowerCase(Locale.ENGLISH);
}
String sindex = indexDelim >= 0 ? token.substring(indexDelim + 1, token.length()) : "0";
String sindex = indexDelim >= 0 ? token.substring(indexDelim + 1) : "0";
int index = Integer.parseInt(sindex);

int count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void run(StyleSheet styleSheet) {

String lightId = indexDelim >= 0 ? token.substring(0, indexDelim) : token;

String sindex = indexDelim >= 0 ? token.substring(indexDelim + 1, token.length()) : "1";
String sindex = indexDelim >= 0 ? token.substring(indexDelim + 1) : "1";
int index = Integer.parseInt(sindex);

int count = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public void keyPressed(KeyEvent e) {
// keywordString.substring(1, keywordString.length()-1);
// } else if (keywordString.length() > 2 && ( keywordString.startsWith("\"") || keywordString.startsWith("\'") ) ) {
// db_element_wo_quotes =
// keywordString.substring(1, keywordString.length());
// keywordString.substring(1);
// } else
// db_element_wo_quotes = keywordString;
// // check if it is schema name
Expand Down Expand Up @@ -437,7 +437,7 @@ public void keyPressed(KeyEvent e) {
// } else if ( str.length() > 2 &&
// ( str.startsWith("\"") ||
// str.startsWith("\'") ) ) {
// db_element_wo_quotes = str.substring(1, str.length());
// db_element_wo_quotes = str.substring(1);
// position = position+1;
// } else {
// db_element_wo_quotes = str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ static URL encodeURL(URL url) throws MalformedURLException, URISyntaxException {

String part = urlString.substring(colon + 1, pound != -1 ? pound : urlString.length());
if (pound != -1) {
fragment = urlString.substring(pound + 1, urlString.length());
fragment = urlString.substring(pound + 1);
}
return new URI(url.getProtocol(), part, fragment).toURL();
}
Expand Down
Loading

0 comments on commit 570e74a

Please sign in to comment.