Parcourir la source

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
tags/before_ooxml_3rd_edition
Axel Howind il y a 4 ans
Parent
révision
842e71a3d7

+ 1
- 1
src/examples/src/org/apache/poi/ss/examples/ToCSV.java Voir le fichier

@@ -346,7 +346,7 @@ public class ToCSV {
// Simply replace the .xls or .xlsx file extension with .csv
destinationFilename = excelFile.getName();
destinationFilename = destinationFilename.substring(
0, destinationFilename.lastIndexOf(".")) +
0, destinationFilename.lastIndexOf('.')) +
ToCSV.CSV_FILE_EXTENSION;

// Save the CSV file away using the newly constricted file name

+ 1
- 1
src/java/org/apache/poi/ss/format/CellTextFormatter.java Voir le fichier

@@ -47,7 +47,7 @@ public class CellTextFormatter extends CellFormatter {
textPos = new int[numPlaces[0]];
int pos = desc.length() - 1;
for (int i = 0; i < textPos.length; i++) {
textPos[i] = desc.lastIndexOf("\u0000", pos);
textPos[i] = desc.lastIndexOf('\u0000', pos);
pos = textPos[i] - 1;
}
}

+ 1
- 1
src/java/org/apache/poi/ss/util/CellRangeAddress.java Voir le fichier

@@ -122,7 +122,7 @@ public class CellRangeAddress extends CellRangeAddressBase {
* column range (e.g. "C:F")
*/
public static CellRangeAddress valueOf(String ref) {
int sep = ref.indexOf(":");
int sep = ref.indexOf(':');
CellReference a;
CellReference b;
if (sep == -1) {

+ 1
- 1
src/ooxml/java/org/apache/poi/openxml4j/opc/ContentTypes.java Voir le fichier

@@ -111,7 +111,7 @@ public final class ContentTypes {
public static final String EXTENSION_XML = "xml";

public static String getContentTypeFromFileExtension(String filename) {
String extension = filename.substring(filename.lastIndexOf(".") + 1)
String extension = filename.substring(filename.lastIndexOf('.') + 1)
.toLowerCase(Locale.ROOT);
if (extension.equals(EXTENSION_JPG_1)
|| extension.equals(EXTENSION_JPG_2))

+ 1
- 1
src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java Voir le fichier

@@ -517,7 +517,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
+ filename);
} catch (InvalidFormatException e) {
String partName = "/docProps/thumbnail" +
filename.substring(filename.lastIndexOf(".") + 1);
filename.substring(filename.lastIndexOf('.') + 1);
try {
thumbnailPartName = PackagingURIHelper.createPartName(partName);
} catch (InvalidFormatException e2) {

+ 1
- 1
src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java Voir le fichier

@@ -422,7 +422,7 @@ public final class PackagePartName implements Comparable<PackagePartName> {
public String getExtension() {
String fragment = this.partNameURI.getPath();
if (fragment.length() > 0) {
int i = fragment.lastIndexOf(".");
int i = fragment.lastIndexOf('.');
if (i > -1) {
return fragment.substring(i + 1);
}

+ 1
- 1
src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java Voir le fichier

@@ -193,7 +193,7 @@ public final class PackagingURIHelper {
*/
public static String getFilenameWithoutExtension(URI uri) {
String filename = getFilename(uri);
int dotIndex = filename.lastIndexOf(".");
int dotIndex = filename.lastIndexOf('.');
if (dotIndex == -1)
return filename;
return filename.substring(0, dotIndex);

+ 1
- 1
src/ooxml/java/org/apache/poi/xdgf/util/Util.java Voir le fichier

@@ -22,7 +22,7 @@ public class Util {
public static int countLines(String str) {
int lines = 1;
int pos = 0;
while ((pos = str.indexOf("\n", pos) + 1) != 0) {
while ((pos = str.indexOf('\n', pos) + 1) != 0) {
lines++;
}
return lines;

+ 1
- 1
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Voir le fichier

@@ -916,7 +916,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertEquals(text, cell.getStringCellValue());

// 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);
assertEquals(text, cell.getStringCellValue());


+ 1
- 1
src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBug46610.java Voir le fichier

@@ -47,7 +47,7 @@ public final class TestBug46610 {

private static String runExtract(String sampleName) throws Exception {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile(sampleName);
StringBuffer out = new StringBuffer();
StringBuilder out = new StringBuilder();

Range globalRange = doc.getRange();
for (int i = 0; i < globalRange.numParagraphs(); i++) {

Chargement…
Annuler
Enregistrer