mirror of https://github.com/apache/poi.git
use indexOf(char) instead of indexOf(String) where possible; replace one more StringBuffer with StringBuilder - bug 63805
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1874262 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
09d55c7832
commit
842e71a3d7
|
@ -346,7 +346,7 @@ public class ToCSV {
|
||||||
// Simply replace the .xls or .xlsx file extension with .csv
|
// Simply replace the .xls or .xlsx file extension with .csv
|
||||||
destinationFilename = excelFile.getName();
|
destinationFilename = excelFile.getName();
|
||||||
destinationFilename = destinationFilename.substring(
|
destinationFilename = destinationFilename.substring(
|
||||||
0, destinationFilename.lastIndexOf(".")) +
|
0, destinationFilename.lastIndexOf('.')) +
|
||||||
ToCSV.CSV_FILE_EXTENSION;
|
ToCSV.CSV_FILE_EXTENSION;
|
||||||
|
|
||||||
// Save the CSV file away using the newly constricted file name
|
// Save the CSV file away using the newly constricted file name
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class CellTextFormatter extends CellFormatter {
|
||||||
textPos = new int[numPlaces[0]];
|
textPos = new int[numPlaces[0]];
|
||||||
int pos = desc.length() - 1;
|
int pos = desc.length() - 1;
|
||||||
for (int i = 0; i < textPos.length; i++) {
|
for (int i = 0; i < textPos.length; i++) {
|
||||||
textPos[i] = desc.lastIndexOf("\u0000", pos);
|
textPos[i] = desc.lastIndexOf('\u0000', pos);
|
||||||
pos = textPos[i] - 1;
|
pos = textPos[i] - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class CellRangeAddress extends CellRangeAddressBase {
|
||||||
* column range (e.g. "C:F")
|
* column range (e.g. "C:F")
|
||||||
*/
|
*/
|
||||||
public static CellRangeAddress valueOf(String ref) {
|
public static CellRangeAddress valueOf(String ref) {
|
||||||
int sep = ref.indexOf(":");
|
int sep = ref.indexOf(':');
|
||||||
CellReference a;
|
CellReference a;
|
||||||
CellReference b;
|
CellReference b;
|
||||||
if (sep == -1) {
|
if (sep == -1) {
|
||||||
|
|
|
@ -111,7 +111,7 @@ public final class ContentTypes {
|
||||||
public static final String EXTENSION_XML = "xml";
|
public static final String EXTENSION_XML = "xml";
|
||||||
|
|
||||||
public static String getContentTypeFromFileExtension(String filename) {
|
public static String getContentTypeFromFileExtension(String filename) {
|
||||||
String extension = filename.substring(filename.lastIndexOf(".") + 1)
|
String extension = filename.substring(filename.lastIndexOf('.') + 1)
|
||||||
.toLowerCase(Locale.ROOT);
|
.toLowerCase(Locale.ROOT);
|
||||||
if (extension.equals(EXTENSION_JPG_1)
|
if (extension.equals(EXTENSION_JPG_1)
|
||||||
|| extension.equals(EXTENSION_JPG_2))
|
|| extension.equals(EXTENSION_JPG_2))
|
||||||
|
|
|
@ -517,7 +517,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
|
||||||
+ filename);
|
+ filename);
|
||||||
} catch (InvalidFormatException e) {
|
} catch (InvalidFormatException e) {
|
||||||
String partName = "/docProps/thumbnail" +
|
String partName = "/docProps/thumbnail" +
|
||||||
filename.substring(filename.lastIndexOf(".") + 1);
|
filename.substring(filename.lastIndexOf('.') + 1);
|
||||||
try {
|
try {
|
||||||
thumbnailPartName = PackagingURIHelper.createPartName(partName);
|
thumbnailPartName = PackagingURIHelper.createPartName(partName);
|
||||||
} catch (InvalidFormatException e2) {
|
} catch (InvalidFormatException e2) {
|
||||||
|
|
|
@ -422,7 +422,7 @@ public final class PackagePartName implements Comparable<PackagePartName> {
|
||||||
public String getExtension() {
|
public String getExtension() {
|
||||||
String fragment = this.partNameURI.getPath();
|
String fragment = this.partNameURI.getPath();
|
||||||
if (fragment.length() > 0) {
|
if (fragment.length() > 0) {
|
||||||
int i = fragment.lastIndexOf(".");
|
int i = fragment.lastIndexOf('.');
|
||||||
if (i > -1) {
|
if (i > -1) {
|
||||||
return fragment.substring(i + 1);
|
return fragment.substring(i + 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ public final class PackagingURIHelper {
|
||||||
*/
|
*/
|
||||||
public static String getFilenameWithoutExtension(URI uri) {
|
public static String getFilenameWithoutExtension(URI uri) {
|
||||||
String filename = getFilename(uri);
|
String filename = getFilename(uri);
|
||||||
int dotIndex = filename.lastIndexOf(".");
|
int dotIndex = filename.lastIndexOf('.');
|
||||||
if (dotIndex == -1)
|
if (dotIndex == -1)
|
||||||
return filename;
|
return filename;
|
||||||
return filename.substring(0, dotIndex);
|
return filename.substring(0, dotIndex);
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class Util {
|
||||||
public static int countLines(String str) {
|
public static int countLines(String str) {
|
||||||
int lines = 1;
|
int lines = 1;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while ((pos = str.indexOf("\n", pos) + 1) != 0) {
|
while ((pos = str.indexOf('\n', pos) + 1) != 0) {
|
||||||
lines++;
|
lines++;
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
|
|
|
@ -916,7 +916,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||||
assertEquals(text, cell.getStringCellValue());
|
assertEquals(text, cell.getStringCellValue());
|
||||||
|
|
||||||
// Now add a 2nd, and check again
|
// Now add a 2nd, and check again
|
||||||
int fontAt = text.indexOf("\n", 6);
|
int fontAt = text.indexOf('\n', 6);
|
||||||
cell.getRichStringCellValue().applyFont(10, fontAt + 1, font2);
|
cell.getRichStringCellValue().applyFont(10, fontAt + 1, font2);
|
||||||
assertEquals(text, cell.getStringCellValue());
|
assertEquals(text, cell.getStringCellValue());
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public final class TestBug46610 {
|
||||||
|
|
||||||
private static String runExtract(String sampleName) throws Exception {
|
private static String runExtract(String sampleName) throws Exception {
|
||||||
HWPFDocument doc = HWPFTestDataSamples.openSampleFile(sampleName);
|
HWPFDocument doc = HWPFTestDataSamples.openSampleFile(sampleName);
|
||||||
StringBuffer out = new StringBuffer();
|
StringBuilder out = new StringBuilder();
|
||||||
|
|
||||||
Range globalRange = doc.getRange();
|
Range globalRange = doc.getRange();
|
||||||
for (int i = 0; i < globalRange.numParagraphs(); i++) {
|
for (int i = 0; i < globalRange.numParagraphs(); i++) {
|
||||||
|
|
Loading…
Reference in New Issue