Skip to content
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.

Code quality fix - Synchronized classes Vector, Hashtable, Stack and StringBuffer should not be used. #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions src/main/java/us/monoid/json/CDL.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class CDL {
private static String getValue(JSONTokener x) throws JSONException {
char c;
char q;
StringBuffer sb;
StringBuilder sb;
do {
c = x.next();
} while (c == ' ' || c == '\t');
Expand All @@ -65,7 +65,7 @@ private static String getValue(JSONTokener x) throws JSONException {
case '"':
case '\'':
q = c;
sb = new StringBuffer();
sb = new StringBuilder();
for (;;) {
c = x.next();
if (c == q) {
Expand Down Expand Up @@ -205,7 +205,7 @@ public static JSONArray toJSONArray(JSONArray names, JSONTokener x)
* @return A string ending in NEWLINE.
*/
public static String rowToString(JSONArray ja) {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ja.length(); i += 1) {
if (i > 0) {
sb.append(',');
Expand Down Expand Up @@ -267,7 +267,7 @@ public static String toString(JSONArray names, JSONArray ja)
if (names == null || names.length() == 0) {
return null;
}
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ja.length(); i += 1) {
JSONObject jo = ja.optJSONObject(i);
if (jo != null) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/us/monoid/json/Cookie.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class Cookie {
public static String escape(String string) {
char c;
String s = string.trim();
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
int len = s.length();
for (int i = 0; i < len; i += 1) {
c = s.charAt(i);
Expand Down Expand Up @@ -117,7 +117,7 @@ public static JSONObject toJSONObject(String string) throws JSONException {
* @throws JSONException
*/
public static String toString(JSONObject o) throws JSONException {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();

sb.append(escape(o.getString("name")));
sb.append("=");
Expand Down Expand Up @@ -150,7 +150,7 @@ public static String toString(JSONObject o) throws JSONException {
*/
public static String unescape(String s) {
int len = s.length();
StringBuffer b = new StringBuffer();
StringBuilder b = new StringBuilder();
for (int i = 0; i < len; ++i) {
char c = s.charAt(i);
if (c == '+') {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/us/monoid/json/CookieList.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static String toString(JSONObject o) throws JSONException {
boolean b = false;
Iterator<?> keys = o.keys();
String s;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
while (keys.hasNext()) {
s = keys.next().toString();
if (!o.isNull(s)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/us/monoid/json/HTTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static JSONObject toJSONObject(String string) throws JSONException {
public static String toString(JSONObject o) throws JSONException {
Iterator<?> keys = o.keys();
String s;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
if (o.has("Status-Code") && o.has("Reason-Phrase")) {
sb.append(o.getString("HTTP-Version"));
sb.append(' ');
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/us/monoid/json/HTTPTokener.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public HTTPTokener(String s) {
public String nextToken() throws JSONException {
char c;
char q;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
do {
c = next();
} while (Character.isWhitespace(c));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/us/monoid/json/JSONArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public boolean isNull(int index) {
*/
public String join(String separator) throws JSONException {
int len = length();
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();

for (int i = 0; i < len; i += 1) {
if (i > 0) {
Expand Down Expand Up @@ -885,7 +885,7 @@ String toString(int indentFactor, int indent) throws JSONException {
return "[]";
}
int i;
StringBuffer sb = new StringBuffer("[");
StringBuilder sb = new StringBuilder("[");
if (len == 1) {
sb.append(JSONObject.valueToString(this.myArrayList.get(0), indentFactor, indent));
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/us/monoid/json/JSONML.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public static String toString(JSONArray ja) throws JSONException {
String k;
Iterator<?> keys;
int length;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
String tagName;
String v;

Expand Down Expand Up @@ -390,7 +390,7 @@ public static String toString(JSONArray ja) throws JSONException {
* @throws JSONException
*/
public static String toString(JSONObject jo) throws JSONException {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
Object e;
int i;
JSONArray ja;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/us/monoid/json/JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ public static String quote(String string) {
char c = 0;
int i;
int len = string.length();
StringBuffer sb = new StringBuffer(len + 4);
StringBuilder sb = new StringBuilder(len + 4);
String t;

sb.append('"');
Expand Down Expand Up @@ -1785,7 +1785,7 @@ public JSONArray toJSONArray(JSONArray names) throws JSONException {
public String toString() {
try {
Iterator<String> keys = sortedKeys();
StringBuffer sb = new StringBuffer("{");
StringBuilder sb = new StringBuilder("{");

while (keys.hasNext()) {
if (sb.length() > 1) {
Expand Down Expand Up @@ -1844,7 +1844,7 @@ String toString(int indentFactor, int indent) throws JSONException {
return "{}";
}
Iterator<String> keys = sortedKeys();
StringBuffer sb = new StringBuffer("{");
StringBuilder sb = new StringBuilder("{");
int newindent = indent + indentFactor;
Object o;
if (n == 1) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/us/monoid/json/JSONTokener.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public char nextClean() throws JSONException {
*/
public String nextString(char quote) throws JSONException {
char c;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (;;) {
c = next();
switch (c) {
Expand Down Expand Up @@ -295,7 +295,7 @@ public String nextString(char quote) throws JSONException {
* @return A string.
*/
public String nextTo(char d) throws JSONException {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (;;) {
char c = next();
if (c == d || c == 0 || c == '\n' || c == '\r') {
Expand All @@ -317,7 +317,7 @@ public String nextTo(char d) throws JSONException {
*/
public String nextTo(String delimiters) throws JSONException {
char c;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (;;) {
c = next();
if (delimiters.indexOf(c) >= 0 || c == 0 ||
Expand Down Expand Up @@ -365,7 +365,7 @@ public Object nextValue() throws JSONException {
* formatting character.
*/

StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
sb.append(c);
c = next();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/us/monoid/json/XML.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class XML {
* @return The escaped string.
*/
public static String escape(String string) {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0, len = string.length(); i < len; i++) {
char c = string.charAt(i);
switch (c) {
Expand Down Expand Up @@ -329,7 +329,7 @@ public static String toString(Object o) throws JSONException {
*/
public static String toString(Object o, String tagName)
throws JSONException {
StringBuffer b = new StringBuffer();
StringBuilder b = new StringBuilder();
int i;
JSONArray ja;
JSONObject jo;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/us/monoid/json/XMLTokener.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public XMLTokener(String s) {
public String nextCDATA() throws JSONException {
char c;
int i;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (;;) {
c = next();
if (end()) {
Expand Down Expand Up @@ -92,7 +92,7 @@ public String nextCDATA() throws JSONException {
*/
public Object nextContent() throws JSONException {
char c;
StringBuffer sb;
StringBuilder sb;
do {
c = next();
} while (Character.isWhitespace(c));
Expand All @@ -102,7 +102,7 @@ public Object nextContent() throws JSONException {
if (c == '<') {
return XML.LT;
}
sb = new StringBuffer();
sb = new StringBuilder();
for (;;) {
if (c == '<' || c == 0) {
back();
Expand All @@ -126,7 +126,7 @@ public Object nextContent() throws JSONException {
* @throws JSONException If missing ';' in XML entity.
*/
public Object nextEntity(char a) throws JSONException {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (;;) {
char c = next();
if (Character.isLetterOrDigit(c) || c == '#') {
Expand Down Expand Up @@ -220,7 +220,7 @@ public Object nextMeta() throws JSONException {
public Object nextToken() throws JSONException {
char c;
char q;
StringBuffer sb;
StringBuilder sb;
do {
c = next();
} while (Character.isWhitespace(c));
Expand All @@ -245,7 +245,7 @@ public Object nextToken() throws JSONException {
case '"':
case '\'':
q = c;
sb = new StringBuffer();
sb = new StringBuilder();
for (;;) {
c = next();
if (c == 0) {
Expand All @@ -264,7 +264,7 @@ public Object nextToken() throws JSONException {

// Name

sb = new StringBuffer();
sb = new StringBuilder();
for (;;) {
sb.append(c);
c = next();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/us/monoid/web/jp/javacc/ParseException.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
StringBuilder expected = new StringBuilder();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
Expand Down Expand Up @@ -139,7 +139,7 @@ private static String initialise(Token currentToken,
* string literal.
*/
static String add_escapes(String str) {
StringBuffer retval = new StringBuffer();
StringBuilder retval = new StringBuilder();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/us/monoid/web/jp/javacc/TokenMgrError.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class TokenMgrError extends Error
* equivalents in the given string
*/
protected static final String addEscapes(String str) {
StringBuffer retval = new StringBuffer();
StringBuilder retval = new StringBuilder();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
Expand Down