/** This method retrieves the AWT Color representation from the colour hash table
*
*/
- /* package */ static final Color getAWTColor(int index, Color deflt) {
+ /* package */ static Color getAWTColor(int index, Color deflt) {
HSSFColor clr = colors.get(index);
if (clr == null) {
return deflt;
return new Color(rgb[0],rgb[1],rgb[2]);
}
- /* package */ static final Color getAWTColor(HSSFColorPredefined clr) {
+ /* package */ static Color getAWTColor(HSSFColorPredefined clr) {
short[] rgb = clr.getTriplet();
return new Color(rgb[0],rgb[1],rgb[2]);
}
* @param dataSheet An instance of a class that implements the Sheet Sheet
* interface (HSSFSheet or XSSFSheet).
*/
- private static final void buildDataSheet(Sheet dataSheet) {
+ private static void buildDataSheet(Sheet dataSheet) {
Row row = null;
Cell cell = null;
Name name = null;
);
- private static final Set<String> unmodifiableHashSet(String... a) {
+ private static Set<String> unmodifiableHashSet(String... a) {
return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(a)));
}
// held on the first bit
if (b == getNeedRecalculation()) {
return;
- } else if (b) {
+ }
+
+ if (b) {
field_2_need_recalculation_and_id++;
} else {
field_2_need_recalculation_and_id--;
}
CellRangeAddressList cral = new CellRangeAddressList();
CellRangeAddress enclosingRange = null;
- for (int i = 0; i < cellRanges.length; i++) {
- CellRangeAddress cr = cellRanges[i];
+ for (CellRangeAddress cr : cellRanges) {
enclosingRange = CellRangeUtil.createEnclosingCellRange(cr, enclosingRange);
cral.addCellRangeAddress(cr);
}
}
protected abstract String getRecordName();
+
public String toString() {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
buffer.append("[").append(getRecordName()).append("]\n");
buffer.append("\t.numCF = ").append(getNumberOfConditionalFormats()).append("\n");
return _sstInfos;
}
- public static final int getNumberOfInfoRecsForStrings(int numStrings) {
+ public static int getNumberOfInfoRecsForStrings(int numStrings) {
int infoRecs = (numStrings / DEFAULT_BUCKET_SIZE);
if ((numStrings % DEFAULT_BUCKET_SIZE) != 0)
infoRecs ++;
*
* @return the size of the extsst record
*/
- public static final int getRecordSizeForStrings(int numStrings) {
+ public static int getRecordSizeForStrings(int numStrings) {
return 4 + 2 + getNumberOfInfoRecsForStrings(numStrings) * 8;
}
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndianOutput;
*
* @version 2.0-pre
*/
-
public final class GridsetRecord extends StandardRecord implements Cloneable {
public final static short sid = 0x82;
public short field_1_gridset_flag;
- public GridsetRecord()
- {
+ public GridsetRecord() {
}
public GridsetRecord(RecordInputStream in)
*
* @param gridset - <b>true</b> if no gridlines are print, <b>false</b> if gridlines are not print.
*/
-
- public void setGridset(boolean gridset)
- {
- if (gridset == true)
- {
+ public void setGridset(boolean gridset) {
+ if (gridset) {
field_1_gridset_flag = 1;
- }
- else
- {
+ } else {
field_1_gridset_flag = 0;
}
}
*
* @return gridset - true if gridlines are NOT printed, false if they are.
*/
-
public boolean getGridset()
{
return (field_1_gridset_flag == 1);
}
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
-
- buffer.append("[GRIDSET]\n");
- buffer.append(" .gridset = ").append(getGridset())
- .append("\n");
- buffer.append("[/GRIDSET]\n");
- return buffer.toString();
+ public String toString() {
+ return "[GRIDSET]\n" +
+ " .gridset = " + getGridset() +
+ "\n" +
+ "[/GRIDSET]\n";
}
public void serialize(LittleEndianOutput out) {
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndianOutput;
public final static short sid = 0x0083;
private short field_1_hcenter;
- public HCenterRecord()
- {
+ public HCenterRecord() {
}
public HCenterRecord(RecordInputStream in)
* set whether or not to horizonatally center this sheet.
* @param hc center - t/f
*/
-
- public void setHCenter(boolean hc)
- {
- if (hc == true)
- {
+ public void setHCenter(boolean hc) {
+ if (hc) {
field_1_hcenter = 1;
- }
- else
- {
+ } else {
field_1_hcenter = 0;
}
}
* get whether or not to horizonatally center this sheet.
* @return center - t/f
*/
-
public boolean getHCenter()
{
return (field_1_hcenter == 1);
}
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
-
- buffer.append("[HCENTER]\n");
- buffer.append(" .hcenter = ").append(getHCenter())
- .append("\n");
- buffer.append("[/HCENTER]\n");
- return buffer.toString();
+ public String toString() {
+ return "[HCENTER]\n" +
+ " .hcenter = " + getHCenter() +
+ "\n" +
+ "[/HCENTER]\n";
}
public void serialize(LittleEndianOutput out) {
public static final int OPT_COMPLEX = 0x0010;
public static final int OPT_BUILTIN = 0x0020;
public static final int OPT_BINDATA = 0x1000;
- public static final boolean isFormula(int optValue) {
+ public static boolean isFormula(int optValue) {
return (optValue & 0x0F) == 0;
}
}
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndianOutput;
* REFERENCE: PG 372 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
* @version 2.0-pre
*/
-
-public final class PrecisionRecord
- extends StandardRecord
-{
+public final class PrecisionRecord extends StandardRecord {
public final static short sid = 0xE;
public short field_1_precision;
- public PrecisionRecord()
- {
+ public PrecisionRecord() {
}
public PrecisionRecord(RecordInputStream in)
*
* @param fullprecision - or not
*/
-
- public void setFullPrecision(boolean fullprecision)
- {
- if (fullprecision == true)
- {
+ public void setFullPrecision(boolean fullprecision) {
+ if (fullprecision) {
field_1_precision = 1;
- }
- else
- {
+ } else {
field_1_precision = 0;
}
}
*
* @return fullprecision - or not
*/
-
public boolean getFullPrecision()
{
return (field_1_precision == 1);
}
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
-
- buffer.append("[PRECISION]\n");
- buffer.append(" .precision = ").append(getFullPrecision())
- .append("\n");
- buffer.append("[/PRECISION]\n");
- return buffer.toString();
+ public String toString() {
+ return "[PRECISION]\n" +
+ " .precision = " + getFullPrecision() +
+ "\n" +
+ "[/PRECISION]\n";
}
public void serialize(LittleEndianOutput out) {
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndianOutput;
* @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/
-
-public final class PrintGridlinesRecord
- extends StandardRecord
-{
+public final class PrintGridlinesRecord extends StandardRecord {
public final static short sid = 0x2b;
private short field_1_print_gridlines;
- public PrintGridlinesRecord()
- {
+ public PrintGridlinesRecord() {
}
public PrintGridlinesRecord(RecordInputStream in)
*
* @param pg make spreadsheet ugly - Y/N
*/
-
- public void setPrintGridlines(boolean pg)
- {
- if (pg == true)
- {
+ public void setPrintGridlines(boolean pg) {
+ if (pg) {
field_1_print_gridlines = 1;
- }
- else
- {
+ } else {
field_1_print_gridlines = 0;
}
}
*
* @return make spreadsheet ugly - Y/N
*/
-
public boolean getPrintGridlines()
{
return (field_1_print_gridlines == 1);
}
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
-
- buffer.append("[PRINTGRIDLINES]\n");
- buffer.append(" .printgridlines = ").append(getPrintGridlines())
- .append("\n");
- buffer.append("[/PRINTGRIDLINES]\n");
- return buffer.toString();
+ public String toString() {
+ return "[PRINTGRIDLINES]\n" +
+ " .printgridlines = " + getPrintGridlines() +
+ "\n" +
+ "[/PRINTGRIDLINES]\n";
}
public void serialize(LittleEndianOutput out) {
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndianOutput;
* @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/
-
-public final class PrintHeadersRecord
- extends StandardRecord
-{
+public final class PrintHeadersRecord extends StandardRecord {
public final static short sid = 0x2a;
private short field_1_print_headers;
- public PrintHeadersRecord()
- {
+ public PrintHeadersRecord() {
}
public PrintHeadersRecord(RecordInputStream in)
* set to print the headers - y/n
* @param p printheaders or not
*/
-
- public void setPrintHeaders(boolean p)
- {
- if (p == true)
- {
+ public void setPrintHeaders(boolean p) {
+ if (p) {
field_1_print_headers = 1;
- }
- else
- {
+ } else {
field_1_print_headers = 0;
}
}
* get whether to print the headers - y/n
* @return printheaders or not
*/
-
public boolean getPrintHeaders()
{
return (field_1_print_headers == 1);
}
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
-
- buffer.append("[PRINTHEADERS]\n");
- buffer.append(" .printheaders = ").append(getPrintHeaders())
- .append("\n");
- buffer.append("[/PRINTHEADERS]\n");
- return buffer.toString();
+ public String toString() {
+ return "[PRINTHEADERS]\n" +
+ " .printheaders = " + getPrintHeaders() +
+ "\n" +
+ "[/PRINTHEADERS]\n";
}
public void serialize(LittleEndianOutput out) {
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndianOutput;
* @author Jason Height (jheight at chariot dot net dot au)
* @version 2.0-pre
*/
-
public final class SaveRecalcRecord
extends StandardRecord
{
public final static short sid = 0x5f;
private short field_1_recalc;
- public SaveRecalcRecord()
- {
+ public SaveRecalcRecord() {
}
public SaveRecalcRecord(RecordInputStream in)
* set whether to recalculate formulas/etc before saving or not
* @param recalc - whether to recalculate or not
*/
-
- public void setRecalc(boolean recalc)
- {
- field_1_recalc = ( short ) ((recalc == true) ? 1
- : 0);
+ public void setRecalc(boolean recalc) {
+ field_1_recalc = ( short ) (recalc ? 1 : 0);
}
/**
* get whether to recalculate formulas/etc before saving or not
* @return recalc - whether to recalculate or not
*/
-
public boolean getRecalc()
{
return (field_1_recalc == 1);
}
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
-
- buffer.append("[SAVERECALC]\n");
- buffer.append(" .recalc = ").append(getRecalc())
- .append("\n");
- buffer.append("[/SAVERECALC]\n");
- return buffer.toString();
+ public String toString() {
+ return "[SAVERECALC]\n" +
+ " .recalc = " + getRecalc() +
+ "\n" +
+ "[/SAVERECALC]\n";
}
public void serialize(LittleEndianOutput out) {
*
* @return a Map containing all colours keyed by <tt>Integer</tt> excel-style palette indexes
*/
- public static final synchronized Map<Integer,HSSFColor> getIndexHash() {
+ public static synchronized Map<Integer,HSSFColor> getIndexHash() {
if(indexHash == null) {
indexHash = Collections.unmodifiableMap( createColorsByIndexMap() );
}
* the table, then call {@link #getIndexHash()} which returns a
* statically cached immutable map of colours.
*/
- public static final Map<Integer,HSSFColor> getMutableIndexHash() {
+ public static Map<Integer,HSSFColor> getMutableIndexHash() {
return createColorsByIndexMap();
}
}
// Create an algorithm runner.
- IDStarAlgorithm algorithm = null;
+ IDStarAlgorithm algorithm;
switch(algoType) {
case DGET: algorithm = new DGet(); break;
case DMIN: algorithm = new DMin(); break;
// Iterate over all DB entries.
final int height = db.getHeight();
for(int row = 1; row < height; ++row) {
- boolean matches = true;
+ boolean matches;
try {
matches = fullfillsConditions(db, row, cdb);
}
* @param nameValueEval Must not be a RefEval or AreaEval. Thus make sure resolveReference() is called on the value first!
* @param db Database
* @return Corresponding column number.
- * @throws EvaluationException
+ * @throws EvaluationException If it's not possible to turn all headings into strings.
*/
private static int getColumnForName(ValueEval nameValueEval, AreaEval db)
throws EvaluationException {
// Whether the condition column matches a database column, if not it's a
// special column that accepts formulas.
boolean columnCondition = true;
- ValueEval condition = null;
+ ValueEval condition;
// The condition to apply.
condition = resolveReference(cdb, conditionRow, column);
// No column found, it's again a special column that accepts formulas.
columnCondition = false;
- if(columnCondition == true) { // normal column condition
+ if(columnCondition) { // normal column condition
// Should not throw, checked above.
ValueEval value = resolveReference(db, row, getColumnForName(targetHeader, db));
if(!testNormalCondition(value, condition)) {
"D* function with formula conditions");
}
}
- if (matches == true) {
+ if (matches) {
return true;
}
}
} else {
return testNumericCondition(value, operator.smallerThan, number);
}
- }
- else if(conditionString.startsWith(">")) { // It's a >/>= condition.
+ } else if(conditionString.startsWith(">")) { // It's a >/>= condition.
String number = conditionString.substring(1);
if(number.startsWith("=")) {
number = number.substring(1);
} else {
return testNumericCondition(value, operator.largerThan, number);
}
- }
- else if(conditionString.startsWith("=")) { // It's a = condition.
+ } else if(conditionString.startsWith("=")) { // It's a = condition.
String stringOrNumber = conditionString.substring(1);
if(stringOrNumber.isEmpty()) {
return value instanceof BlankEval;
}
// Distinguish between string and number.
- boolean itsANumber = false;
+ boolean itsANumber;
try {
Integer.parseInt(stringOrNumber);
itsANumber = true;
return valueString.startsWith(conditionString);
}
}
- }
- else if(condition instanceof NumericValueEval) {
- double conditionNumber = ((NumericValueEval)condition).getNumberValue();
+ } else if(condition instanceof NumericValueEval) {
+ double conditionNumber = ((NumericValueEval) condition).getNumberValue();
Double valueNumber = getNumberFromValueEval(value);
- if(valueNumber == null) {
- return false;
- }
-
- return conditionNumber == valueNumber;
- }
- else if(condition instanceof ErrorEval) {
+ return valueNumber != null && conditionNumber == valueNumber;
+ } else if(condition instanceof ErrorEval) {
if(value instanceof ErrorEval) {
return ((ErrorEval)condition).getErrorCode() == ((ErrorEval)value).getErrorCode();
- }
- else {
+ } else {
return false;
}
- }
- else {
+ } else {
return false;
}
}
double value = ((NumericValueEval)valueEval).getNumberValue();
// Construct double from condition.
- double conditionValue = 0.0;
+ double conditionValue;
try {
conditionValue = Integer.parseInt(condition);
} catch (NumberFormatException e) { // It's not an int.
boolean result = m.matches();
String real = "";
- if (result == true) {
+ if (result) {
String realGroup = m.group(2);
boolean hasRealPart = realGroup.length() != 0;
boolean result = m.matches();
String imaginary = "";
- if (result == true) {
+ if (result) {
String imaginaryGroup = m.group(5);
boolean hasImaginaryPart = imaginaryGroup.equals("i") || imaginaryGroup.equals("j");
*/
public abstract class MatrixFunction implements Function{
- public static final void checkValues(double[] results) throws EvaluationException {
+ public static void checkValues(double[] results) throws EvaluationException {
for (int idx = 0; idx < results.length; idx++) {
if (Double.isNaN(results[idx]) || Double.isInfinite(results[idx])) {
throw new EvaluationException(ErrorEval.NUM_ERROR);
static final double TEN = 10.0;
static final double LOG_10_TO_BASE_e = Math.log(TEN);
- protected static final double singleOperandEvaluate(ValueEval arg, int srcRowIndex, int srcColumnIndex) throws EvaluationException {
+ protected static double singleOperandEvaluate(ValueEval arg, int srcRowIndex, int srcColumnIndex) throws EvaluationException {
if (arg == null) {
throw new IllegalArgumentException("arg must not be null");
}
/**
* @throws EvaluationException (#NUM!) if <tt>result</tt> is <tt>NaN</> or <tt>Infinity</tt>
*/
- public static final void checkValue(double result) throws EvaluationException {
+ public static void checkValue(double result) throws EvaluationException {
if (Double.isNaN(result) || Double.isInfinite(result)) {
throw new EvaluationException(ErrorEval.NUM_ERROR);
}
*
* @throws EvaluationException (#NUM!) if <tt>result</tt> is <tt>NaN</> or <tt>Infinity</tt>
*/
- static final void checkValue(double result) throws EvaluationException {
+ static void checkValue(double result) throws EvaluationException {
if (Double.isNaN(result) || Double.isInfinite(result)) {
throw new EvaluationException(ErrorEval.NUM_ERROR);
}
* @return <code>true</code> if the name specifies a standard worksheet function,
* <code>false</code> if the name should be assumed to be an external function.
*/
- public static final boolean isBuiltInFunctionName(String name) {
+ public static boolean isBuiltInFunctionName(String name) {
short ix = FunctionMetadataRegistry.lookupIndexByName(name.toUpperCase(Locale.ROOT));
return ix >= 0;
}
private BigDecimal divider;
private static final BigDecimal ONE_THOUSAND = new BigDecimal(1000);
private final DecimalFormat df;
- private static final String trimTrailingCommas(String s) {
+ private static String trimTrailingCommas(String s) {
return s.replaceAll(",+$", "");
}
}
}
- public static final boolean isValidCode(int errorCode) {
+ public static boolean isValidCode(int errorCode) {
for (FormulaError error : values()) {
if (error.getCode() == errorCode) return true;
if (error.getLongCode() == errorCode) return true;
*/
public Sheet build() {
Sheet sheet = (sheetName == null) ? workbook.createSheet() : workbook.createSheet(sheetName);
- Row currentRow = null;
- Cell currentCell = null;
+ Row currentRow;
+ Cell currentCell;
for (int rowIndex = 0; rowIndex < cells.length; ++rowIndex) {
Object[] rowArray = cells[rowIndex];
private void setCellValue(Cell cell, Object value) {
if (value == null || cell == null) {
return;
- } else if (value instanceof Number) {
+ }
+
+ if (value instanceof Number) {
double doubleValue = ((Number) value).doubleValue();
cell.setCellValue(doubleValue);
} else if (value instanceof Date) {
private boolean isFormulaDefinition(Object obj) {
if (obj instanceof String) {
String str = (String) obj;
- if (str.length() < 2) {
- return false;
- } else {
- return ((String) obj).charAt(0) == '=';
- }
+ return str.length() >= 2 && str.charAt(0) == '=';
} else {
return false;
}
private String getFormula(Object obj) {
return ((String) obj).substring(1);
}
-}
\ No newline at end of file
+}
* allowed to be null
* @return a valid string, "empty" if to short, "null" if null
*/
- public final static String createSafeSheetName(final String nameProposal) {
+ public static String createSafeSheetName(final String nameProposal) {
return createSafeSheetName(nameProposal, ' ');
}
* @param replaceChar the char to replace invalid characters.
* @return a valid string, "empty" if to short, "null" if null
*/
- public final static String createSafeSheetName(final String nameProposal, char replaceChar) {
+ public static String createSafeSheetName(final String nameProposal, char replaceChar) {
if (nameProposal == null) {
return "null";
}
}
public static XmlObject parse(File file, SchemaType type, XmlOptions options) throws XmlException, IOException {
- InputStream is = new FileInputStream(file);
- try {
+ try (InputStream is = new FileInputStream(file)) {
return parse(is, type, options);
- } finally {
- is.close();
}
}
public static XmlObject parse(URL file, SchemaType type, XmlOptions options) throws XmlException, IOException {
- InputStream is = file.openStream();
- try {
+ try (InputStream is = file.openStream()) {
return parse(is, type, options);
- } finally {
- is.close();
}
}
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.HashMap;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
* responses.
*/
public boolean hasOCSPs() {
- return false == this.ocsps.isEmpty();
+ return !this.ocsps.isEmpty();
}
/**
* @return <code>true</code> if this revocation data set holds CRLs.
*/
public boolean hasCRLs() {
- return false == this.crls.isEmpty();
+ return !this.crls.isEmpty();
}
/**
*/
public Path2D.Double getPath() {
for (GeometrySection geoSection : getGeometrySections()) {
- if (geoSection.getNoShow() == true)
+ if (geoSection.getNoShow())
continue;
return geoSection.getPath(this);
*/
public boolean hasGeometry() {
for (GeometrySection geoSection : getGeometrySections()) {
- if (geoSection.getNoShow() == false)
+ if (!geoSection.getNoShow())
return true;
}
return false;
String txt = ((CTRegularTextRun)_r).getT();
TextCap cap = getTextCap();
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for(int i = 0; i < txt.length(); i++) {
char c = txt.charAt(i);
if(c == '\t') {
public void setText(String text){
if (_r instanceof CTTextField) {
((CTTextField)_r).setT(text);
- } else if (_r instanceof CTTextLineBreak) {
- // ignored
- return;
- } else {
+ } else if (!(_r instanceof CTTextLineBreak)) {
((CTRegularTextRun)_r).setT(text);
}
}
* Public so clients can initialize the map on startup rather than lazily
* during evaluation if desired.
*/
- public static final synchronized void init() {
+ public static synchronized void init() {
if (! styleMap.isEmpty()) return;
/*
CTGraphicalObjectData data = graphicFrame.getGraphic().addNewGraphicData();
appendChartElement(data, relId);
chart.setGraphicFrame(this);
- return;
}
/**
// Get the hyperlinks
// TODO: make me optional/separated in private function
try {
- Iterator<PackageRelationship> relIter =
- getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation()).iterator();
- while (relIter.hasNext()) {
- PackageRelationship rel = relIter.next();
+ for (PackageRelationship rel : getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation())) {
hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
}
} catch (InvalidFormatException e) {
// TODO this needs to be migrated out into section code
if (type == HeaderFooterType.FIRST) {
CTSectPr ctSectPr = getSection();
- if (ctSectPr.isSetTitlePg() == false) {
+ if (!ctSectPr.isSetTitlePg()) {
CTOnOff titlePg = ctSectPr.addNewTitlePg();
titlePg.setVal(STOnOff.ON);
}
// TODO this needs to be migrated out into section code
if (type == HeaderFooterType.FIRST) {
CTSectPr ctSectPr = getSection();
- if (ctSectPr.isSetTitlePg() == false) {
+ if (!ctSectPr.isSetTitlePg()) {
CTOnOff titlePg = ctSectPr.addNewTitlePg();
titlePg.setVal(STOnOff.ON);
}
* parameter points to the {@link org.apache.xmlbeans.XmlCursor.TokenType#END}
* of the newly inserted paragraph.
*
- * @param cursor
+ * @param cursor The cursor-position where the new paragraph should be added.
* @return the {@link XWPFParagraph} object representing the newly inserted
* CTP object
*/
text.append(o);
addNewLine = false;
}
- if (addNewLine == true && i < bodyElements.size() - 1) {
+ if (addNewLine && i < bodyElements.size() - 1) {
text.append("\n");
}
}
}
}
- private static final <K,V> void assertNotContainsKey(Map<K,V> map, K key) {
+ private static <K,V> void assertNotContainsKey(Map<K,V> map, K key) {
assertFalse(map.containsKey(key));
}
- private static final <K,V> void assertNotContainsValue(Map<K,V> map, V value) {
+ private static <K,V> void assertNotContainsValue(Map<K,V> map, V value) {
assertFalse(map.containsValue(value));
}
/**
* Adds the given new Child Record at the given location,
* shuffling everything from there on down by one
- * @param newChild
- * @param position
+ *
+ * @param newChild The record to be added as child-record.
+ * @param position The index where the child should be added, 0-based
*/
private void addChildAt(Record newChild, int position) {
// Firstly, have the child added in at the end
/**
* Adds the given Child Record after the supplied record
- * @param newChild
- * @param after
+ * @param newChild The record to add as new child.
+ * @param after The record after which the given record should be added.
* @return the position of the added child within the list
*/
public int addChildAfter(Record newChild, Record after) {
/**
* Adds the given Child Record before the supplied record
- * @param newChild
- * @param before
+ * @param newChild The record to add as new child.
+ * @param before The record before which the given record should be added.
* @return the position of the added child within the list
*/
public int addChildBefore(Record newChild, Record before) {
mout.write(new byte[4]);
// Write out the children
- for(int i=0; i<children.length; i++) {
- children[i].writeOut(mout);
+ for (Record aChildren : children) {
+ aChildren.writeOut(mout);
}
// Update our header with the size
baos.write(new byte[] {0,0,0,0});
// Write out our children
- for(int i=0; i<children.length; i++) {
- children[i].writeOut(baos);
+ for (Record aChildren : children) {
+ aChildren.writeOut(baos);
}
// Grab the bytes back
/**
* Constructs a new, empty, Powerpoint document.
*/
- public static final HSLFSlideShowImpl create() {
+ public static HSLFSlideShowImpl create() {
InputStream is = HSLFSlideShowImpl.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt");
if (is == null) {
throw new HSLFException("Missing resource 'empty.ppt'");
* Constructor for reading MSG Files from the file system.
*
* @param filename Name of the file to read
- * @throws IOException
+ * @exception IOException on errors reading, or invalid data
*/
public MAPIMessage(String filename) throws IOException {
this(new File(filename));
* Constructor for reading MSG Files from the file system.
*
* @param file The file to read from
- * @throws IOException
+ * @exception IOException on errors reading, or invalid data
*/
public MAPIMessage(File file) throws IOException {
this(new NPOIFSFileSystem(file));
* in order to process. For lower memory use, use {@link #MAPIMessage(File)}
*
* @param in The InputStream to buffer then read from
- * @throws IOException
+ * @exception IOException on errors reading, or invalid data
*/
public MAPIMessage(InputStream in) throws IOException {
this(new NPOIFSFileSystem(in));
* Constructor for reading MSG Files from a POIFS filesystem
*
* @param fs Open POIFS FileSystem containing the message
- * @throws IOException
+ * @exception IOException on errors reading, or invalid data
*/
public MAPIMessage(NPOIFSFileSystem fs) throws IOException {
this(fs.getRoot());
* Constructor for reading MSG Files from a certain
* point within a POIFS filesystem
* @param poifsDir Directory containing the message
- * @throws IOException
+ * @exception IOException on errors reading, or invalid data
*/
public MAPIMessage(DirectoryNode poifsDir) throws IOException {
super(poifsDir);
/**
* Gets the plain text body of this Outlook Message
* @return The string representation of the 'text' version of the body, if available.
- * @throws ChunkNotFoundException
+ * @throws ChunkNotFoundException If the text-body chunk does not exist and
+ * returnNullOnMissingChunk is set
*/
public String getTextBody() throws ChunkNotFoundException {
return getStringFromChunk(mainChunks.getTextBodyChunk());
* Gets the html body of this Outlook Message, if this email
* contains a html version.
* @return The string representation of the 'html' version of the body, if available.
- * @throws ChunkNotFoundException
+ * @throws ChunkNotFoundException If the html-body chunk does not exist and
+ * returnNullOnMissingChunk is set
*/
public String getHtmlBody() throws ChunkNotFoundException {
if(mainChunks.getHtmlBodyChunkBinary() != null) {
* Gets the RTF Rich Message body of this Outlook Message, if this email
* contains a RTF (rich) version.
* @return The string representation of the 'RTF' version of the body, if available.
- * @throws ChunkNotFoundException
+ * @throws ChunkNotFoundException If the rtf-body chunk does not exist and
+ * returnNullOnMissingChunk is set
*/
public String getRtfBody() throws ChunkNotFoundException {
ByteChunk chunk = mainChunks.getRtfBodyChunk();
/**
* Gets the subject line of the Outlook Message
- * @throws ChunkNotFoundException
+ * @throws ChunkNotFoundException If the subject-chunk does not exist and
+ * returnNullOnMissingChunk is set
*/
public String getSubject() throws ChunkNotFoundException {
return getStringFromChunk(mainChunks.getSubjectChunk());
/**
* Gets the display value of the "FROM" line of the outlook message
* This is not the actual address that was sent from but the formated display of the user name.
- * @throws ChunkNotFoundException
+ * @throws ChunkNotFoundException If the from-chunk does not exist and
+ * returnNullOnMissingChunk is set
*/
public String getDisplayFrom() throws ChunkNotFoundException {
return getStringFromChunk(mainChunks.getDisplayFromChunk());
* This is not the actual list of addresses/values that will be
* sent to if you click Reply in the email - those are stored
* in {@link RecipientChunks}.
- * @throws ChunkNotFoundException
+ * @throws ChunkNotFoundException If the to-chunk does not exist and
+ * returnNullOnMissingChunk is set
*/
public String getDisplayTo() throws ChunkNotFoundException {
return getStringFromChunk(mainChunks.getDisplayToChunk());
* This is not the actual list of addresses/values that will be
* sent to if you click Reply in the email - those are stored
* in {@link RecipientChunks}.
- * @throws ChunkNotFoundException
+ * @throws ChunkNotFoundException If the cc-chunk does not exist and
+ * returnNullOnMissingChunk is set
*/
public String getDisplayCC() throws ChunkNotFoundException {
return getStringFromChunk(mainChunks.getDisplayCCChunk());
* sent to if you click Reply in the email - those are stored
* in {@link RecipientChunks}.
* This will only be present in sent emails, not received ones!
- * @throws ChunkNotFoundException
+ * @throws ChunkNotFoundException If the bcc-chunk does not exist and
+ * returnNullOnMissingChunk is set
*/
public String getDisplayBCC() throws ChunkNotFoundException {
return getStringFromChunk(mainChunks.getDisplayBCCChunk());
// Found it! Tell all the string chunks
String charset = m.group(1);
set7BitEncoding(charset);
- return;
}
}
} catch(ChunkNotFoundException e) {}
/**
* Gets the conversation topic of the parsed Outlook Message.
* This is the part of the subject line that is after the RE: and FWD:
- * @throws ChunkNotFoundException
+ * @throws ChunkNotFoundException If the conversation-topic chunk does not exist and
+ * returnNullOnMissingChunk is set
*/
public String getConversationTopic() throws ChunkNotFoundException {
return getStringFromChunk(mainChunks.getConversationTopic());
* item, note, or actual outlook Message)
* For emails the class will be IPM.Note
*
- * @throws ChunkNotFoundException
+ * @throws ChunkNotFoundException If the message-class chunk does not exist and
+ * returnNullOnMissingChunk is set
*/
public MESSAGE_CLASS getMessageClassEnum() throws ChunkNotFoundException {
String mc = getStringFromChunk(mainChunks.getMessageClass());
private String toSemicolonList(String[] l) {
- StringBuffer list = new StringBuffer();
+ StringBuilder list = new StringBuilder();
boolean first = true;
for(String s : l) {
conversationTopic = (StringChunk) chunk;
} else if (prop == MAPIProperty.SUBJECT) {
subjectChunk = (StringChunk) chunk;
- } else if (prop == MAPIProperty.ORIGINAL_SUBJECT) {
+ } /*else if (prop == MAPIProperty.ORIGINAL_SUBJECT) {
// TODO
- }
+ }*/
else if (prop == MAPIProperty.DISPLAY_TO) {
displayToChunk = (StringChunk) chunk;
if ( separatorMark + 1 < endMark )
processCharacters( wordDocument, currentTableLevel,
deadFieldValueSubrage, currentBlock );
-
- return;
}
public void processDocument( HWPFDocumentCore wordDocument )
}
}
- if ( processed == false )
+ if (!processed)
{
processParagraph( wordDocument, flow, currentTableLevel,
paragraph, AbstractWordUtils.EMPTY );
}
WordToFoUtils.compactInlines( block );
- return;
}
protected void processSection( HWPFDocumentCore wordDocument,
&& !AbstractWordUtils.equals( triplet.fontName,
blockProperies.pFontName ) )
{
- style.append( "font-family:" + triplet.fontName + ";" );
+ style.append("font-family:").append(triplet.fontName).append(";");
}
if ( characterRun.getFontSize() / 2 != blockProperies.pFontSize )
{
- style.append( "font-size:" + characterRun.getFontSize() / 2 + "pt;" );
+ style.append("font-size:").append(characterRun.getFontSize() / 2).append("pt;");
}
if ( triplet.bold )
{
}
WordToHtmlUtils.compactSpans( pElement );
- return;
}
@Override
* Testing for {@link HSSFEventFactory}
*/
public final class TestHSSFEventFactory extends TestCase {
- private static final InputStream openSample(String sampleFileName) {
+ private static InputStream openSample(String sampleFileName) {
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
}
fr0.setCachedResultBoolean(false);
fr1.setCachedResultBoolean(true);
- if (fr0.getCachedBooleanValue() == true && fr1.getCachedBooleanValue() == false) {
+ if (fr0.getCachedBooleanValue() && !fr1.getCachedBooleanValue()) {
throw new AssertionFailedError("Identified bug 46479c");
}
assertEquals(false, fr0.getCachedBooleanValue());
* checks
*/
public class TestNotOLE2Exception extends TestCase {
- private static final InputStream openXLSSampleStream(String sampleFileName) {
+ private static InputStream openXLSSampleStream(String sampleFileName) {
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
}
- private static final InputStream openDOCSampleStream(String sampleFileName) {
+ private static InputStream openDOCSampleStream(String sampleFileName) {
return POIDataSamples.getDocumentInstance().openResourceAsStream(sampleFileName);
}
*/
public class TestOfficeXMLException extends TestCase {
- private static final InputStream openSampleStream(String sampleFileName) {
+ private static InputStream openSampleStream(String sampleFileName) {
return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
}
public void testOOXMLException() throws IOException
public void testMissingInputCellH() throws IOException {
expectedEx.expect(UnsupportedOperationException.class);
expectedEx.expectMessage("Underlying cell 'A2' is missing in master sheet.");
-
- Workbook wb = createWorkbook();
- try {
- ForkedEvaluator fe = ForkedEvaluator.create(wb, null, null);
- // attempt update input at cell A2 (which is missing)
- fe.updateCell("Inputs", 1, 0, new NumberEval(4.0));
- } finally {
- wb.close();
+ try (Workbook wb = createWorkbook()) {
+ ForkedEvaluator fe = ForkedEvaluator.create(wb, null, null);
+ // attempt update input at cell A2 (which is missing)
+ fe.updateCell("Inputs", 1, 0, new NumberEval(4.0));
}
}
}
* @param sampleFileName the filename.
* @return the loaded workbook.
*/
- protected static final HSSFWorkbook loadWorkbook(String sampleFileName) {
+ protected static HSSFWorkbook loadWorkbook(String sampleFileName) {
return HSSFTestDataSamples.openSampleWorkbook(sampleFileName);
}
/**
* Creates a new Workbook and adds one sheet with the specified name
*/
- protected static final HSSFWorkbook createWorkbookWithSheet(String sheetName) {
+ protected static HSSFWorkbook createWorkbookWithSheet(String sheetName) {
HSSFWorkbook book = new HSSFWorkbook();
book.createSheet(sheetName);
return book;