Converted all StringBuffers to StringBuilders

This commit is contained in:
Willem Cazander 2014-03-09 14:41:23 +01:00
parent 5c4419bcbd
commit cab1a4bc1e
20 changed files with 37 additions and 37 deletions

View file

@ -146,7 +146,7 @@ public class StringSplitConverter extends AbstractStringObjectConverter {
throw new ObjectConverterException(this,"Step size is wrong; "+steps.size()+" need: "+splitSize); throw new ObjectConverterException(this,"Step size is wrong; "+steps.size()+" need: "+splitSize);
} }
try { try {
StringBuffer buf = new StringBuffer(200); StringBuilder buf = new StringBuilder(200);
for (int i=0;i<steps.size();i++) { for (int i=0;i<steps.size();i++) {
StringSplitConverterStep step = steps.get(i); StringSplitConverterStep step = steps.get(i);
Method m = classTo.getMethod(step.getFromMethod(), new Class[] {}); Method m = classTo.getMethod(step.getFromMethod(), new Class[] {});

View file

@ -73,7 +73,7 @@ public class AttributeFromBodyConfigurator extends AbstractElementConfigurator {
} }
private String fetchBodyType(Element element,ElementType elementType) { private String fetchBodyType(Element element,ElementType elementType) {
StringBuffer buf = new StringBuffer(300); StringBuilder buf = new StringBuilder(300);
List<Element> childsAll = element.getAllChilderen(); List<Element> childsAll = element.getAllChilderen();
List<Element> childs = ElementType.filterElements(childsAll, elementType); List<Element> childs = ElementType.filterElements(childsAll, elementType);
for (int i=0;i<childs.size();i++) { for (int i=0;i<childs.size();i++) {

View file

@ -94,7 +94,7 @@ public class ElementModuleBindingHandler extends AbstractElementBindingHandler<
} }
// TODO: no language here so move to EL default on eld attribute tag // TODO: no language here so move to EL default on eld attribute tag
if (elementNamespace.getId()!=null) { if (elementNamespace.getId()!=null) {
StringBuffer buf = new StringBuffer(30); StringBuilder buf = new StringBuilder(30);
for (char c:elementNamespace.getId().toLowerCase().toCharArray()) { for (char c:elementNamespace.getId().toLowerCase().toCharArray()) {
if (Character.isLetter(c)) {buf.append(c);} if (Character.isLetter(c)) {buf.append(c);}
if (Character.isDigit(c)) {buf.append(c);} if (Character.isDigit(c)) {buf.append(c);}

View file

@ -165,7 +165,7 @@ public class EldXsdWriterElement {
// this is a mess; // this is a mess;
String desc = "Automatic generated schema for language: "+language.getLanguageName()+" by "+byValue; String desc = "Automatic generated schema for language: "+language.getLanguageName()+" by "+byValue;
int space = COMMENT_SEPERATOR.length()-desc.length()-(2*COMMENT_TEXT.length())-4; 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(" ");
b.append(COMMENT_TEXT); b.append(COMMENT_TEXT);
b.append(" "); b.append(" ");
@ -191,7 +191,7 @@ public class EldXsdWriterElement {
break; break;
} }
} }
StringBuffer b = new StringBuffer(COMMENT_SEPERATOR.length()); StringBuilder b = new StringBuilder(COMMENT_SEPERATOR.length());
String formatLine = "\n\t%1$-20s %2$s"; String formatLine = "\n\t%1$-20s %2$s";
b.append(String.format(formatLine,"Id:",module.getId())); b.append(String.format(formatLine,"Id:",module.getId()));
b.append(String.format(formatLine,"ProviderName:",module.getProviderName())); b.append(String.format(formatLine,"ProviderName:",module.getProviderName()));

View file

@ -273,7 +273,7 @@ public final class XMLConstants {
static public String escapeAttributeName(String value) { static public String escapeAttributeName(String value) {
// Attribute ::= Name Eq AttValue // Attribute ::= Name Eq AttValue
int length = value.length(); int length = value.length();
StringBuffer result = new StringBuffer(length); StringBuilder result = new StringBuilder(length);
for (int i=0;i<length;i++) { for (int i=0;i<length;i++) {
char c = value.charAt(i); char c = value.charAt(i);
if (isNameChar(c)) { if (isNameChar(c)) {
@ -315,7 +315,7 @@ public final class XMLConstants {
for (int i=0;i<length;i++) { for (int i=0;i<length;i++) {
char c = value.charAt(i); char c = value.charAt(i);
if (c=='&') { if (c=='&') {
StringBuffer buf = new StringBuffer(length); StringBuilder buf = new StringBuilder(length);
int iOrg = i; int iOrg = i;
i = charEntityLookup(i,value,buf); i = charEntityLookup(i,value,buf);
String entity = buf.toString(); String entity = buf.toString();
@ -382,8 +382,8 @@ public final class XMLConstants {
return false; return false;
} }
static private int charEntityLookup(int iStart,String value,StringBuffer buf) { static private int charEntityLookup(int iStart,String value,StringBuilder buf) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
int iMax = 10; int iMax = 10;
for (int i=iStart;i<value.length() && i<(iStart+iMax);i++) { for (int i=iStart;i<value.length() && i<(iStart+iMax);i++) {
char c = value.charAt(i); char c = value.charAt(i);
@ -406,7 +406,7 @@ public final class XMLConstants {
value = value.replaceAll(COMMENT_START, ""); value = value.replaceAll(COMMENT_START, "");
value = value.replaceAll(COMMENT_END, ""); value = value.replaceAll(COMMENT_END, "");
int length = value.length(); int length = value.length();
StringBuffer result = new StringBuffer(length); StringBuilder result = new StringBuilder(length);
for (int i=0;i<length;i++) { for (int i=0;i<length;i++) {
char c = value.charAt(i); char c = value.charAt(i);
if (c=='\n') { if (c=='\n') {

View file

@ -396,7 +396,7 @@ public class X4ODebugWriter {
contentWriter.endElement(DEBUG_URI, "elementObject", ""); contentWriter.endElement(DEBUG_URI, "elementObject", "");
} }
StringBuffer elementPath = getElementPath(element,new StringBuffer()); StringBuilder elementPath = getElementPath(element,new StringBuilder());
atts.addAttribute ("", "elementPath", "", "", elementPath.toString()); atts.addAttribute ("", "elementPath", "", "", elementPath.toString());
contentWriter.startElement (DEBUG_URI, "element", "", atts); contentWriter.startElement (DEBUG_URI, "element", "", atts);
@ -412,7 +412,7 @@ public class X4ODebugWriter {
* @param buff The buffer. * @param buff The buffer.
* @return Returns the buffer of the builf path. * @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) { if (element.getParent()==null) {
buff.append('/'); // root slash buff.append('/'); // root slash
buff.append(element.getElementClass().getId()); buff.append(element.getElementClass().getId());

View file

@ -81,7 +81,7 @@ public class X4OEntityResolver implements EntityResolver {
if (ns.getSchemaResource()==null) { if (ns.getSchemaResource()==null) {
continue; continue;
} }
StringBuffer buf = new StringBuffer(30); StringBuilder buf = new StringBuilder(30);
buf.append(elementContext.getLanguage().getLanguageConfiguration().getLanguageResourcePathPrefix()); buf.append(elementContext.getLanguage().getLanguageConfiguration().getLanguageResourcePathPrefix());
buf.append('/'); buf.append('/');
buf.append(elementContext.getLanguage().getLanguageName()); buf.append(elementContext.getLanguage().getLanguageName());
@ -89,7 +89,7 @@ public class X4OEntityResolver implements EntityResolver {
buf.append(ns.getSchemaResource()); buf.append(ns.getSchemaResource());
schemaResources.put( ns.getSchemaUri(), buf.toString() ); schemaResources.put( ns.getSchemaUri(), buf.toString() );
buf = new StringBuffer(30); buf = new StringBuilder(30);
buf.append(elementContext.getLanguage().getLanguageName()); buf.append(elementContext.getLanguage().getLanguageName());
buf.append(File.separatorChar); buf.append(File.separatorChar);
buf.append(ns.getSchemaResource()); buf.append(ns.getSchemaResource());

View file

@ -72,7 +72,7 @@ public class X4OErrorHandler implements ErrorHandler {
* Prints the error message to string. * Prints the error message to string.
*/ */
private String printErrorString(boolean isError, SAXParseException exception) { private String printErrorString(boolean isError, SAXParseException exception) {
StringBuffer buf = new StringBuffer(50); StringBuilder buf = new StringBuilder(50);
buf.append(exception.getSystemId()); buf.append(exception.getSystemId());
buf.append(":"); buf.append(":");
buf.append(exception.getLineNumber()); buf.append(exception.getLineNumber());

View file

@ -61,7 +61,7 @@ public class AbstractContentWriterHandler implements ContentHandler {
private int indent = 0; private int indent = 0;
private Map<String,String> prefixMapping = null; private Map<String,String> prefixMapping = null;
private List<String> printedMappings = null; private List<String> printedMappings = null;
private StringBuffer startElement = null; private StringBuilder startElement = null;
private boolean printReturn = false; private boolean printReturn = false;
private String lastElement = null; private String lastElement = null;
private Stack<String> elements = 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+"'"); throw new SAXException("LocalName of element is not valid in xml; '"+localName+"'");
} }
autoCloseStartElement(); autoCloseStartElement();
startElement = new StringBuffer(200); startElement = new StringBuilder(200);
startElement.append(getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE)); startElement.append(getPropertyConfig().getPropertyString(OUTPUT_CHAR_NEWLINE));
for (int i = 0; i < indent; i++) { for (int i = 0; i < indent; i++) {
startElement.append(getPropertyConfig().getPropertyString(OUTPUT_CHAR_TAB)); startElement.append(getPropertyConfig().getPropertyString(OUTPUT_CHAR_TAB));

View file

@ -267,7 +267,7 @@ TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
} }
private class ModulesTagHandler extends DefaultHandler2 { private class ModulesTagHandler extends DefaultHandler2 {
private StringBuffer buf = new StringBuffer(); private StringBuilder buf = new StringBuilder();
private String loadedFrom = null; private String loadedFrom = null;
private VersionedResources versionedResources = null; private VersionedResources versionedResources = null;
private List<VersionedResources> result = null; private List<VersionedResources> result = null;
@ -302,7 +302,7 @@ TODO: if (language.getLanguageConfiguration().hasX4ODebugWriter()) {
// Get and clear text // Get and clear text
String value = buf.toString(); String value = buf.toString();
buf = new StringBuffer(); buf = new StringBuilder();
// Skip root and language and non versions // Skip root and language and non versions
if ("modules".equals(tag)) { if ("modules".equals(tag)) {

View file

@ -64,7 +64,7 @@ public abstract class AbstractX4OLanguageTask implements X4OLanguageTask {
if (keys.isEmpty()) { if (keys.isEmpty()) {
return config; return config;
} }
StringBuffer buf = new StringBuffer(100); StringBuilder buf = new StringBuilder(100);
buf.append("Error missing value(s) for key(s) {"); buf.append("Error missing value(s) for key(s) {");
for (int i=0;i<keys.size();i++) { for (int i=0;i<keys.size();i++) {
buf.append('"'); buf.append('"');

View file

@ -196,7 +196,7 @@ public class X4OTaskCommandLine {
} }
private String unescapeDefault(String defaultValue) { private String unescapeDefault(String defaultValue) {
StringBuffer buf = new StringBuffer(defaultValue.length()+10); StringBuilder buf = new StringBuilder(defaultValue.length()+10);
for (char c:defaultValue.toCharArray()) { for (char c:defaultValue.toCharArray()) {
if (c=='\n') { if (c=='\n') {
buf.append("\\n");continue; buf.append("\\n");continue;

View file

@ -274,7 +274,7 @@ public class EldDocWriter {
} }
private String createPageSubTitle() { private String createPageSubTitle() {
StringBuffer buf = new StringBuffer(100); StringBuilder buf = new StringBuilder(100);
buf.append(language.getLanguageName()); 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(" ");// note use real space as 'html/header/title' will not always escape entities. TODO: add to html writer
buf.append(language.getLanguageVersion()); buf.append(language.getLanguageVersion());
@ -283,7 +283,7 @@ public class EldDocWriter {
} }
private String createLanguageAbout() { private String createLanguageAbout() {
StringBuffer buf = new StringBuffer(100); StringBuilder buf = new StringBuilder(100);
buf.append("XML X4O Language\n"); buf.append("XML X4O Language\n");
buf.append(language.getLanguageName().toUpperCase()); buf.append(language.getLanguageName().toUpperCase());
buf.append("&trade;&nbsp;"); buf.append("&trade;&nbsp;");
@ -293,7 +293,7 @@ public class EldDocWriter {
private String createLanguageCopyright() { private String createLanguageCopyright() {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
StringBuffer buf = new StringBuffer(100); StringBuilder buf = new StringBuilder(100);
buf.append("Copyright&nbsp;&#x00a9;&nbsp;"); buf.append("Copyright&nbsp;&#x00a9;&nbsp;");
buf.append(calendar.get(Calendar.YEAR)); buf.append(calendar.get(Calendar.YEAR));
buf.append("&nbsp;"); buf.append("&nbsp;");

View file

@ -164,7 +164,7 @@ public class EldDocWriterElementClass extends AbstractApiDocWriter {
} }
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespace namespace,ElementClass ec) { private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespace namespace,ElementClass ec) {
StringBuffer buf = new StringBuffer(100); StringBuilder buf = new StringBuilder(100);
if (pathPrefix!=null) { if (pathPrefix!=null) {
buf.append(pathPrefix); buf.append(pathPrefix);
} }

View file

@ -108,7 +108,7 @@ public class EldDocXTreePageWriter extends DefaultPageWriterTree implements ApiD
} }
} }
private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespace namespace,ElementClass ec) { private String toElementUri(String pathPrefix,X4OLanguageModule mod,ElementNamespace namespace,ElementClass ec) {
StringBuffer buf = new StringBuffer(100); StringBuilder buf = new StringBuilder(100);
if (pathPrefix!=null) { if (pathPrefix!=null) {
buf.append(pathPrefix); buf.append(pathPrefix);
} }

View file

@ -183,7 +183,7 @@ public abstract class AbstractApiDocWriter {
return "class "+cls.getName(); return "class "+cls.getName();
} }
if (value instanceof List) { if (value instanceof List) {
StringBuffer buf = new StringBuffer(100); StringBuilder buf = new StringBuilder(100);
buf.append("[L: "); buf.append("[L: ");
List<?> l = (List<?>)value; List<?> l = (List<?>)value;
if (l.isEmpty()) { if (l.isEmpty()) {
@ -197,7 +197,7 @@ public abstract class AbstractApiDocWriter {
return buf.toString(); return buf.toString();
} }
if (value instanceof Object[]) { if (value instanceof Object[]) {
StringBuffer buf = new StringBuffer(100); StringBuilder buf = new StringBuilder(100);
buf.append("[A: "); buf.append("[A: ");
Object[] l = (Object[])value; Object[] l = (Object[])value;
if (l.length==0) { if (l.length==0) {

View file

@ -68,7 +68,7 @@ public class ApiDocContentWriter extends ContentWriterHtml {
// ======= Write body // ======= Write body
printTagStart(Tag.body); printTagStart(Tag.body);
StringBuffer script = new StringBuffer(); StringBuilder script = new StringBuilder();
script.append("\n"); script.append("\n");
script.append("\tif (location.href.indexOf('is-external=true') == -1) {\n"); script.append("\tif (location.href.indexOf('is-external=true') == -1) {\n");
script.append("\t\tparent.document.title=\"");script.append(title);script.append("\";\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) { static public String toSafeUri(String...paths) {
StringBuffer result = new StringBuffer(100); StringBuilder result = new StringBuilder(100);
for (int i=0;i<paths.length;i++) { for (int i=0;i<paths.length;i++) {
String path=paths[i]; String path=paths[i];
result.append(toSafeUri(path)); result.append(toSafeUri(path));

View file

@ -422,7 +422,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
writer.printTagEnd(Tag.li); writer.printTagEnd(Tag.li);
} else { } else {
writer.printTagStart(Tag.li); writer.printTagStart(Tag.li);
StringBuffer buf = new StringBuffer(20); StringBuilder buf = new StringBuilder(20);
for (int i=1;i<linkPrefixCount;i++) { for (int i=1;i<linkPrefixCount;i++) {
buf.append("../"); buf.append("../");
} }
@ -596,7 +596,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
} }
private void writeStyleSheetResources(List<String> resources) throws IOException, SecurityException, InterruptedException { private void writeStyleSheetResources(List<String> resources) throws IOException, SecurityException, InterruptedException {
StringBuffer cssData = new StringBuffer(); StringBuilder cssData = new StringBuilder();
for (String cssResource:resources) { for (String cssResource:resources) {
appendResourceToBuffer(cssData,cssResource); 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(); ClassLoader cl = X4OLanguageClassLoader.getClassLoader();
BufferedReader reader = null; BufferedReader reader = null;
try { try {
@ -948,7 +948,7 @@ public class ApiDocWriter extends AbstractApiDocWriter {
} }
private File createOutputPathFile(File basePath,String...argu) { private File createOutputPathFile(File basePath,String...argu) {
StringBuffer buf = new StringBuffer(200); StringBuilder buf = new StringBuilder(200);
buf.append(basePath.getAbsolutePath()); buf.append(basePath.getAbsolutePath());
buf.append(File.separatorChar); buf.append(File.separatorChar);
for (int i=0;i<argu.length-1;i++) { for (int i=0;i<argu.length-1;i++) {

View file

@ -69,7 +69,7 @@ public class DefaultPageWriterTree implements ApiDocPageWriter {
} }
} }
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
if (!doc.getRootNode().equals(node)) { if (!doc.getRootNode().equals(node)) {
buildParentPath(node,buf); buildParentPath(node,buf);
} }
@ -92,7 +92,7 @@ public class DefaultPageWriterTree implements ApiDocPageWriter {
writer.printTagEnd(Tag.ul); writer.printTagEnd(Tag.ul);
} }
private void buildParentPath(ApiDocNode node,StringBuffer buf) { private void buildParentPath(ApiDocNode node,StringBuilder buf) {
if (node.getParent()==null) { if (node.getParent()==null) {
buf.append(ApiDocContentWriter.toSafeUri(node.getId())); buf.append(ApiDocContentWriter.toSafeUri(node.getId()));
buf.append('/'); buf.append('/');

View file

@ -347,7 +347,7 @@ public class ApiDoc {
*/ */
public void createDocCopyright(String owner) { public void createDocCopyright(String owner) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
StringBuffer buf = new StringBuffer(100); StringBuilder buf = new StringBuilder(100);
buf.append("Copyright&nbsp;&#x00a9;&nbsp;"); buf.append("Copyright&nbsp;&#x00a9;&nbsp;");
buf.append(calendar.get(Calendar.YEAR)); buf.append(calendar.get(Calendar.YEAR));
buf.append("&nbsp;"); buf.append("&nbsp;");