Converted all StringBuffers to StringBuilders
This commit is contained in:
parent
5c4419bcbd
commit
cab1a4bc1e
|
@ -146,7 +146,7 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
|
|||
throw new ObjectConverterException(this,"Step size is wrong; "+steps.size()+" need: "+splitSize);
|
||||
}
|
||||
try {
|
||||
StringBuffer buf = new StringBuffer(200);
|
||||
StringBuilder buf = new StringBuilder(200);
|
||||
for (int i=0;i<steps.size();i++) {
|
||||
StringSplitConverterStep step = steps.get(i);
|
||||
Method m = classTo.getMethod(step.getFromMethod(), new Class[] {});
|
||||
|
|
|
@ -73,7 +73,7 @@ public class AttributeFromBodyConfigurator extends AbstractElementConfigurator {
|
|||
}
|
||||
|
||||
private String fetchBodyType(Element element,ElementType elementType) {
|
||||
StringBuffer buf = new StringBuffer(300);
|
||||
StringBuilder buf = new StringBuilder(300);
|
||||
List<Element> childsAll = element.getAllChilderen();
|
||||
List<Element> childs = ElementType.filterElements(childsAll, elementType);
|
||||
for (int i=0;i<childs.size();i++) {
|
||||
|
|
|
@ -94,7 +94,7 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler<
|
|||
}
|
||||
// TODO: no language here so move to EL default on eld attribute tag
|
||||
if (elementNamespace.getId()!=null) {
|
||||
StringBuffer buf = new StringBuffer(30);
|
||||
StringBuilder buf = new StringBuilder(30);
|
||||
for (char c:elementNamespace.getId().toLowerCase().toCharArray()) {
|
||||
if (Character.isLetter(c)) {buf.append(c);}
|
||||
if (Character.isDigit(c)) {buf.append(c);}
|
||||
|
|
|
@ -165,7 +165,7 @@ public class EldXsdWriterElement {
|
|||
// this is a mess;
|
||||
String desc = "Automatic generated schema for language: "+language.getLanguageName()+" by "+byValue;
|
||||
int space = COMMENT_SEPERATOR.length()-desc.length()-(2*COMMENT_TEXT.length())-4;
|
||||
StringBuffer b = new StringBuffer(COMMENT_SEPERATOR.length());
|
||||
StringBuilder b = new StringBuilder(COMMENT_SEPERATOR.length());
|
||||
b.append(" ");
|
||||
b.append(COMMENT_TEXT);
|
||||
b.append(" ");
|
||||
|
@ -191,7 +191,7 @@ public class EldXsdWriterElement {
|
|||
break;
|
||||
}
|
||||
}
|
||||
StringBuffer b = new StringBuffer(COMMENT_SEPERATOR.length());
|
||||
StringBuilder b = new StringBuilder(COMMENT_SEPERATOR.length());
|
||||
String formatLine = "\n\t%1$-20s %2$s";
|
||||
b.append(String.format(formatLine,"Id:",module.getId()));
|
||||
b.append(String.format(formatLine,"ProviderName:",module.getProviderName()));
|
||||
|
|
|
@ -273,7 +273,7 @@ public final class XMLConstants {
|
|||
static public String escapeAttributeName(String value) {
|
||||
// Attribute ::= Name Eq AttValue
|
||||
int length = value.length();
|
||||
StringBuffer result = new StringBuffer(length);
|
||||
StringBuilder result = new StringBuilder(length);
|
||||
for (int i=0;i<length;i++) {
|
||||
char c = value.charAt(i);
|
||||
if (isNameChar(c)) {
|
||||
|
@ -315,7 +315,7 @@ public final class XMLConstants {
|
|||
for (int i=0;i<length;i++) {
|
||||
char c = value.charAt(i);
|
||||
if (c=='&') {
|
||||
StringBuffer buf = new StringBuffer(length);
|
||||
StringBuilder buf = new StringBuilder(length);
|
||||
int iOrg = i;
|
||||
i = charEntityLookup(i,value,buf);
|
||||
String entity = buf.toString();
|
||||
|
@ -382,8 +382,8 @@ public final class XMLConstants {
|
|||
return false;
|
||||
}
|
||||
|
||||
static private int charEntityLookup(int iStart,String value,StringBuffer buf) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
static private int charEntityLookup(int iStart,String value,StringBuilder buf) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
int iMax = 10;
|
||||
for (int i=iStart;i<value.length() && i<(iStart+iMax);i++) {
|
||||
char c = value.charAt(i);
|
||||
|
@ -406,7 +406,7 @@ public final class XMLConstants {
|
|||
value = value.replaceAll(COMMENT_START, "");
|
||||
value = value.replaceAll(COMMENT_END, "");
|
||||
int length = value.length();
|
||||
StringBuffer result = new StringBuffer(length);
|
||||
StringBuilder result = new StringBuilder(length);
|
||||
for (int i=0;i<length;i++) {
|
||||
char c = value.charAt(i);
|
||||
if (c=='\n') {
|
||||
|
|
|
@ -396,7 +396,7 @@ public class X4ODebugWriter {
|
|||
contentWriter.endElement(DEBUG_URI, "elementObject", "");
|
||||
}
|
||||
|
||||
StringBuffer elementPath = getElementPath(element,new StringBuffer());
|
||||
StringBuilder elementPath = getElementPath(element,new StringBuilder());
|
||||
atts.addAttribute ("", "elementPath", "", "", elementPath.toString());
|
||||
|
||||
contentWriter.startElement (DEBUG_URI, "element", "", atts);
|
||||
|
@ -412,7 +412,7 @@ public class X4ODebugWriter {
|
|||
* @param buff The buffer.
|
||||
* @return Returns the buffer of the builf path.
|
||||
*/
|
||||
private StringBuffer getElementPath(Element element,StringBuffer buff) {
|
||||
private StringBuilder getElementPath(Element element,StringBuilder buff) {
|
||||
if (element.getParent()==null) {
|
||||
buff.append('/'); // root slash
|
||||
buff.append(element.getElementClass().getId());
|
||||
|
|
|
@ -81,7 +81,7 @@ public class X4OEntityResolver implements EntityResolver {
|
|||
if (ns.getSchemaResource()==null) {
|
||||
continue;
|
||||
}
|
||||
StringBuffer buf = new StringBuffer(30);
|
||||
StringBuilder buf = new StringBuilder(30);
|
||||
buf.append(elementContext.getLanguage().getLanguageConfiguration().getLanguageResourcePathPrefix());
|
||||
buf.append('/');
|
||||
buf.append(elementContext.getLanguage().getLanguageName());
|
||||
|
@ -89,7 +89,7 @@ public class X4OEntityResolver implements EntityResolver {
|
|||
buf.append(ns.getSchemaResource());
|
||||
schemaResources.put( ns.getSchemaUri(), buf.toString() );
|
||||
|
||||
buf = new StringBuffer(30);
|
||||
buf = new StringBuilder(30);
|
||||
buf.append(elementContext.getLanguage().getLanguageName());
|
||||
buf.append(File.separatorChar);
|
||||
buf.append(ns.getSchemaResource());
|
||||
|
|
|
@ -72,7 +72,7 @@ public class X4OErrorHandler implements ErrorHandler {
|
|||
* Prints the error message to string.
|
||||
*/
|
||||
private String printErrorString(boolean isError, SAXParseException exception) {
|
||||
StringBuffer buf = new StringBuffer(50);
|
||||
StringBuilder buf = new StringBuilder(50);
|
||||
buf.append(exception.getSystemId());
|
||||
buf.append(":");
|
||||
buf.append(exception.getLineNumber());
|
||||
|
|
|
@ -61,7 +61,7 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
|||
private int indent = 0;
|
||||
private Map<String,String> prefixMapping = null;
|
||||
private List<String> printedMappings = null;
|
||||
private StringBuffer startElement = null;
|
||||
private StringBuilder startElement = null;
|
||||
private boolean printReturn = false;
|
||||
private String lastElement = null;
|
||||
private Stack<String> elements = null;
|
||||
|
@ -248,7 +248,7 @@ public class AbstractContentWriterHandler implements ContentHandler {
|
|||
throw new SAXException("LocalName of element is not valid in xml; '"+localName+"'");
|
||||
}
|
||||
autoCloseStartElement();
|
||||
startElement = new StringBuffer(200);
|
||||
startElement = new StringBuilder(200);
|
||||
startElement.append(getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE));
|
||||
for (int i = 0; i < indent; i++) {
|
||||
startElement.append(getPropertyConfig().getPropertyString(OUTPUT_CHAR_TAB));
|
||||
|
|
|
@ -267,7 +267,7 @@ TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
|
|||
}
|
||||
|
||||
private class ModulesTagHandler extends DefaultHandler2 {
|
||||
private StringBuffer buf = new StringBuffer();
|
||||
private StringBuilder buf = new StringBuilder();
|
||||
private String loadedFrom = null;
|
||||
private VersionedResources versionedResources = null;
|
||||
private List<VersionedResources> result = null;
|
||||
|
@ -302,7 +302,7 @@ TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
|
|||
|
||||
// Get and clear text
|
||||
String value = buf.toString();
|
||||
buf = new StringBuffer();
|
||||
buf = new StringBuilder();
|
||||
|
||||
// Skip root and language and non versions
|
||||
if ("modules".equals(tag)) {
|
||||
|
|
|
@ -64,7 +64,7 @@ public abstract class AbstractX4OLanguageTask implements X4OLanguageTask {
|
|||
if (keys.isEmpty()) {
|
||||
return config;
|
||||
}
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("Error missing value(s) for key(s) {");
|
||||
for (int i=0;i<keys.size();i++) {
|
||||
buf.append('"');
|
||||
|
|
|
@ -196,7 +196,7 @@ public class X4OTaskCommandLine {
|
|||
}
|
||||
|
||||
private String unescapeDefault(String defaultValue) {
|
||||
StringBuffer buf = new StringBuffer(defaultValue.length()+10);
|
||||
StringBuilder buf = new StringBuilder(defaultValue.length()+10);
|
||||
for (char c:defaultValue.toCharArray()) {
|
||||
if (c=='\n') {
|
||||
buf.append("\\n");continue;
|
||||
|
|
|
@ -274,7 +274,7 @@ public class EldDocWriter {
|
|||
}
|
||||
|
||||
private String createPageSubTitle() {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
buf.append(language.getLanguageName());
|
||||
buf.append(" ");// note use real space as 'html/header/title' will not always escape entities. TODO: add to html writer
|
||||
buf.append(language.getLanguageVersion());
|
||||
|
@ -283,7 +283,7 @@ public class EldDocWriter {
|
|||
}
|
||||
|
||||
private String createLanguageAbout() {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("XML X4O Language\n");
|
||||
buf.append(language.getLanguageName().toUpperCase());
|
||||
buf.append("™ ");
|
||||
|
@ -293,7 +293,7 @@ public class EldDocWriter {
|
|||
|
||||
private String createLanguageCopyright() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("Copyright © ");
|
||||
buf.append(calendar.get(Calendar.YEAR));
|
||||
buf.append(" ");
|
||||
|
|
|
@ -164,7 +164,7 @@ public class EldDocWriterElementClass extends AbstractApiDocWriter {
|
|||
}
|
||||
|
||||
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespace namespace,ElementClass ec) {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
if (pathPrefix!=null) {
|
||||
buf.append(pathPrefix);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
|
|||
}
|
||||
}
|
||||
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespace namespace,ElementClass ec) {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
if (pathPrefix!=null) {
|
||||
buf.append(pathPrefix);
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ public abstract class AbstractApiDocWriter {
|
|||
return "class "+cls.getName();
|
||||
}
|
||||
if (value instanceof List) {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("[L: ");
|
||||
List<?> l = (List<?>)value;
|
||||
if (l.isEmpty()) {
|
||||
|
@ -197,7 +197,7 @@ public abstract class AbstractApiDocWriter {
|
|||
return buf.toString();
|
||||
}
|
||||
if (value instanceof Object[]) {
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("[A: ");
|
||||
Object[] l = (Object[])value;
|
||||
if (l.length==0) {
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
|||
// ======= Write body
|
||||
printTagStart(Tag.body);
|
||||
|
||||
StringBuffer script = new StringBuffer();
|
||||
StringBuilder script = new StringBuilder();
|
||||
script.append("\n");
|
||||
script.append("\tif (location.href.indexOf('is-external=true') == -1) {\n");
|
||||
script.append("\t\tparent.document.title=\"");script.append(title);script.append("\";\n");
|
||||
|
@ -300,7 +300,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
|
|||
}
|
||||
|
||||
static public String toSafeUri(String...paths) {
|
||||
StringBuffer result = new StringBuffer(100);
|
||||
StringBuilder result = new StringBuilder(100);
|
||||
for (int i=0;i<paths.length;i++) {
|
||||
String path=paths[i];
|
||||
result.append(toSafeUri(path));
|
||||
|
|
|
@ -422,7 +422,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
writer.printTagEnd(Tag.li);
|
||||
} else {
|
||||
writer.printTagStart(Tag.li);
|
||||
StringBuffer buf = new StringBuffer(20);
|
||||
StringBuilder buf = new StringBuilder(20);
|
||||
for (int i=1;i<linkPrefixCount;i++) {
|
||||
buf.append("../");
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
}
|
||||
|
||||
private void writeStyleSheetResources(List<String> resources) throws IOException, SecurityException, InterruptedException {
|
||||
StringBuffer cssData = new StringBuffer();
|
||||
StringBuilder cssData = new StringBuilder();
|
||||
for (String cssResource:resources) {
|
||||
appendResourceToBuffer(cssData,cssResource);
|
||||
}
|
||||
|
@ -891,7 +891,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
}
|
||||
}
|
||||
|
||||
private void appendResourceToBuffer(StringBuffer buffer,String resource) throws IOException {
|
||||
private void appendResourceToBuffer(StringBuilder buffer,String resource) throws IOException {
|
||||
ClassLoader cl = X4OLanguageClassLoader.getClassLoader();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
|
@ -948,7 +948,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
|
|||
}
|
||||
|
||||
private File createOutputPathFile(File basePath,String...argu) {
|
||||
StringBuffer buf = new StringBuffer(200);
|
||||
StringBuilder buf = new StringBuilder(200);
|
||||
buf.append(basePath.getAbsolutePath());
|
||||
buf.append(File.separatorChar);
|
||||
for (int i=0;i<argu.length-1;i++) {
|
||||
|
|
|
@ -69,7 +69,7 @@ public class DefaultPageWriterTree implements ApiDocPageWriter {
|
|||
}
|
||||
}
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (!doc.getRootNode().equals(node)) {
|
||||
buildParentPath(node,buf);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class DefaultPageWriterTree implements ApiDocPageWriter {
|
|||
writer.printTagEnd(Tag.ul);
|
||||
}
|
||||
|
||||
private void buildParentPath(ApiDocNode node,StringBuffer buf) {
|
||||
private void buildParentPath(ApiDocNode node,StringBuilder buf) {
|
||||
if (node.getParent()==null) {
|
||||
buf.append(ApiDocContentWriter.toSafeUri(node.getId()));
|
||||
buf.append('/');
|
||||
|
|
|
@ -347,7 +347,7 @@ public class ApiDoc {
|
|||
*/
|
||||
public void createDocCopyright(String owner) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
StringBuilder buf = new StringBuilder(100);
|
||||
buf.append("Copyright © ");
|
||||
buf.append(calendar.get(Calendar.YEAR));
|
||||
buf.append(" ");
|
||||
|
|
Loading…
Reference in a new issue