Skip to content

Commit

Permalink
Merge pull request #2003 from mavrk/TRUNK-5038
Browse files Browse the repository at this point in the history
TRUNK-5038 Replace StringBuffer with StringBuilder
  • Loading branch information
teleivo committed Feb 17, 2017
2 parents 9c705a0 + a97ec5f commit ba9a68a
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/api/EventListeners.java
Expand Up @@ -38,7 +38,7 @@ public List<GlobalPropertyListener> getGlobalPropertyListeners() {
*/
public void setGlobalPropertyListeners(List<GlobalPropertyListener> globalPropertyListeners) {
if (log.isDebugEnabled()) {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (GlobalPropertyListener gpl : globalPropertyListeners) {
if (sb.length() > 0) {
sb.append(", ");
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/org/openmrs/hl7/HL7Util.java
Expand Up @@ -78,7 +78,7 @@ public static Date parseHL7Timestamp(String s) throws HL7Exception {
throw new HL7Exception("Invalid date '" + s + "'");
}

StringBuffer dateString = new StringBuffer();
StringBuilder dateString = new StringBuilder();
dateString.append(s.substring(0, 4)); // year
if (s.length() >= 6) {
dateString.append(s.substring(4, 6)); // month
Expand Down Expand Up @@ -225,7 +225,7 @@ public static Date parseHL7Time(String s) throws HL7Exception {
String timeZoneOffset = getTimeZoneOffset(s, new Date());
s = s.replace(timeZoneOffset, ""); // remove the timezone from the string

StringBuffer timeString = new StringBuffer();
StringBuilder timeString = new StringBuilder();

if (s.length() < 2 || s.length() > 16) {
throw new HL7Exception("Invalid time format '" + s + "'");
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/logic/LogicTransform.java
Expand Up @@ -51,7 +51,7 @@ public Operator getTransformOperator() {
}

public String toString() {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();

if (transformOperator != null) {
result.append(transformOperator);
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/logic/result/Result.java
Expand Up @@ -634,7 +634,7 @@ public String toString() {
return valueText;
}
}
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
for (Result r : this) {
if (s.length() > 0) {
s.append(",");
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/module/Module.java
Expand Up @@ -751,7 +751,7 @@ public void setStartupErrorMessage(String exceptionMessage, Throwable t) {
throw new ModuleException("Startup error value cannot be null", this.getModuleId());
}

StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();

// if exceptionMessage is not null, append it
if (exceptionMessage != null) {
Expand Down
Expand Up @@ -498,7 +498,7 @@ protected void modulesSetChanged() {
}

if (log.isDebugEnabled()) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("New code URL's populated for module " + getModule() + ":\r\n");
for (URL u : newUrls) {
buf.append("\t");
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/util/DoubleRange.java
Expand Up @@ -145,7 +145,7 @@ public boolean contains(double d) {
* @should print empty string if low and high are infinite
*/
public String toString() {
StringBuffer ret = new StringBuffer();
StringBuilder ret = new StringBuilder();
if (low != null && low.doubleValue() != Double.NEGATIVE_INFINITY) {
ret.append(">");
if (closedLow) {
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/org/openmrs/util/OpenmrsUtil.java
Expand Up @@ -218,7 +218,7 @@ public static Boolean isValidNumericValue(Float value, ConceptNumeric concept) {
* @throws IOException
*/
public static String getFileAsString(File file) throws IOException {
StringBuffer fileData = new StringBuffer(1000);
StringBuilder fileData = new StringBuilder(1000);
BufferedReader reader = new BufferedReader(new FileReader(file));
char[] buf = new char[1024];
int numRead = 0;
Expand Down Expand Up @@ -1583,7 +1583,7 @@ public static File getOutFile(File dir, Date date, User user) {
*/
public static String generateUid(Integer size) {
Random gen = new Random();
StringBuffer sb = new StringBuffer(size);
StringBuilder sb = new StringBuilder(size);
for (int i = 0; i < size; i++) {
int ch = gen.nextInt() * 62;
if (ch < 10) {
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/org/openmrs/util/Security.java
Expand Up @@ -139,7 +139,7 @@ private static String encodeStringSHA1(String strToEncode) throws APIException {
* @return Hexidecimal based string
*/
private static String hexString(byte[] block) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
int len = block.length;
int high = 0;
Expand Down Expand Up @@ -194,7 +194,7 @@ private static String incorrectHexString(byte[] b) {
if (b == null || b.length < 1) {
return "";
}
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
for (int i = 0; i < b.length; i++) {
s.append(Integer.toHexString(b[i] & 0xFF));
}
Expand Down
Expand Up @@ -127,7 +127,7 @@ public void execute(Database database) throws CustomChangeException {
+ databaseName;

// run the command line string
StringBuffer output = new StringBuffer();
StringBuilder output = new StringBuilder();
Integer exitValue = -1; // default to a non-zero exit value in case of exceptions
try {
exitValue = execCmd(tmpOutputFile.getParentFile(), commands.toArray(new String[] {}), output);
Expand Down Expand Up @@ -190,7 +190,7 @@ private String fixWindowsPathHack(String path) {
* @param the string
* @return process exit value
*/
private Integer execCmd(File wd, String[] cmdWithArguments, StringBuffer out) throws Exception {
private Integer execCmd(File wd, String[] cmdWithArguments, StringBuilder out) throws Exception {
log.debug("executing command: " + Arrays.toString(cmdWithArguments));

Integer exitValue = -1;
Expand Down
Expand Up @@ -153,7 +153,7 @@ public static boolean startModule(Module mod, ServletContext servletContext, boo
// trim out the starting path of "web/module/"
String filepath = name.substring(11);

StringBuffer absPath = new StringBuffer(realPath + "/WEB-INF");
StringBuilder absPath = new StringBuilder(realPath + "/WEB-INF");

// If this is within the tag file directory, copy it into /WEB-INF/tags/module/moduleId/...
if (filepath.startsWith("tags/")) {
Expand Down

0 comments on commit ba9a68a

Please sign in to comment.