mirror of https://github.com/apache/poi.git
Replace StringBuffer with StringBuilder
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1870600 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9a1b75aaac
commit
2a982f62ec
|
@ -40,7 +40,11 @@ import org.apache.poi.hssf.record.OldSheetRecord;
|
|||
import org.apache.poi.hssf.record.OldStringRecord;
|
||||
import org.apache.poi.hssf.record.RKRecord;
|
||||
import org.apache.poi.hssf.record.RecordInputStream;
|
||||
import org.apache.poi.poifs.filesystem.*;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||
import org.apache.poi.poifs.filesystem.DocumentNode;
|
||||
import org.apache.poi.poifs.filesystem.FileMagic;
|
||||
import org.apache.poi.poifs.filesystem.NotOLE2FileException;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
|
||||
|
@ -219,7 +223,7 @@ public class OldExcelExtractor implements Closeable {
|
|||
* @return the text contents of the file
|
||||
*/
|
||||
public String getText() {
|
||||
StringBuffer text = new StringBuffer();
|
||||
StringBuilder text = new StringBuilder();
|
||||
|
||||
// To track formats and encodings
|
||||
CodepageRecord codepage = null;
|
||||
|
@ -306,7 +310,7 @@ public class OldExcelExtractor implements Closeable {
|
|||
}
|
||||
}
|
||||
|
||||
protected void handleNumericCell(StringBuffer text, double value) {
|
||||
protected void handleNumericCell(StringBuilder text, double value) {
|
||||
// TODO Need to fetch / use format strings
|
||||
text.append(value);
|
||||
text.append('\n');
|
||||
|
|
|
@ -119,7 +119,7 @@ public abstract class PageBreakRecord extends StandardRecord {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer retval = new StringBuffer();
|
||||
StringBuilder retval = new StringBuilder();
|
||||
|
||||
String label;
|
||||
String mainLabel;
|
||||
|
|
|
@ -212,15 +212,8 @@ public final class HSSFPalette {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getHexString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getGnumericPart(_red));
|
||||
sb.append(':');
|
||||
sb.append(getGnumericPart(_green));
|
||||
sb.append(':');
|
||||
sb.append(getGnumericPart(_blue));
|
||||
return sb.toString();
|
||||
public String getHexString() {
|
||||
return getGnumericPart(_red) + ":" + getGnumericPart(_green) + ":" + getGnumericPart(_blue);
|
||||
}
|
||||
|
||||
private String getGnumericPart(byte color)
|
||||
|
|
|
@ -101,8 +101,8 @@ public class POIFSViewEngine
|
|||
private static String indent(final int indentLevel,
|
||||
final String indentString, final String data)
|
||||
{
|
||||
StringBuffer finalBuffer = new StringBuffer();
|
||||
StringBuffer indentPrefix = new StringBuffer();
|
||||
StringBuilder finalBuffer = new StringBuilder();
|
||||
StringBuilder indentPrefix = new StringBuilder();
|
||||
|
||||
for (int j = 0; j < indentLevel; j++)
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ public final class POIFSViewer {
|
|||
|
||||
private static void viewFile(String filename, boolean printName) {
|
||||
if (printName) {
|
||||
StringBuffer flowerbox = new StringBuffer();
|
||||
StringBuilder flowerbox = new StringBuilder();
|
||||
|
||||
flowerbox.append(".");
|
||||
for (int j = 0; j < filename.length(); j++) {
|
||||
|
|
|
@ -104,7 +104,7 @@ public class DocumentDescriptor
|
|||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer(40 * (path.length() + 1));
|
||||
StringBuilder buffer = new StringBuilder(40 * (path.length() + 1));
|
||||
|
||||
for (int j = 0; j < path.length(); j++)
|
||||
{
|
||||
|
|
|
@ -284,7 +284,7 @@ public class POIFSDocumentPath
|
|||
|
||||
public String toString()
|
||||
{
|
||||
final StringBuffer b = new StringBuffer();
|
||||
final StringBuilder b = new StringBuilder();
|
||||
final int l = length();
|
||||
|
||||
b.append(File.separatorChar);
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SheetIdentifier {
|
|||
public NameIdentifier getSheetIdentifier() {
|
||||
return _sheetIdentifier;
|
||||
}
|
||||
protected void asFormulaString(StringBuffer sb) {
|
||||
protected void asFormulaString(StringBuilder sb) {
|
||||
if (_bookName != null) {
|
||||
sb.append(" [").append(_sheetIdentifier.getName()).append("]");
|
||||
}
|
||||
|
@ -42,16 +42,11 @@ public class SheetIdentifier {
|
|||
}
|
||||
}
|
||||
public String asFormulaString() {
|
||||
StringBuffer sb = new StringBuffer(32);
|
||||
StringBuilder sb = new StringBuilder(32);
|
||||
asFormulaString(sb);
|
||||
return sb.toString();
|
||||
}
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer(64);
|
||||
sb.append(getClass().getName());
|
||||
sb.append(" [");
|
||||
asFormulaString(sb);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
return getClass().getName() + " [" + asFormulaString() + "]";
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ public class SheetRangeIdentifier extends SheetIdentifier {
|
|||
public NameIdentifier getLastSheetIdentifier() {
|
||||
return _lastSheetIdentifier;
|
||||
}
|
||||
protected void asFormulaString(StringBuffer sb) {
|
||||
protected void asFormulaString(StringBuilder sb) {
|
||||
super.asFormulaString(sb);
|
||||
sb.append(':');
|
||||
if (_lastSheetIdentifier.isQuoted()) {
|
||||
|
|
|
@ -165,12 +165,7 @@ public final class Countif extends Fixed2ArgFunction {
|
|||
}
|
||||
@Override
|
||||
public final String toString() {
|
||||
StringBuffer sb = new StringBuffer(64);
|
||||
sb.append(getClass().getName()).append(" [");
|
||||
sb.append(_operator.getRepresentation());
|
||||
sb.append(getValueText());
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
return getClass().getName() + " [" + _operator.getRepresentation() + getValueText() + "]";
|
||||
}
|
||||
protected abstract String getValueText();
|
||||
}
|
||||
|
@ -386,7 +381,7 @@ public final class Countif extends Fixed2ArgFunction {
|
|||
*/
|
||||
public static Pattern getWildCardPattern(String value) {
|
||||
int len = value.length();
|
||||
StringBuffer sb = new StringBuffer(len);
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
boolean hasWildCard = false;
|
||||
for(int i=0; i<len; i++) {
|
||||
char ch = value.charAt(i);
|
||||
|
|
|
@ -404,42 +404,42 @@ public class GenericRecordJsonWriter implements Closeable {
|
|||
printName(name);
|
||||
fw.write('"');
|
||||
|
||||
final Matcher m = ESC_CHARS.matcher(o.toString());
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
final String str = o.toString();
|
||||
final Matcher m = ESC_CHARS.matcher(str);
|
||||
int pos = 0;
|
||||
while (m.find()) {
|
||||
String repl;
|
||||
fw.append(str, pos, m.start());
|
||||
String match = m.group();
|
||||
switch (match) {
|
||||
case "\n":
|
||||
repl = "\\\\n";
|
||||
fw.write("\\\\n");
|
||||
break;
|
||||
case "\r":
|
||||
repl = "\\\\r";
|
||||
fw.write("\\\\r");
|
||||
break;
|
||||
case "\t":
|
||||
repl = "\\\\t";
|
||||
fw.write("\\\\t");
|
||||
break;
|
||||
case "\b":
|
||||
repl = "\\\\b";
|
||||
fw.write("\\\\b");
|
||||
break;
|
||||
case "\f":
|
||||
repl = "\\\\f";
|
||||
fw.write("\\\\f");
|
||||
break;
|
||||
case "\\":
|
||||
repl = "\\\\\\\\";
|
||||
fw.write("\\\\\\\\");
|
||||
break;
|
||||
case "\"":
|
||||
repl = "\\\\\"";
|
||||
fw.write("\\\\\"");
|
||||
break;
|
||||
default:
|
||||
repl = "\\\\u" + trimHex(match.charAt(0), 4);
|
||||
fw.write("\\\\u");
|
||||
fw.write(trimHex(match.charAt(0), 4));
|
||||
break;
|
||||
}
|
||||
m.appendReplacement(sb, repl);
|
||||
pos = m.end();
|
||||
}
|
||||
m.appendTail(sb);
|
||||
fw.write(sb.toString());
|
||||
|
||||
fw.append(str, pos, str.length());
|
||||
fw.write('"');
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -462,35 +462,37 @@ public class GenericRecordXmlWriter implements Closeable {
|
|||
|
||||
protected boolean printObject(String name, Object o) {
|
||||
openName(name+">");
|
||||
final Matcher m = ESC_CHARS.matcher(o.toString());
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
final String str = o.toString();
|
||||
final Matcher m = ESC_CHARS.matcher(str);
|
||||
int pos = 0;
|
||||
while (m.find()) {
|
||||
String repl;
|
||||
fw.write(str, pos, m.start());
|
||||
String match = m.group();
|
||||
switch (match) {
|
||||
case "<":
|
||||
repl = "<";
|
||||
fw.write("<");
|
||||
break;
|
||||
case ">":
|
||||
repl = ">";
|
||||
fw.write(">");
|
||||
break;
|
||||
case "&":
|
||||
repl = "&";
|
||||
fw.write("&");
|
||||
break;
|
||||
case "\'":
|
||||
repl = "'";
|
||||
fw.write("'");
|
||||
break;
|
||||
case "\"":
|
||||
repl = """;
|
||||
fw.write(""");
|
||||
break;
|
||||
default:
|
||||
repl = "&#x" + Long.toHexString(match.codePointAt(0)) + ";";
|
||||
fw.write("&#x");
|
||||
fw.write(Long.toHexString(match.codePointAt(0)));
|
||||
fw.write(";");
|
||||
break;
|
||||
}
|
||||
m.appendReplacement(sb, repl);
|
||||
pos = m.end();
|
||||
}
|
||||
m.appendTail(sb);
|
||||
fw.write(sb.toString());
|
||||
fw.append(str, pos, str.length());
|
||||
closeName(name+">");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -201,16 +201,6 @@ public final class TNEFProperty {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer str = new StringBuffer();
|
||||
str.append(name);
|
||||
str.append(" [");
|
||||
str.append(id);
|
||||
str.append("]");
|
||||
if(mapiProperty != null) {
|
||||
str.append(" (");
|
||||
str.append(mapiProperty);
|
||||
str.append(")");
|
||||
}
|
||||
return str.toString();
|
||||
return name + " [" + id + "]" + (mapiProperty == null ? "" : " (" + mapiProperty + ")");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public final class HPBFDumper {
|
|||
* two chars
|
||||
*/
|
||||
private String dumpBytes(byte[] data, int offset, int len) {
|
||||
StringBuffer ret = new StringBuffer();
|
||||
StringBuilder ret = new StringBuilder();
|
||||
for(int i=0; i<len; i++) {
|
||||
int j = i + offset;
|
||||
int b = data[j];
|
||||
|
|
|
@ -121,7 +121,7 @@ public final class QuickButCruddyTextExtractor {
|
|||
* Fetches the ALL the text of the powerpoint file, as a single string
|
||||
*/
|
||||
public String getTextAsString() {
|
||||
StringBuffer ret = new StringBuffer();
|
||||
StringBuilder ret = new StringBuilder();
|
||||
List<String> textV = getTextAsVector();
|
||||
for(String text : textV) {
|
||||
ret.append(text);
|
||||
|
|
|
@ -282,24 +282,23 @@ public final class AnimationInfoAtom extends RecordAtom {
|
|||
}
|
||||
|
||||
public String toString(){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("AnimationInfoAtom\n");
|
||||
buf.append("\tDimColor: " + getDimColor() + "\n");
|
||||
int mask = getMask();
|
||||
buf.append("\tMask: " + mask + ", 0x"+Integer.toHexString(mask)+"\n");
|
||||
buf.append("\t Reverse: " + getFlag(Reverse)+"\n");
|
||||
buf.append("\t Automatic: " + getFlag(Automatic)+"\n");
|
||||
buf.append("\t Sound: " + getFlag(Sound)+"\n");
|
||||
buf.append("\t StopSound: " + getFlag(StopSound)+"\n");
|
||||
buf.append("\t Play: " + getFlag(Play)+"\n");
|
||||
buf.append("\t Synchronous: " + getFlag(Synchronous)+"\n");
|
||||
buf.append("\t Hide: " + getFlag(Hide)+"\n");
|
||||
buf.append("\t AnimateBg: " + getFlag(AnimateBg)+"\n");
|
||||
buf.append("\tSoundIdRef: " + getSoundIdRef() + "\n");
|
||||
buf.append("\tDelayTime: " + getDelayTime() + "\n");
|
||||
buf.append("\tOrderID: " + getOrderID() + "\n");
|
||||
buf.append("\tSlideCount: " + getSlideCount() + "\n");
|
||||
return buf.toString();
|
||||
return
|
||||
"AnimationInfoAtom\n"+
|
||||
"\tDimColor: " + getDimColor() + "\n" +
|
||||
"\tMask: " + mask + ", 0x"+Integer.toHexString(mask)+"\n" +
|
||||
"\t Reverse: " + getFlag(Reverse)+"\n" +
|
||||
"\t Automatic: " + getFlag(Automatic)+"\n" +
|
||||
"\t Sound: " + getFlag(Sound)+"\n" +
|
||||
"\t StopSound: " + getFlag(StopSound)+"\n" +
|
||||
"\t Play: " + getFlag(Play)+"\n" +
|
||||
"\t Synchronous: " + getFlag(Synchronous)+"\n" +
|
||||
"\t Hide: " + getFlag(Hide)+"\n" +
|
||||
"\t AnimateBg: " + getFlag(AnimateBg)+"\n" +
|
||||
"\tSoundIdRef: " + getSoundIdRef() + "\n" +
|
||||
"\tDelayTime: " + getDelayTime() + "\n" +
|
||||
"\tOrderID: " + getOrderID() + "\n" +
|
||||
"\tSlideCount: " + getSlideCount() + "\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.io.OutputStream;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.poi.util.GenericRecordJsonWriter;
|
||||
import org.apache.poi.util.GenericRecordUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
@ -169,15 +170,8 @@ public final class ExMediaAtom extends RecordAtom
|
|||
setMask(mask);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("ExMediaAtom\n");
|
||||
buf.append("\tObjectId: " + getObjectId() + "\n");
|
||||
buf.append("\tMask : " + getMask() + "\n");
|
||||
buf.append("\t fLoop : " + getFlag(fLoop) + "\n");
|
||||
buf.append("\t fRewind : " + getFlag(fRewind) + "\n");
|
||||
buf.append("\t fNarration : " + getFlag(fNarration) + "\n");
|
||||
return buf.toString();
|
||||
public String toString() {
|
||||
return GenericRecordJsonWriter.marshal(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.OutputStream;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.poi.util.GenericRecordJsonWriter;
|
||||
import org.apache.poi.util.GenericRecordUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
@ -341,16 +342,8 @@ public class ExOleObjAtom extends RecordAtom {
|
|||
out.write(_data);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("ExOleObjAtom\n");
|
||||
buf.append(" drawAspect: " + getDrawAspect() + "\n");
|
||||
buf.append(" type: " + getType() + "\n");
|
||||
buf.append(" objID: " + getObjID() + "\n");
|
||||
buf.append(" subType: " + getSubType() + "\n");
|
||||
buf.append(" objStgDataRef: " + getObjStgDataRef() + "\n");
|
||||
buf.append(" options: " + getOptions() + "\n");
|
||||
return buf.toString();
|
||||
public String toString() {
|
||||
return GenericRecordJsonWriter.marshal(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -246,17 +246,16 @@ public final class HeadersFootersAtom extends RecordAtom {
|
|||
}
|
||||
|
||||
public String toString(){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("HeadersFootersAtom\n");
|
||||
buf.append("\tFormatId: " + getFormatId() + "\n");
|
||||
buf.append("\tMask : " + getMask() + "\n");
|
||||
buf.append("\t fHasDate : " + getFlag(fHasDate) + "\n");
|
||||
buf.append("\t fHasTodayDate : " + getFlag(fHasTodayDate) + "\n");
|
||||
buf.append("\t fHasUserDate : " + getFlag(fHasUserDate) + "\n");
|
||||
buf.append("\t fHasSlideNumber : " + getFlag(fHasSlideNumber) + "\n");
|
||||
buf.append("\t fHasHeader : " + getFlag(fHasHeader) + "\n");
|
||||
buf.append("\t fHasFooter : " + getFlag(fHasFooter) + "\n");
|
||||
return buf.toString();
|
||||
return
|
||||
"HeadersFootersAtom\n" +
|
||||
"\tFormatId: " + getFormatId() + "\n" +
|
||||
"\tMask : " + getMask() + "\n" +
|
||||
"\t fHasDate : " + getFlag(fHasDate) + "\n" +
|
||||
"\t fHasTodayDate : " + getFlag(fHasTodayDate) + "\n" +
|
||||
"\t fHasUserDate : " + getFlag(fHasUserDate) + "\n" +
|
||||
"\t fHasSlideNumber : " + getFlag(fHasSlideNumber) + "\n" +
|
||||
"\t fHasHeader : " + getFlag(fHasHeader) + "\n" +
|
||||
"\t fHasFooter : " + getFlag(fHasFooter) + "\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,8 +22,8 @@ import java.io.OutputStream;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.poi.util.GenericRecordJsonWriter;
|
||||
import org.apache.poi.util.GenericRecordUtil;
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
@ -114,10 +114,7 @@ public final class TextBytesAtom extends RecordAtom {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer out = new StringBuffer();
|
||||
out.append( "TextBytesAtom:\n");
|
||||
out.append( HexDump.dump(_text, 0, 0) );
|
||||
return out.toString();
|
||||
return GenericRecordJsonWriter.marshal(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,8 +22,8 @@ import java.io.OutputStream;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.poi.util.GenericRecordJsonWriter;
|
||||
import org.apache.poi.util.GenericRecordUtil;
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
@ -110,10 +110,7 @@ public final class TextCharsAtom extends RecordAtom {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer out = new StringBuffer();
|
||||
out.append( "TextCharsAtom:\n");
|
||||
out.append( HexDump.dump(_text, 0, 0) );
|
||||
return out.toString();
|
||||
return GenericRecordJsonWriter.marshal(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -81,7 +81,7 @@ public class ByteChunk extends Chunk {
|
|||
return "(Null Byte Array)";
|
||||
}
|
||||
|
||||
StringBuffer text = new StringBuffer();
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("Bytes len=").append(value.length);
|
||||
text.append(" [");
|
||||
|
||||
|
|
|
@ -1075,17 +1075,7 @@ public class MAPIProperty {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer str = new StringBuffer();
|
||||
str.append(name);
|
||||
str.append(" [");
|
||||
str.append(id);
|
||||
str.append("]");
|
||||
if (mapiProperty != null) {
|
||||
str.append(" (");
|
||||
str.append(mapiProperty);
|
||||
str.append(")");
|
||||
}
|
||||
return str.toString();
|
||||
return name + " [" + id + "]" + (mapiProperty == null ? "" : " (" + mapiProperty + ")");
|
||||
}
|
||||
|
||||
public static MAPIProperty get(int id) {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class OutlookTextExtactor extends POIOLE2TextExtractor {
|
|||
*/
|
||||
public String getText() {
|
||||
MAPIMessage msg = (MAPIMessage)document;
|
||||
StringBuffer s = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
// See if we can get a suitable encoding for any
|
||||
// non unicode text in the file
|
||||
|
@ -158,7 +158,7 @@ public class OutlookTextExtactor extends POIOLE2TextExtractor {
|
|||
* of emails, and does its best to return something like
|
||||
* "Nick <nick@example.com>; Jim <jim@example.com>"
|
||||
*/
|
||||
protected void handleEmails(StringBuffer s, String type, String displayText, StringsIterator emails) {
|
||||
protected void handleEmails(StringBuilder s, String type, String displayText, StringsIterator emails) {
|
||||
if(displayText == null || displayText.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,11 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.poi.hwpf.HWPFDocument;
|
||||
import org.apache.poi.hwpf.HWPFDocumentCore;
|
||||
|
@ -227,7 +231,7 @@ public class AbstractWordUtils
|
|||
public static String getBulletText( NumberingState numberingState,
|
||||
HWPFList list, char level )
|
||||
{
|
||||
StringBuffer bulletBuffer = new StringBuffer();
|
||||
StringBuilder bulletBuffer = new StringBuilder();
|
||||
char[] xst = list.getNumberText( level ).toCharArray();
|
||||
for ( char element : xst )
|
||||
{
|
||||
|
@ -240,17 +244,17 @@ public class AbstractWordUtils
|
|||
if ( !list.isStartAtOverriden( element )
|
||||
&& numberingState.levels.containsKey( key ) )
|
||||
{
|
||||
num = numberingState.levels.get( key ).intValue();
|
||||
num = numberingState.levels.get( key );
|
||||
if ( level == element )
|
||||
{
|
||||
num++;
|
||||
numberingState.levels.put( key, Integer.valueOf( num ) );
|
||||
numberingState.levels.put( key, num );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num = list.getStartAt( element );
|
||||
numberingState.levels.put( key, Integer.valueOf( num ) );
|
||||
numberingState.levels.put( key, num );
|
||||
}
|
||||
|
||||
if ( level == element )
|
||||
|
|
|
@ -20,10 +20,9 @@ package org.apache.poi.hwpf.extractor;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.poi.hwpf.converter.WordToTextConverter;
|
||||
|
||||
import org.apache.poi.extractor.POIOLE2TextExtractor;
|
||||
import org.apache.poi.hwpf.HWPFOldDocument;
|
||||
import org.apache.poi.hwpf.converter.WordToTextConverter;
|
||||
import org.apache.poi.hwpf.usermodel.Range;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
@ -123,7 +122,7 @@ public final class Word6Extractor extends POIOLE2TextExtractor {
|
|||
catch ( Exception exc )
|
||||
{
|
||||
// fall-back
|
||||
StringBuffer text = new StringBuffer();
|
||||
StringBuilder text = new StringBuilder();
|
||||
|
||||
for ( String t : getParagraphText() )
|
||||
{
|
||||
|
|
|
@ -159,7 +159,7 @@ public final class WordExtractor extends POIOLE2TextExtractor {
|
|||
/**
|
||||
* Add the header/footer text, if it's not empty
|
||||
*/
|
||||
private void appendHeaderFooter( String text, StringBuffer out ) {
|
||||
private void appendHeaderFooter( String text, StringBuilder out ) {
|
||||
if ( text == null || text.length() == 0 )
|
||||
return;
|
||||
|
||||
|
@ -186,7 +186,7 @@ public final class WordExtractor extends POIOLE2TextExtractor {
|
|||
public String getHeaderText() {
|
||||
HeaderStories hs = new HeaderStories( doc );
|
||||
|
||||
StringBuffer ret = new StringBuffer();
|
||||
StringBuilder ret = new StringBuilder();
|
||||
if ( hs.getFirstHeader() != null ) {
|
||||
appendHeaderFooter( hs.getFirstHeader(), ret );
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public final class WordExtractor extends POIOLE2TextExtractor {
|
|||
public String getFooterText() {
|
||||
HeaderStories hs = new HeaderStories( doc );
|
||||
|
||||
StringBuffer ret = new StringBuffer();
|
||||
StringBuilder ret = new StringBuilder();
|
||||
if ( hs.getFirstFooter() != null ) {
|
||||
appendHeaderFooter( hs.getFirstFooter(), ret );
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public final class EscherRecordHolder {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
if (escherRecords.size() == 0) {
|
||||
buffer.append("No Escher Records Decoded").append("\n");
|
||||
|
|
|
@ -87,25 +87,18 @@ public final class FSPATable
|
|||
return result.toArray(new FSPA[0]);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append( "[FPSA PLC size=" ).append( _byStart.size() )
|
||||
.append( "]\n" );
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append( "[FPSA PLC size=" ).append( _byStart.size() ).append( "]\n" );
|
||||
|
||||
for ( Map.Entry<Integer, GenericPropertyNode> entry : _byStart
|
||||
.entrySet() )
|
||||
{
|
||||
for ( Map.Entry<Integer, GenericPropertyNode> entry : _byStart.entrySet() ) {
|
||||
Integer i = entry.getKey();
|
||||
buf.append( " " ).append(i).append( " => \t" );
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
FSPA fspa = getFspaFromCp( i.intValue() );
|
||||
buf.append(fspa);
|
||||
}
|
||||
catch ( Exception exc )
|
||||
{
|
||||
} catch ( Exception exc ) {
|
||||
buf.append( exc.getMessage() );
|
||||
}
|
||||
buf.append( "\n" );
|
||||
|
|
|
@ -66,40 +66,22 @@ public abstract class FLDAbstractType
|
|||
data[0x1 + offset] = field_2_flt;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
buffer.append( "[FLD]\n" );
|
||||
|
||||
buffer.append( " .chHolder = " );
|
||||
buffer.append( " (" ).append( getChHolder() ).append( " )\n" );
|
||||
buffer.append( " .ch = " )
|
||||
.append( getCh() ).append( '\n' );
|
||||
buffer.append( " .reserved = " )
|
||||
.append( getReserved() ).append( '\n' );
|
||||
|
||||
buffer.append( " .flt = " );
|
||||
buffer.append( " (" ).append( getFlt() ).append( " )\n" );
|
||||
buffer.append( " .fDiffer = " )
|
||||
.append( isFDiffer() ).append( '\n' );
|
||||
buffer.append( " .fZombieEmbed = " )
|
||||
.append( isFZombieEmbed() ).append( '\n' );
|
||||
buffer.append( " .fResultDirty = " )
|
||||
.append( isFResultDirty() ).append( '\n' );
|
||||
buffer.append( " .fResultEdited = " )
|
||||
.append( isFResultEdited() ).append( '\n' );
|
||||
buffer.append( " .fLocked = " )
|
||||
.append( isFLocked() ).append( '\n' );
|
||||
buffer.append( " .fPrivateResult = " )
|
||||
.append( isFPrivateResult() ).append( '\n' );
|
||||
buffer.append( " .fNested = " )
|
||||
.append( isFNested() ).append( '\n' );
|
||||
buffer.append( " .fHasSep = " )
|
||||
.append( isFHasSep() ).append( '\n' );
|
||||
|
||||
buffer.append( "[/FLD]\n" );
|
||||
return buffer.toString();
|
||||
public String toString() {
|
||||
return
|
||||
"[FLD]\n" +
|
||||
" .chHolder = (" + getChHolder() + " )\n" +
|
||||
" .ch = " + getCh() + "\n" +
|
||||
" .reserved = " + getReserved() + "\n" +
|
||||
" .flt = (" + getFlt() + " )\n" +
|
||||
" .fDiffer = " + isFDiffer() + "\n" +
|
||||
" .fZombieEmbed = " + isFZombieEmbed() + "\n" +
|
||||
" .fResultDirty = " + isFResultDirty() + "\n" +
|
||||
" .fResultEdited = " + isFResultEdited() + "\n" +
|
||||
" .fLocked = " + isFLocked() + "\n" +
|
||||
" .fPrivateResult = " + isFPrivateResult() + "\n" +
|
||||
" .fNested = " + isFNested() + "\n" +
|
||||
" .fHasSep = " + isFHasSep() + "\n" +
|
||||
"[/FLD]\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,34 +64,19 @@ public abstract class TLPAbstractType
|
|||
data[0x2 + offset] = field_2_tlp_flags;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
buffer.append( "[TLP]\n" );
|
||||
|
||||
buffer.append( " .itl = " );
|
||||
buffer.append( " (" ).append( getItl() ).append( " )\n" );
|
||||
|
||||
buffer.append( " .tlp_flags = " );
|
||||
buffer.append( " (" ).append( getTlp_flags() ).append( " )\n" );
|
||||
buffer.append( " .fBorders = " )
|
||||
.append( isFBorders() ).append( '\n' );
|
||||
buffer.append( " .fShading = " )
|
||||
.append( isFShading() ).append( '\n' );
|
||||
buffer.append( " .fFont = " )
|
||||
.append( isFFont() ).append( '\n' );
|
||||
buffer.append( " .fColor = " )
|
||||
.append( isFColor() ).append( '\n' );
|
||||
buffer.append( " .fBestFit = " )
|
||||
.append( isFBestFit() ).append( '\n' );
|
||||
buffer.append( " .fHdrRows = " )
|
||||
.append( isFHdrRows() ).append( '\n' );
|
||||
buffer.append( " .fLastRow = " )
|
||||
.append( isFLastRow() ).append( '\n' );
|
||||
|
||||
buffer.append( "[/TLP]\n" );
|
||||
return buffer.toString();
|
||||
public String toString() {
|
||||
return
|
||||
"[TLP]\n" +
|
||||
" .itl = (" + getItl() + " )\n" +
|
||||
" .tlp_flags = (" + getTlp_flags() + " )\n" +
|
||||
" .fBorders = " + isFBorders() + "\n" +
|
||||
" .fShading = " + isFShading() + "\n" +
|
||||
" .fFont = " + isFFont() + "\n" +
|
||||
" .fColor = " + isFColor() + "\n" +
|
||||
" .fBestFit = " + isFBestFit() + "\n" +
|
||||
" .fHdrRows = " + isFHdrRows() + "\n" +
|
||||
" .fLastRow = " + isFLastRow() + "\n" +
|
||||
"[/TLP]\n";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -210,34 +210,15 @@ public final class BorderCode implements Cloneable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if ( isEmpty() )
|
||||
return "[BRC] EMPTY";
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
buffer.append( "[BRC]\n" );
|
||||
|
||||
buffer.append( " .dptLineWidth = " );
|
||||
buffer.append( " (" ).append( getLineWidth() ).append( " )\n" );
|
||||
|
||||
buffer.append( " .brcType = " );
|
||||
buffer.append( " (" ).append( getBorderType() ).append( " )\n" );
|
||||
|
||||
buffer.append( " .ico = " );
|
||||
buffer.append( " (" ).append( getColor() ).append( " )\n" );
|
||||
|
||||
buffer.append( " .dptSpace = " );
|
||||
buffer.append( " (" ).append( getSpace() ).append( " )\n" );
|
||||
|
||||
buffer.append( " .fShadow = " );
|
||||
buffer.append( " (" ).append( isShadow() ).append( " )\n" );
|
||||
|
||||
buffer.append( " .fFrame = " );
|
||||
buffer.append( " (" ).append( isFrame() ).append( " )\n" );
|
||||
|
||||
return buffer.toString();
|
||||
public String toString() {
|
||||
return isEmpty() ? "[BRC] EMPTY" :
|
||||
"[BRC]\n" +
|
||||
" .dptLineWidth = (" + getLineWidth() + " )\n" +
|
||||
" .brcType = (" + getBorderType() + " )\n" +
|
||||
" .ico = (" + getColor() + " )\n" +
|
||||
" .dptSpace = (" + getSpace() + " )\n" +
|
||||
" .fShadow = (" + isShadow() + " )\n" +
|
||||
" .fFrame = (" + isFrame() + " )\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import static org.junit.Assert.assertArrayEquals;
|
|||
import java.io.ByteArrayInputStream;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
|
||||
import org.apache.poi.ss.formula.ptg.Ptg;
|
||||
import org.apache.poi.ss.formula.ptg.RefPtg;
|
||||
|
@ -109,7 +108,7 @@ public final class TestTextObjectRecord extends TestCase {
|
|||
public void testLongRecords() {
|
||||
int[] lengths = {1024, 2048, 4096, 8192, 16384}; //test against strings of different length
|
||||
for (int length : lengths) {
|
||||
StringBuffer buff = new StringBuffer(length);
|
||||
StringBuilder buff = new StringBuilder(length);
|
||||
for (int j = 0; j < length; j++) {
|
||||
buff.append("x");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue