unstick r1870129

Revision 1870129

Date:
2019/11/22 00:08:27
Author:
fanningpj
Revision Log:
replace some StringBuffers
Files:

Legend:

 
Added
 
Removed
 
Modified
  • xmlbeans/trunk/samples/SchemaEnum/src/org/apache/xmlbeans/samples/enumeration/SchemaEnum.java

     
    163 163 PriceSummaryDocument.PriceSummary summary = summaryDoc.getPriceSummary();
    164 164 PriceType[] priceElements = summary.getPriceArray();
    165 165
    166 StringBuffer responseBuffer = new StringBuffer();
    166 StringBuilder responseBuffer = new StringBuilder();
    167 167
    168 168 // Create string buffers to hold the sorted results of the values
    169 169 // retrieved.
    170 StringBuffer zeroBuffer = new StringBuffer("\nItems under 10 dollars: \n");
    171 StringBuffer tenBuffer = new StringBuffer("\nItems between 10 and 20 dollars: \n");
    172 StringBuffer twentyBuffer = new StringBuffer("\nItems more than 20 dollars: \n");
    170 StringBuilder zeroBuffer = new StringBuilder("\nItems under 10 dollars: \n");
    171 StringBuilder tenBuffer = new StringBuilder("\nItems between 10 and 20 dollars: \n");
    172 StringBuilder twentyBuffer = new StringBuilder("\nItems more than 20 dollars: \n");
    173 173
    174 174 // Loop through the price elements, extracting the array of <item> child
    175 175 // elements in each.
  • xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/NameUtil.java

     
    654 654 if (s.length() == 0 || Character.isUpperCase(s.charAt(0)))
    655 655 return s;
    656 656
    657 StringBuffer buf = new StringBuffer(s);
    657 StringBuilder buf = new StringBuilder(s);
    658 658 buf.setCharAt(0, Character.toUpperCase(buf.charAt(0)));
    659 659 return buf.toString();
    660 660 }
  • xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/regex/REUtil.java

     
    101 101 }
    102 102
    103 103 static final String createOptionString(int options) {
    104 StringBuffer sb = new StringBuffer(9);
    104 StringBuilder sb = new StringBuilder(9);
    105 105 if ((options & RegularExpression.PROHIBIT_FIXED_STRING_OPTIMIZATION) != 0)
    106 106 sb.append((char)'F');
    107 107 if ((options & RegularExpression.PROHIBIT_HEAD_CHARACTER_OPTIMIZATION) != 0)
     
    129 129
    130 130 static String stripExtendedComment(String regex) {
    131 131 int len = regex.length();
    132 StringBuffer buffer = new StringBuffer(len);
    132 StringBuilder buffer = new StringBuilder(len);
    133 133 int offset = 0;
    134 134 while (offset < len) {
    135 135 int ch = regex.charAt(offset++);
     
    298 298 */
    299 299 public static String quoteMeta(String literal) {
    300 300 int len = literal.length();
    301 StringBuffer buffer = null;
    301 StringBuilder buffer = null;
    302 302 for (int i = 0; i < len; i ++) {
    303 303 int ch = literal.charAt(i);
    304 304 if (".*+?{[()|\\^$".indexOf(ch) >= 0) {
    305 305 if (buffer == null) {
    306 buffer = new StringBuffer(i+(len-i)*2);
    306 buffer = new StringBuilder(i+(len-i)*2);
    307 307 if (i > 0) buffer.append(literal.substring(0, i));
    308 308 }
    309 309 buffer.append((char)'\\');
  • xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscChecker.java

     
    1635 1635
    1636 1636 private static String printParticles(SchemaParticle[] parts, int start, int end)
    1637 1637 {
    1638 StringBuffer buf = new StringBuffer(parts.length * 30);
    1638 StringBuilder buf = new StringBuilder(parts.length * 30);
    1639 1639 for (int i = start; i < end; )
    1640 1640 {
    1641 1641 buf.append(printParticle(parts[i]));
  • xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/StscTranslator.java

     
    596 596 // Error! Circular redefinition
    597 597 if (!errorReported)
    598 598 {
    599 StringBuffer fileNameList = new StringBuffer();
    599 StringBuilder fileNameList = new StringBuilder();
    600 600 XmlObject location = null;
    601 601 for (int i = 0; i < n; i++)
    602 602 if (specificRedefines[i] != null)
  • xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/util/XsTypeConverter.java

     
    194 194 int begin = (value.signum() < 0) ? 1 : 0;
    195 195 int delta = scale;
    196 196 // We take space for all digits, plus a possible decimal point, plus 'scale'
    197 StringBuffer result = new StringBuffer(intStr.length() + 1 + Math.abs(scale));
    197 StringBuilder result = new StringBuilder(intStr.length() + 1 + Math.abs(scale));
    198 198
    199 199 if (begin == 1)
    200 200 {
     
    765 765 } */
    766 766
    767 767 // Per XMLSchema spec allow spaces inside URIs
    768 StringBuffer s = new StringBuffer(lexical_value.toString());
    768 StringBuilder s = new StringBuilder(lexical_value.toString());
    769 769 for (int ic = 0; ic<URI_CHARS_TO_BE_REPLACED.length; ic++)
    770 770 {
    771 771 int i = 0;
  • xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlValidationError.java

     
    235 235 if (_fieldQName != null)
    236 236 {
    237 237 String msg = super.getMessage();
    238 StringBuffer sb = new StringBuffer(msg.length() + 100);
    238 StringBuilder sb = new StringBuilder(msg.length() + 100);
    239 239
    240 240 sb.append(msg);
    241 241
  • xmlbeans/trunk/test/src/scomp/common/BaseCase.java

     
    59 59
    60 60 return false;
    61 61 }
    62 StringBuffer errMessage=
    63 new StringBuffer();
    62 StringBuilder errMessage = new StringBuilder();
    64 63 for (int i = 0; i < errorList.size(); i++) {
    65 64 XmlError error = (XmlError) errorList.get(i);
    66 65 if ( error.getErrorCode() == null )
    67 66 errMessage.append("Kevin needs a code here "+error.getMessage()+"\n");
    68 67
    69 68 if (!expected[i].equals(error.getErrorCode())){
    70 if (errMessage.length() >0)
    69 if (errMessage.length() > 0)
    71 70 System.err.println(errMessage);
    72 71 ArrayList exp=new ArrayList();
    73 72
     
    80 79
    81 80 public String stringOfCodes(String[] errorCodes, ArrayList actual_errorCodes)
    82 81 {
    83 StringBuffer res=new StringBuffer();
    82 StringBuilder res = new StringBuilder();
    84 83 res.append("\n Expected codes:\n");
    85 84 int i=0;
    86 85 for (;i < errorCodes.length; i++ )
  • xmlbeans/trunk/test/src/xmlcursor/checkin/StoreTests.java

     
    315 315 return _sb.toString();
    316 316 }
    317 317
    318 private StringBuffer _sb = new StringBuffer();
    318 private StringBuilder _sb = new StringBuilder();
    319 319 }
    320 320
    321 321 private void doTestSaxSaver(String xml)
  • xmlbeans/trunk/test/src/xmlobject/extensions/interfaceFeature/readOnlyBean/checkin/ReadOnlyTest.java

     
    15 15 package xmlobject.extensions.interfaceFeature.readOnlyBean.checkin;
    16 16
    17 17
    18 import interfaceFeature.xbean.readOnlyBean.purchaseOrder.PurchaseOrderDocument ;
    18 import interfaceFeature.xbean.readOnlyBean.purchaseOrder.PurchaseOrderDocument;
    19 19 import interfaceFeature.xbean.readOnlyBean.purchaseOrder.PurchaseOrderType;
    20 20 import interfaceFeature.xbean.readOnlyBean.purchaseOrder.Items;
    21 21
    22 22
    23 23 import java.math.BigDecimal;
    24
    24 25 import junit.framework.*;
    25 26
    26 public class ReadOnlyTest extends TestCase{
    27 public class ReadOnlyTest extends TestCase {
    27 28
    28 29
    29 public ReadOnlyTest(String s){
    30 super(s);
    31 }
    32 public void test(){
    30 public ReadOnlyTest(String s) {
    31 super(s);
    32 }
    33 33
    34 PurchaseOrderDocument poDoc ;
    34 public void test() {
    35 35
    36 poDoc= PurchaseOrderDocument.Factory.newInstance();
    37 PurchaseOrderType po=poDoc.addNewPurchaseOrder();
    38 int LEN=20;
    36 PurchaseOrderDocument poDoc;
    39 37
    40 Items.Item[] it= new Items.Item[LEN];
    41 for (int i=0; i< LEN; i++){
    42 it[i]=Items.Item.Factory.newInstance();
    43 it[i].setUSPrice(new BigDecimal(""+ 4 ));
    44 }
    45 Items items= Items.Factory.newInstance();
    46 items.setItemArray(it);
    47 po.setItems(items);
    38 poDoc = PurchaseOrderDocument.Factory.newInstance();
    39 PurchaseOrderType po = poDoc.addNewPurchaseOrder();
    40 int LEN = 20;
    48 41
    49 StringBuilder sb = new StringBuilder();
    42 Items.Item[] it = new Items.Item[LEN];
    43 for (int i = 0; i < LEN; i++) {
    44 it[i] = Items.Item.Factory.newInstance();
    45 it[i].setUSPrice(new BigDecimal("" + 4));
    46 }
    47 Items items = Items.Factory.newInstance();
    48 items.setItemArray(it);
    49 po.setItems(items);
    50
    51 StringBuilder sb = new StringBuilder();
    50 52 sb.append(
    51 53 "<pur:purchaseOrder xmlns:pur=\"http://xbean.interface_feature/readOnlyBean/PurchaseOrder\">");
    52 54
    53 55 sb.append("<pur:items>");
    54 56
    55 StringBuffer sbContent = new StringBuffer();
    57 StringBuilder sbContent = new StringBuilder();
    56 58 for (int i = 0; i < LEN; i++)
    57 59 sbContent.append("<pur:item><pur:USPrice>4</pur:USPrice></pur:item>");
    58 60
     
    63 65 sbContent.toString() +
    64 66 sb.subSequence(pos, sb.length());
    65 67
    66 assertEquals( sExpected, poDoc.xmlText());
    68 assertEquals(sExpected, poDoc.xmlText());
    67 69
    68 try{
    70 try {
    69 71 poDoc.setPrice(10);
    70 72
    71 }catch (Exception t){
    73 } catch (Exception t) {
    72 74 t.printStackTrace(System.err);
    73 75 System.exit(-1);
    74 76 }
    75 77
    76 78
    77 assertTrue ( !poDoc.validate() );
    79 assertTrue(!poDoc.validate());
    78 80 }
    79
    81
    80 82 }
  • xmlbeans/trunk/test/src/xmlobject/extensions/prePostFeature/ValueRestriction/checkin/ValueRestrictionTest.java

     
    19 19 import org.apache.xmlbeans.XmlString;
    20 20
    21 21
    22 public class ValueRestrictionTest extends TestCase{
    22 public class ValueRestrictionTest extends TestCase {
    23 23
    24 public ValueRestrictionTest(String s){
    25 super(s);
    26 }
    27 public void test() throws Exception{
    24 public ValueRestrictionTest(String s) {
    25 super(s);
    26 }
    28 27
    29 CompanyDocument poDoc ;
    28 public void test() throws Exception {
    30 29
    31 poDoc= CompanyDocument.Factory.newInstance();
    32 CompanyType po=poDoc.addNewCompany();
    30 CompanyDocument poDoc;
    33 31
    32 poDoc = CompanyDocument.Factory.newInstance();
    33 CompanyType po = poDoc.addNewCompany();
    34 34
    35 int LEN=20;
    36 35
    37 StringBuffer sExpected=new StringBuffer();
    38 sExpected.append("<com:company xmlns:com=\"http://xbean.prePostFeature/ValueRestriction/company\"><departments>");
    39 DepartmentType dept=po.addNewDepartments();
    40 ConsultantType[] it= new ConsultantType[LEN];
    41 for (int i=0; i < LEN; i++){
    42 it[i]=dept.addNewConsultant();
    43 XmlString s= XmlString.Factory.newInstance();
    44 it[i].setAge(50);
    45 sExpected.append("<consultant age=\"50\"/>");
    46 }
    36 int LEN = 20;
    47 37
    48 sExpected.append("</departments></com:company>");
    38 StringBuilder sExpected = new StringBuilder();
    39 sExpected.append("<com:company xmlns:com=\"http://xbean.prePostFeature/ValueRestriction/company\"><departments>");
    40 DepartmentType dept = po.addNewDepartments();
    41 ConsultantType[] it = new ConsultantType[LEN];
    42 for (int i = 0; i < LEN; i++) {
    43 it[i] = dept.addNewConsultant();
    44 XmlString s = XmlString.Factory.newInstance();
    45 it[i].setAge(50);
    46 sExpected.append("<consultant age=\"50\"/>");
    47 }
    49 48
    50 assertEquals( sExpected.toString(), poDoc.xmlText());
    51 assertTrue( poDoc.validate() );
    49 sExpected.append("</departments></com:company>");
    52 50
    51 assertEquals(sExpected.toString(), poDoc.xmlText());
    52 assertTrue(poDoc.validate());
    53 53
    54 xmlobject.extensions.prePostFeature.ValueRestriction.existing.SetterHandler.bReady=true;
    55 54
    55 xmlobject.extensions.prePostFeature.ValueRestriction.existing.SetterHandler.bReady = true;
    56 56
    57 for (int i=0; i< LEN; i++){
    58 it[i].setAge(150);
    59 }
    60 57
    61 assertEquals( sExpected.toString(), poDoc.xmlText());
    62 assertTrue( poDoc.validate() );
    58 for (int i = 0; i < LEN; i++) {
    59 it[i].setAge(150);
    60 }
    63 61
    64 for (int i=0; i< LEN; i++){
    65 it[i].setEmployeeAge(150);
    66 }
    67 assertTrue( sExpected.toString().equals(poDoc.xmlText()) );
    68 assertTrue ( poDoc.validate() );
    62 assertEquals(sExpected.toString(), poDoc.xmlText());
    63 assertTrue(poDoc.validate());
    64
    65 for (int i = 0; i < LEN; i++) {
    66 it[i].setEmployeeAge(150);
    67 }
    68 assertTrue(sExpected.toString().equals(poDoc.xmlText()));
    69 assertTrue(poDoc.validate());
    69 70 }
    70 71
    71 72 }
  • xmlbeans/trunk/test/tools/src/tools/JUnit/SimpleResultFormatter.java

     
    109 109 */
    110 110 public void endTestSuite(JUnitTest suite) throws BuildException {
    111 111 String newLine = System.getProperty("line.separator");
    112 StringBuffer sb = new StringBuffer("Testsuite: ");
    112 StringBuilder sb = new StringBuilder("Testsuite: ");
    113 113 sb.append(suite.getName());
    114 114 sb.append(newLine);
    115 115 sb.append("Tests run: ");
  • xmlbeans/trunk/test/tools/src/tools/JUnit/XmlResultFormatter.java

     
    316 316 if (index < 0) index = exp.length();
    317 317 exo.setErrorname(exp.substring(0, index));
    318 318 }
    319 StringBuffer output = new StringBuffer();
    319 StringBuilder output = new StringBuilder();
    320 320 String eol = System.getProperty("line.separator");
    321 321 output.append("[STDOUT]").append(eol);
    322 322 output.append(rec.getSysout()).append(eol);
  • xmlbeans/trunk/test/tools/src/tools/JUnit/XmlResultFormatterImpl.java

     
    529 529 exo.setErrorname(exp.substring(0, index));
    530 530 }
    531 531
    532 StringBuffer output = new StringBuffer();
    532 StringBuilder output = new StringBuilder();
    533 533 String eol = System.getProperty("line.separator");
    534 534 output.append("[STDOUT]").append(eol);
    535 535 output.append(rec.getSysout()).append(eol);
  • xmlbeans/trunk/test/tools/src/tools/util/Util.java

     
    78 78 {
    79 79 try
    80 80 {
    81 StringBuffer sb = new StringBuffer(_charBuffer.length);
    81 StringBuilder sb = new StringBuilder(_charBuffer.length);
    82 82 int amount = 0;
    83 83
    84 84 while (true)
     
    736 736 hexStringFromBytes(byte[] bytes)
    737 737 {
    738 738 String hex = "0123456789abcdef";
    739 StringBuffer buf = new StringBuffer(2 * bytes.length);
    739 StringBuilder buf = new StringBuilder(2 * bytes.length);
    740 740
    741 741 for (int i = 0; i < bytes.length; i++)
    742 742 {
     
    805 805 int lenIn = sIn.length();
    806 806 int iIn;
    807 807
    808 StringBuffer outBuf = new StringBuffer(lenIn + lenIn / 4); // Plenty of room for extra characters
    808 StringBuilder outBuf = new StringBuilder(lenIn + lenIn / 4); // Plenty of room for extra characters
    809 809 char c;
    810 810
    811 811 for (iIn = 0; iIn < lenIn; ++iIn)
     
    1054 1054 if (map == null)
    1055 1055 return str;
    1056 1056
    1057 StringBuffer result = new StringBuffer();
    1057 StringBuilder result = new StringBuilder();
    1058 1058
    1059 1059 int pos = 0;
    1060 1060 int open = -1;
     
    1165 1165 public static String escapeProperty(String s)
    1166 1166 {
    1167 1167 int len = s.length();
    1168 StringBuffer buf = new StringBuffer(len * 2);
    1168 StringBuilder buf = new StringBuilder(len * 2);
    1169 1169
    1170 1170 for (int i = 0; i < len; ++i)
    1171 1171 {
  • xmlbeans/trunk/test/tools/src/tools/xml/XmlComparator.java

     
    24 24 {
    25 25 public static class Diagnostic
    26 26 {
    27 private StringBuffer message = null;
    27 private StringBuilder message = null;
    28 28
    29 29 private void add(String s)
    30 30 {
    31 if (message==null)
    32 message = new StringBuffer();
    31 if (message == null)
    32 message = new StringBuilder();
    33 33
    34 34 message.append(s).append("\n");
    35 35 }
    36 36
    37 37 public boolean hasMessage()
    38 38 {
    39 return message!=null;
    39 return message != null;
    40 40 }
    41 41
    42 42 public String toString()
    43 43 {
    44 return (message==null ? null : message.toString());
    44 return (message == null ? null : message.toString());
    45 45 }
    46 46
    47 47 public static void add(Diagnostic diag, String s)