Index: XMLOutputter.java =================================================================== RCS file: /home/cvspublic/jdom-wip/src/java/org/jdom/output/XMLOutputter.java,v retrieving revision 1.5 diff -c -r1.5 XMLOutputter.java *** XMLOutputter.java 2001/11/02 19:30:42 1.5 --- XMLOutputter.java 2001/11/25 01:10:03 *************** *** 487,494 **** enc = "UTF8"; } ! Writer writer = new OutputStreamWriter ! (new BufferedOutputStream(out), enc); return writer; } --- 487,495 ---- enc = "UTF8"; } ! Writer writer = new BufferedWriter ! (new OutputStreamWriter ! (new BufferedOutputStream(out), enc)); return writer; } *************** *** 1371,1378 **** // two different URIs. For attributes on the same element // this is illegal; but as yet we don't throw an exception // if someone tries to do this - Set prefixes = new HashSet(); - Iterator itr = attributes.iterator(); while (itr.hasNext()) { Attribute attribute = (Attribute)itr.next(); --- 1372,1377 ---- *************** *** 1447,1459 **** * @return String with escaped content. */ protected String escapeAttributeEntities(String st) { ! StringBuffer buff = new StringBuffer(); ! char[] block = st.toCharArray(); String stEntity = null; int i, last; ! for (i=0, last=0; i < block.length; i++) { ! switch(block[i]) { case '<' : stEntity = "<"; break; --- 1446,1458 ---- * @return String with escaped content. */ protected String escapeAttributeEntities(String st) { ! StringBuffer buff = null; ! int length = st.length(); String stEntity = null; int i, last; ! for (i=0, last=0; i < length; i++) { ! switch(st.charAt(i)) { case '<' : stEntity = "<"; break; *************** *** 1475,1491 **** /* no-op */ ; } if (stEntity != null) { ! buff.append(block, last, i - last); buff.append(stEntity); stEntity = null; last = i + 1; } } - if(last < block.length) { - buff.append(block, last, i - last); - } ! return buff.toString(); } --- 1474,1501 ---- /* no-op */ ; } if (stEntity != null) { ! // An entity occurred, so we'll have to use the StringBuffer. ! if (buff == null) { ! buff = new StringBuffer(length + 20); // allow room for a few more entities ! } ! buff.append(st.substring(last, i)); buff.append(stEntity); stEntity = null; last = i + 1; } } ! // If there were any entities, return the escaped charactes that we ! // put in the StringBuffer. Otherwise, just return the unmodified ! // input string. ! if (buff != null) { ! if(last < length) { ! buff.append(st.substring(last, i)); ! } ! return buff.toString(); ! } else { ! return st; ! } } *************** *** 1501,1513 **** * @return String with escaped content. */ protected String escapeElementEntities(String st) { ! StringBuffer buff = new StringBuffer(); ! char[] block = st.toCharArray(); String stEntity = null; int i, last; ! for (i=0, last=0; i < block.length; i++) { ! switch(block[i]) { case '<' : stEntity = "<"; break; --- 1511,1523 ---- * @return String with escaped content. */ protected String escapeElementEntities(String st) { ! StringBuffer buff = null; ! int length = st.length(); String stEntity = null; int i, last; ! for (i=0, last=0; i < length; i++) { ! switch(st.charAt(i)) { case '<' : stEntity = "<"; break; *************** *** 1521,1537 **** /* no-op */ ; } if (stEntity != null) { ! buff.append(block, last, i - last); buff.append(stEntity); stEntity = null; last = i + 1; } } - if (last < block.length) { - buff.append(block, last, i - last); - } ! return buff.toString(); } /** --- 1531,1558 ---- /* no-op */ ; } if (stEntity != null) { ! // An entity occurred, so we'll have to use the StringBuffer. ! if (buff == null) { ! buff = new StringBuffer(length + 20); // allow room for a few more entities ! } ! buff.append(st.substring(last, i)); buff.append(stEntity); stEntity = null; last = i + 1; } } ! // If there were any entities, return the escaped charactes that we ! // put in the StringBuffer. Otherwise, just return the unmodified ! // input string. ! if (buff != null) { ! if (last < length) { ! buff.append(st.substring(last, i)); ! } ! return buff.toString(); ! } else { ! return st; ! } } /** *************** *** 1585,1593 **** // true if string is all whitespace (space, tab, cr, lf only) private boolean isWhitespace(String s) { ! char[] c = s.toCharArray(); ! for (int i=0; i