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