You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/07/19 21:00:38 UTC
svn commit: r1691843 [11/30] - in /poi/branches/common_sl: ./ .settings/
legal/ osgi/ osgi/src/ src/examples/src/org/apache/poi/hpsf/examples/
src/examples/src/org/apache/poi/hssf/usermodel/examples/
src/examples/src/org/apache/poi/ss/examples/ src/exa...
Copied: poi/branches/common_sl/src/java/org/apache/poi/sl/usermodel/TableShape.java (from r1691787, poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TableShape.java)
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/sl/usermodel/TableShape.java?p2=poi/branches/common_sl/src/java/org/apache/poi/sl/usermodel/TableShape.java&p1=poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TableShape.java&r1=1691787&r2=1691843&rev=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/scratchpad/src/org/apache/poi/sl/usermodel/TableShape.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/sl/usermodel/TableShape.java Sun Jul 19 19:00:32 2015
@@ -17,6 +17,6 @@
package org.apache.poi.sl.usermodel;
-public interface TableShape extends Shape {
+public interface TableShape extends Shape, PlaceableShape {
// to be defined ...
}
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/formula/FormulaParser.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/formula/FormulaParser.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/formula/FormulaParser.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/formula/FormulaParser.java Sun Jul 19 19:00:32 2015
@@ -617,16 +617,16 @@ public final class FormulaParser {
return new ParseNode(ptg);
}
- private static AreaReference createAreaRef(SimpleRangePart part1, SimpleRangePart part2) {
+ private AreaReference createAreaRef(SimpleRangePart part1, SimpleRangePart part2) {
if (!part1.isCompatibleForArea(part2)) {
throw new FormulaParseException("has incompatible parts: '"
+ part1.getRep() + "' and '" + part2.getRep() + "'.");
}
if (part1.isRow()) {
- return AreaReference.getWholeRow(part1.getRep(), part2.getRep());
+ return AreaReference.getWholeRow(_ssVersion, part1.getRep(), part2.getRep());
}
if (part1.isColumn()) {
- return AreaReference.getWholeColumn(part1.getRep(), part2.getRep());
+ return AreaReference.getWholeColumn(_ssVersion, part1.getRep(), part2.getRep());
}
return new AreaReference(part1.getCellReference(), part2.getCellReference());
}
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/formula/eval/FunctionEval.java Sun Jul 19 19:00:32 2015
@@ -27,8 +27,8 @@ import org.apache.poi.ss.formula.functio
import org.apache.poi.ss.formula.functions.*;
/**
- * @author Amol S. Deshmukh < amolweb at ya hoo dot com >
- * @author Johan Karlsteen - added Intercept and Slope
+ * Mappings from the Excel functions to our evaluation implementations
+ * (where avilable)
*/
public final class FunctionEval {
/**
@@ -99,7 +99,7 @@ public final class FunctionEval {
retval[39] = NumericFunction.MOD;
retval[43] = new DStarRunner(new DMin());
-
+
retval[46] = AggregateFunction.VAR;
retval[48] = TextFunction.TEXT;
@@ -154,6 +154,7 @@ public final class FunctionEval {
retval[124] = TextFunction.FIND;
+ retval[126] = LogicalFunction.ISERR;
retval[127] = LogicalFunction.ISTEXT;
retval[128] = LogicalFunction.ISNUMBER;
retval[129] = LogicalFunction.ISBLANK;
@@ -161,7 +162,7 @@ public final class FunctionEval {
retval[FunctionID.INDIRECT] = null; // Indirect.evaluate has different signature
- retval[162] = TextFunction.CLEAN; //Aniket Banerjee
+ retval[162] = TextFunction.CLEAN;
retval[167] = new IPMT();
retval[168] = new PPMT();
retval[169] = new Counta();
@@ -177,7 +178,7 @@ public final class FunctionEval {
retval[212] = NumericFunction.ROUNDUP;
retval[213] = NumericFunction.ROUNDDOWN;
retval[216] = new Rank();
- retval[219] = new Address(); //Aniket Banerjee
+ retval[219] = new Address();
retval[220] = new Days360();
retval[221] = new Today();
@@ -290,7 +291,7 @@ public final class FunctionEval {
throw new IllegalArgumentException(name + " is a function from the Excel Analysis Toolpack. " +
"Use AnalysisToolpack.registerFunction(String name, FreeRefFunction func) instead.");
}
-
+
throw new IllegalArgumentException("Unknown function: " + name);
}
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java Sun Jul 19 19:00:32 2015
@@ -57,7 +57,7 @@ public final class OperandResolver {
*/
public static ValueEval getSingleValue(ValueEval arg, int srcCellRow, int srcCellCol)
throws EvaluationException {
- ValueEval result;
+ final ValueEval result;
if (arg instanceof RefEval) {
result = chooseSingleElementFromRef((RefEval) arg);
} else if (arg instanceof AreaEval) {
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Countif.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Countif.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Countif.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Countif.java Sun Jul 19 19:00:32 2015
@@ -30,7 +30,7 @@ import org.apache.poi.ss.formula.eval.Re
import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate;
-import org.apache.poi.ss.usermodel.ErrorConstants;
+import org.apache.poi.ss.usermodel.FormulaError;
/**
* Implementation for the function COUNTIF
@@ -254,6 +254,7 @@ public final class Countif extends Fixed
// boolean values when the target(x) is a string
return false;
}
+ @SuppressWarnings("unused")
StringEval se = (StringEval)x;
Boolean val = parseBoolean(se.getStringValue());
if(val == null) {
@@ -286,7 +287,7 @@ public final class Countif extends Fixed
return evaluate(testValue - _value);
}
}
- private static final class ErrorMatcher extends MatcherBase {
+ public static final class ErrorMatcher extends MatcherBase {
private final int _value;
@@ -296,7 +297,7 @@ public final class Countif extends Fixed
}
@Override
protected String getValueText() {
- return ErrorConstants.getText(_value);
+ return FormulaError.forInt(_value).getString();
}
public boolean matches(ValueEval x) {
@@ -306,6 +307,10 @@ public final class Countif extends Fixed
}
return false;
}
+
+ public int getValue() {
+ return _value;
+ }
}
public static final class StringMatcher extends MatcherBase {
@@ -486,7 +491,7 @@ public final class Countif extends Fixed
*/
private static ValueEval evaluateCriteriaArg(ValueEval arg, int srcRowIndex, int srcColumnIndex) {
try {
- return OperandResolver.getSingleValue(arg, srcRowIndex, (short)srcColumnIndex);
+ return OperandResolver.getSingleValue(arg, srcRowIndex, srcColumnIndex);
} catch (EvaluationException e) {
return e.getErrorEval();
}
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/LogicalFunction.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/LogicalFunction.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/LogicalFunction.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/LogicalFunction.java Sun Jul 19 19:00:32 2015
@@ -90,6 +90,27 @@ public abstract class LogicalFunction ex
}
};
+ /**
+ * Implementation of Excel <tt>ISERR()</tt> function.<p/>
+ *
+ * <b>Syntax</b>:<br/>
+ * <b>ISERR</b>(<b>value</b>)<p/>
+ *
+ * <b>value</b> The value to be tested<p/>
+ *
+ * Returns the logical value <tt>TRUE</tt> if value refers to any error value except
+ * <tt>'#N/A'</tt>; otherwise, it returns <tt>FALSE</tt>.
+ */
+ public static final Function ISERR = new LogicalFunction() {
+ @Override
+ protected boolean evaluate(ValueEval arg) {
+ if (arg instanceof ErrorEval) {
+ return arg != ErrorEval.NA;
+ }
+ return false;
+ }
+ };
+
/**
* Implementation for Excel ISNA() function.<p/>
*
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Sumif.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Sumif.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Sumif.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Sumif.java Sun Jul 19 19:00:32 2015
@@ -69,6 +69,12 @@ public final class Sumif extends Var2or3
AreaEval aeSum) {
// TODO - junit to prove last arg must be srcColumnIndex and not srcRowIndex
I_MatchPredicate mp = Countif.createCriteriaPredicate(arg1, srcRowIndex, srcColumnIndex);
+
+ // handle empty cells
+ if(mp == null) {
+ return NumberEval.ZERO;
+ }
+
double result = sumMatchingCells(aeRange, mp, aeSum);
return new NumberEval(result);
}
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Sumifs.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Sumifs.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Sumifs.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/formula/functions/Sumifs.java Sun Jul 19 19:00:32 2015
@@ -20,8 +20,14 @@
package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext;
-import org.apache.poi.ss.formula.eval.*;
+import org.apache.poi.ss.formula.eval.AreaEval;
+import org.apache.poi.ss.formula.eval.ErrorEval;
+import org.apache.poi.ss.formula.eval.EvaluationException;
+import org.apache.poi.ss.formula.eval.NumberEval;
+import org.apache.poi.ss.formula.eval.RefEval;
+import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate;
+import org.apache.poi.ss.formula.functions.Countif.ErrorMatcher;
/**
* Implementation for the Excel function SUMIFS<p>
@@ -48,6 +54,7 @@ public final class Sumifs implements Fre
public static final FreeRefFunction instance = new Sumifs();
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
+ // need at least 3 arguments and need to have an odd number of arguments (sum-range plus x*(criteria_range, criteria))
if(args.length < 3 || args.length % 2 == 0) {
return ErrorEval.VALUE_INVALID;
}
@@ -60,10 +67,12 @@ public final class Sumifs implements Fre
I_MatchPredicate[] mp = new I_MatchPredicate[ae.length];
for(int i = 1, k=0; i < args.length; i += 2, k++){
ae[k] = convertRangeArg(args[i]);
+
mp[k] = Countif.createCriteriaPredicate(args[i+1], ec.getRowIndex(), ec.getColumnIndex());
}
validateCriteriaRanges(ae, sumRange);
+ validateCriteria(mp);
double result = sumMatchingCells(ae, mp, sumRange);
return new NumberEval(result);
@@ -76,7 +85,7 @@ public final class Sumifs implements Fre
* Verify that each <code>criteriaRanges</code> argument contains the same number of rows and columns
* as the <code>sumRange</code> argument
*
- * @throws EvaluationException if
+ * @throws EvaluationException if the ranges do not match.
*/
private void validateCriteriaRanges(AreaEval[] criteriaRanges, AreaEval sumRange) throws EvaluationException {
for(AreaEval r : criteriaRanges){
@@ -88,6 +97,22 @@ public final class Sumifs implements Fre
}
/**
+ * Verify that each <code>criteria</code> predicate is valid, i.e. not an error
+ *
+ * @throws EvaluationException if there are criteria which resulted in Errors.
+ */
+ private void validateCriteria(I_MatchPredicate[] criteria) throws EvaluationException {
+ for(I_MatchPredicate predicate : criteria) {
+
+ // check for errors in predicate and return immediately using this error code
+ if(predicate instanceof ErrorMatcher) {
+ throw new EvaluationException(ErrorEval.valueOf(((ErrorMatcher)predicate).getValue()));
+ }
+ }
+ }
+
+
+ /**
*
* @param ranges criteria ranges, each range must be of the same dimensions as <code>aeSum</code>
* @param predicates array of predicates, a predicate for each value in <code>ranges</code>
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/Area3DPxg.java Sun Jul 19 19:00:32 2015
@@ -31,7 +31,7 @@ import org.apache.poi.util.LittleEndianO
* <p>This is XSSF only, as it stores the sheet / book references
* in String form. The HSSF equivalent using indexes is {@link Area3DPtg}</p>
*/
-public final class Area3DPxg extends AreaPtgBase implements Pxg {
+public final class Area3DPxg extends AreaPtgBase implements Pxg3D {
private int externalWorkbookNumber = -1;
private String firstSheetName;
private String lastSheetName;
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/AreaPtgBase.java Sun Jul 19 19:00:32 2015
@@ -17,6 +17,7 @@
package org.apache.poi.ss.formula.ptg;
+import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.BitField;
@@ -256,7 +257,7 @@ public abstract class AreaPtgBase extend
CellReference topLeft = new CellReference(getFirstRow(),getFirstColumn(),!isFirstRowRelative(),!isFirstColRelative());
CellReference botRight = new CellReference(getLastRow(),getLastColumn(),!isLastRowRelative(),!isLastColRelative());
- if(AreaReference.isWholeColumnReference(topLeft, botRight)) {
+ if(AreaReference.isWholeColumnReference(SpreadsheetVersion.EXCEL97, topLeft, botRight)) {
return (new AreaReference(topLeft, botRight)).formatAsString();
}
return topLeft.formatAsString() + ":" + botRight.formatAsString();
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/formula/ptg/Ref3DPxg.java Sun Jul 19 19:00:32 2015
@@ -31,7 +31,7 @@ import org.apache.poi.util.LittleEndianO
* <p>This is XSSF only, as it stores the sheet / book references
* in String form. The HSSF equivalent using indexes is {@link Ref3DPtg}</p>
*/
-public final class Ref3DPxg extends RefPtgBase implements Pxg {
+public final class Ref3DPxg extends RefPtgBase implements Pxg3D {
private int externalWorkbookNumber = -1;
private String firstSheetName;
private String lastSheetName;
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/BorderFormatting.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/BorderFormatting.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/BorderFormatting.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/BorderFormatting.java Sun Jul 19 19:00:32 2015
@@ -20,8 +20,8 @@
package org.apache.poi.ss.usermodel;
/**
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
+ * High level representation for Border Formatting component
+ * of Conditional Formatting settings
*/
public interface BorderFormatting {
/** No border */
@@ -64,14 +64,19 @@ public interface BorderFormatting {
short getBorderTop();
short getBottomBorderColor();
+ Color getBottomBorderColorColor();
short getDiagonalBorderColor();
+ Color getDiagonalBorderColorColor();
short getLeftBorderColor();
+ Color getLeftBorderColorColor();
short getRightBorderColor();
+ Color getRightBorderColorColor();
short getTopBorderColor();
+ Color getTopBorderColorColor();
void setBorderBottom(short border);
@@ -104,12 +109,17 @@ public interface BorderFormatting {
void setBorderTop(short border);
void setBottomBorderColor(short color);
+ void setBottomBorderColor(Color color);
void setDiagonalBorderColor(short color);
+ void setDiagonalBorderColor(Color color);
void setLeftBorderColor(short color);
+ void setLeftBorderColor(Color color);
void setRightBorderColor(short color);
+ void setRightBorderColor(Color color);
void setTopBorderColor(short color);
+ void setTopBorderColor(Color color);
}
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ComparisonOperator.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ComparisonOperator.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ComparisonOperator.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ComparisonOperator.java Sun Jul 19 19:00:32 2015
@@ -24,9 +24,6 @@ package org.apache.poi.ss.usermodel;
* <p>
* For example, "highlight cells that begin with "M2" and contain "Mountain Gear".
* </p>
- *
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
*/
public final class ComparisonOperator {
public static final byte NO_COMPARISON = 0;
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ConditionalFormatting.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ConditionalFormatting.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ConditionalFormatting.java Sun Jul 19 19:00:32 2015
@@ -72,9 +72,6 @@ import org.apache.poi.ss.util.CellRangeA
* // Apply Conditional Formatting rule defined above to the regions
* sheet.addConditionalFormatting(regions, rule);
* </PRE>
- *
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
*/
public interface ConditionalFormatting {
@@ -85,17 +82,18 @@ public interface ConditionalFormatting {
/**
* Replaces an existing Conditional Formatting rule at position idx.
- * Excel allows to create up to 3 Conditional Formatting rules.
+ * Excel pre-2007 allows to create up to 3 Conditional Formatting rules,
+ * 2007 and later allow unlimited numbers.
* This method can be useful to modify existing Conditional Formatting rules.
*
- * @param idx position of the rule. Should be between 0 and 2.
+ * @param idx position of the rule. Should be between 0 and 2 for Excel before 2007, otherwise 0+.
* @param cfRule - Conditional Formatting rule
*/
void setRule(int idx, ConditionalFormattingRule cfRule);
/**
* Add a Conditional Formatting rule.
- * Excel allows to create up to 3 Conditional Formatting rules.
+ * Excel pre-2007 allows to create up to 3 Conditional Formatting rules.
*
* @param cfRule - Conditional Formatting rule
*/
@@ -110,6 +108,4 @@ public interface ConditionalFormatting {
* @return number of Conditional Formatting rules.
*/
int getNumberOfRules();
-
-
}
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/ConditionalFormattingRule.java Sun Jul 19 19:00:32 2015
@@ -19,24 +19,25 @@
package org.apache.poi.ss.usermodel;
+import static org.apache.poi.ss.usermodel.ConditionType.*;
+
/**
* Represents a description of a conditional formatting rule
- *
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
*/
public interface ConditionalFormattingRule {
/**
* This conditional formatting rule compares a cell value
* to a formula calculated result, using an operator
+ * @deprecated Use {@link ConditionType#CELL_VALUE_IS}
*/
- public static final byte CONDITION_TYPE_CELL_VALUE_IS = 1;
+ public static final byte CONDITION_TYPE_CELL_VALUE_IS = CELL_VALUE_IS.id;
/**
* This conditional formatting rule contains a formula to evaluate.
* When the formula result is true, the cell is highlighted.
+ * @deprecated Use {@link ConditionType#FORMULA}
*/
- public static final byte CONDITION_TYPE_FORMULA = 2;
+ public static final byte CONDITION_TYPE_FORMULA = FORMULA.id;
/**
* Create a new border formatting structure if it does not exist,
@@ -73,19 +74,32 @@ public interface ConditionalFormattingRu
PatternFormatting createPatternFormatting();
/**
- * @return - pattern formatting object if defined, <code>null</code> otherwise
+ * @return - pattern formatting object if defined, <code>null</code> otherwise
*/
PatternFormatting getPatternFormatting();
/**
+ * @return - icon / multi-state formatting object if defined, <code>null</code> otherwise
+ */
+ IconMultiStateFormatting getMultiStateFormatting();
+
+ /**
* Type of conditional formatting rule.
* <p>
- * MUST be either {@link #CONDITION_TYPE_CELL_VALUE_IS} or {@link #CONDITION_TYPE_FORMULA}
+ * MUST be one of the IDs of a {@link ConditionType}
* </p>
*
* @return the type of condition
+ * @deprecated Use {@link #getConditionTypeType()}
*/
byte getConditionType();
+
+ /**
+ * Type of conditional formatting rule.
+ *
+ * @return the type of condition
+ */
+ ConditionType getConditionTypeType();
/**
* The comparison function used when the type of conditional formatting is set to
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/DataFormatter.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/DataFormatter.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/DataFormatter.java Sun Jul 19 19:00:32 2015
@@ -20,6 +20,7 @@
==================================================================== */
package org.apache.poi.ss.usermodel;
+import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormatSymbols;
import java.text.DecimalFormat;
@@ -38,6 +39,8 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.poi.ss.util.NumberToTextConverter;
+
/**
* DataFormatter contains methods for formatting the value stored in an
@@ -731,7 +734,7 @@ public class DataFormatter {
* @see #formatCellValue(Cell)
*/
public String formatRawCellContents(double value, int formatIndex, String formatString) {
- return formatRawCellContents(value, formatIndex, formatString, false);
+ return formatRawCellContents(value, formatIndex, formatString, false);
}
/**
* Formats the given raw cell value, based on the supplied
@@ -744,28 +747,42 @@ public class DataFormatter {
if(DateUtil.isValidExcelDate(value)) {
Format dateFormat = getFormat(value, formatIndex, formatString);
if(dateFormat instanceof ExcelStyleDateFormatter) {
- // Hint about the raw excel value
- ((ExcelStyleDateFormatter)dateFormat).setDateToBeFormatted(value);
+ // Hint about the raw excel value
+ ((ExcelStyleDateFormatter)dateFormat).setDateToBeFormatted(value);
}
Date d = DateUtil.getJavaDate(value, use1904Windowing);
return performDateFormatting(d, dateFormat);
}
- // RK: Invalid dates are 255 #s.
- if (emulateCsv) {
- return invalidDateTimeString;
- }
+ // RK: Invalid dates are 255 #s.
+ if (emulateCsv) {
+ return invalidDateTimeString;
+ }
}
+
// else Number
- Format numberFormat = getFormat(value, formatIndex, formatString);
- if (numberFormat == null) {
- return String.valueOf(value);
- }
- // RK: This hack handles scientific notation by adding the missing + back.
- String result = numberFormat.format(new Double(value));
- if (result.contains("E") && !result.contains("E-")) {
- result = result.replaceFirst("E", "E+");
- }
- return result;
+ Format numberFormat = getFormat(value, formatIndex, formatString);
+ if (numberFormat == null) {
+ return String.valueOf(value);
+ }
+
+ // When formatting 'value', double to text to BigDecimal produces more
+ // accurate results than double to Double in JDK8 (as compared to
+ // previous versions). However, if the value contains E notation, this
+ // would expand the values, which we do not want, so revert to
+ // original method.
+ String result;
+ final String textValue = NumberToTextConverter.toText(value);
+ if (textValue.indexOf('E') > -1) {
+ result = numberFormat.format(new Double(value));
+ }
+ else {
+ result = numberFormat.format(new BigDecimal(textValue));
+ }
+ // Complete scientific notation by adding the missing +.
+ if (result.indexOf('E') > -1 && !result.contains("E-")) {
+ result = result.replaceFirst("E", "E+");
+ }
+ return result;
}
/**
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/DateUtil.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/DateUtil.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/DateUtil.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/DateUtil.java Sun Jul 19 19:00:32 2015
@@ -146,7 +146,7 @@ public class DateUtil {
* @return Java representation of the date, or null if date is not a valid Excel date
*/
public static Date getJavaDate(double date, TimeZone tz) {
- return getJavaDate(date, false, tz);
+ return getJavaDate(date, false, tz, false);
}
/**
* Given an Excel date with using 1900 date windowing, and
@@ -166,9 +166,9 @@ public class DateUtil {
* @see java.util.TimeZone
*/
public static Date getJavaDate(double date) {
- return getJavaDate(date, (TimeZone)null);
+ return getJavaDate(date, false, null, false);
}
-
+
/**
* Given an Excel date with either 1900 or 1904 date windowing,
* converts it to a java.util.Date.
@@ -185,7 +185,7 @@ public class DateUtil {
* @return Java representation of the date, or null if date is not a valid Excel date
*/
public static Date getJavaDate(double date, boolean use1904windowing, TimeZone tz) {
- return getJavaCalendar(date, use1904windowing, tz, false).getTime();
+ return getJavaDate(date, use1904windowing, tz, false);
}
/**
@@ -205,7 +205,8 @@ public class DateUtil {
* @return Java representation of the date, or null if date is not a valid Excel date
*/
public static Date getJavaDate(double date, boolean use1904windowing, TimeZone tz, boolean roundSeconds) {
- return getJavaCalendar(date, use1904windowing, tz, roundSeconds).getTime();
+ Calendar calendar = getJavaCalendar(date, use1904windowing, tz, roundSeconds);
+ return calendar == null ? null : calendar.getTime();
}
/**
@@ -228,10 +229,9 @@ public class DateUtil {
* @see java.util.TimeZone
*/
public static Date getJavaDate(double date, boolean use1904windowing) {
- return getJavaCalendar(date, use1904windowing, null, false).getTime();
+ return getJavaDate(date, use1904windowing, null, false);
}
-
public static void setCalendar(Calendar calendar, int wholeDays,
int millisecondsInDay, boolean use1904windowing, boolean roundSeconds) {
int startYear = 1900;
@@ -567,7 +567,7 @@ public class DateUtil {
private static int daysInPriorYears(int yr, boolean use1904windowing)
{
- if ((!use1904windowing && yr < 1900) || (use1904windowing && yr < 1900)) {
+ if ((!use1904windowing && yr < 1900) || (use1904windowing && yr < 1904)) {
throw new IllegalArgumentException("'year' must be 1900 or greater");
}
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/FontFormatting.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/FontFormatting.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/FontFormatting.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/FontFormatting.java Sun Jul 19 19:00:32 2015
@@ -22,9 +22,6 @@ package org.apache.poi.ss.usermodel;
/**
* High level representation for Font Formatting component
* of Conditional Formatting settings
- *
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
*/
public interface FontFormatting {
/** Escapement type - None */
@@ -66,15 +63,26 @@ public interface FontFormatting {
void setEscapementType(short escapementType);
/**
- * @return font color index
+ * @return font colour index, or 0 if not indexed (XSSF only)
*/
short getFontColorIndex();
-
/**
- * @param color font color index
+ * Sets the indexed colour to use
+ * @param color font colour index
*/
void setFontColorIndex(short color);
+
+ /**
+ * @return The colour of the font, or null if no colour applied
+ */
+ Color getFontColor();
+
+ /**
+ * Sets the colour to use
+ * @param color font colour to use
+ */
+ void setFontColor(Color color);
/**
* gets the height of the font in 1/20th point units
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/PatternFormatting.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/PatternFormatting.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/PatternFormatting.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/PatternFormatting.java Sun Jul 19 19:00:32 2015
@@ -63,14 +63,16 @@ public interface PatternFormatting {
public final static short LEAST_DOTS = 18 ;
short getFillBackgroundColor();
-
short getFillForegroundColor();
+ Color getFillBackgroundColorColor();
+ Color getFillForegroundColorColor();
short getFillPattern();
void setFillBackgroundColor(short bg);
-
void setFillForegroundColor(short fg);
+ void setFillBackgroundColor(Color bg);
+ void setFillForegroundColor(Color fg);
void setFillPattern(short fp);
}
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/Sheet.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/Sheet.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/Sheet.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/Sheet.java Sun Jul 19 19:00:32 2015
@@ -321,6 +321,13 @@ public interface Sheet extends Iterable<
public CellRangeAddress getMergedRegion(int index);
/**
+ * Returns the list of merged regions.
+ *
+ * @return the list of merged regions
+ */
+ public List<CellRangeAddress> getMergedRegions();
+
+ /**
* Returns an iterator of the physical rows
*
* @return an iterator of the PHYSICAL rows. Meaning the 3rd element may not
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/usermodel/SheetConditionalFormatting.java Sun Jul 19 19:00:32 2015
@@ -19,17 +19,15 @@
package org.apache.poi.ss.usermodel;
+import org.apache.poi.ss.usermodel.IconMultiStateFormatting.IconSet;
import org.apache.poi.ss.util.CellRangeAddress;
/**
* The 'Conditional Formatting' facet of <tt>Sheet</tt>
*
- * @author Dmitriy Kumshayev
- * @author Yegor Kozlov
* @since 3.8
*/
public interface SheetConditionalFormatting {
-
/**
* Add a new Conditional Formatting to the sheet.
*
@@ -58,7 +56,7 @@ public interface SheetConditionalFormatt
* Add a new Conditional Formatting set to the sheet.
*
* @param regions - list of rectangular regions to apply conditional formatting rules
- * @param cfRules - set of up to three conditional formatting rules
+ * @param cfRules - set of up to conditional formatting rules (max 3 for Excel pre-2007)
*
* @return index of the newly created Conditional Formatting object
*/
@@ -86,7 +84,7 @@ public interface SheetConditionalFormatt
* <p>
* The created conditional formatting rule compares a cell value
* to a formula calculated result, using the specified operator.
- * The type of the created condition is {@link ConditionalFormattingRule#CONDITION_TYPE_CELL_VALUE_IS}
+ * The type of the created condition is {@link ConditionType#CELL_VALUE_IS}
* </p>
*
* @param comparisonOperation - MUST be a constant value from
@@ -115,7 +113,7 @@ public interface SheetConditionalFormatt
* Create a conditional formatting rule that compares a cell value
* to a formula calculated result, using an operator *
* <p>
- * The type of the created condition is {@link ConditionalFormattingRule#CONDITION_TYPE_CELL_VALUE_IS}
+ * The type of the created condition is {@link ConditionType#CELL_VALUE_IS}
* </p>
*
* @param comparisonOperation MUST be a constant value from
@@ -132,13 +130,25 @@ public interface SheetConditionalFormatt
* When the formula result is true, the cell is highlighted.
*
* <p>
- * The type of the created format condition is {@link ConditionalFormattingRule#CONDITION_TYPE_FORMULA}
+ * The type of the created format condition is {@link ConditionType#FORMULA}
* </p>
* @param formula the formula to evaluate. MUST be a Boolean function.
*/
ConditionalFormattingRule createConditionalFormattingRule(String formula);
/**
+ * Create an Icon Set / Multi-State conditional formatting rule.
+ * <p>The thresholds for it will be created, but will be empty
+ * and require configuring with
+ * {@link ConditionalFormattingRule#getMultiStateFormatting()}
+ * then
+ * {@link IconMultiStateFormatting#getThresholds()}
+ */
+ ConditionalFormattingRule createConditionalFormattingRule(IconSet iconSet);
+
+ // TODO Support types beyond CELL_VALUE_IS and FORMULA and ICONs
+
+ /**
* Gets Conditional Formatting object at a particular index
*
* @param index 0-based index of the Conditional Formatting object to fetch
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/util/AreaReference.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/util/AreaReference.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/util/AreaReference.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/util/AreaReference.java Sun Jul 19 19:00:32 2015
@@ -35,13 +35,23 @@ public class AreaReference {
private final CellReference _firstCell;
private final CellReference _lastCell;
private final boolean _isSingleCell;
+ private SpreadsheetVersion _version;
/**
+ * @deprecated Prefer supplying a version.
+ */
+ @Deprecated
+ public AreaReference(String reference) {
+ this(reference, SpreadsheetVersion.EXCEL97);
+ }
+
+ /**
* Create an area ref from a string representation. Sheet names containing special characters should be
* delimited and escaped as per normal syntax rules for formulas.<br/>
* The area reference must be contiguous (i.e. represent a single rectangle, not a union of rectangles)
*/
- public AreaReference(String reference) {
+ public AreaReference(String reference, SpreadsheetVersion version) {
+ _version = version;
if(! isContiguous(reference)) {
throw new IllegalArgumentException(
"References passed to the AreaReference must be contiguous, " +
@@ -169,30 +179,34 @@ public class AreaReference {
return false;
}
- public static AreaReference getWholeRow(String start, String end) {
- return new AreaReference("$A" + start + ":$IV" + end);
+ public static AreaReference getWholeRow(SpreadsheetVersion version, String start, String end) {
+ return new AreaReference("$A" + start + ":$" + version.getLastColumnName() + end, version);
}
- public static AreaReference getWholeColumn(String start, String end) {
- return new AreaReference(start + "$1:" + end + "$65536");
+ public static AreaReference getWholeColumn(SpreadsheetVersion version, String start, String end) {
+ return new AreaReference(start + "$1:" + end + "$" + version.getMaxRows(), version);
}
/**
* Is the reference for a whole-column reference,
* such as C:C or D:G ?
*/
- public static boolean isWholeColumnReference(CellReference topLeft, CellReference botRight) {
+ public static boolean isWholeColumnReference(SpreadsheetVersion version, CellReference topLeft, CellReference botRight) {
+ if (null == version) {
+ version = SpreadsheetVersion.EXCEL97; // how the code used to behave.
+ }
+
// These are represented as something like
// C$1:C$65535 or D$1:F$0
// i.e. absolute from 1st row to 0th one
if(topLeft.getRow() == 0 && topLeft.isRowAbsolute() &&
- botRight.getRow() == SpreadsheetVersion.EXCEL97.getLastRowIndex() && botRight.isRowAbsolute()) {
+ botRight.getRow() == version.getLastRowIndex() && botRight.isRowAbsolute()) {
return true;
}
return false;
}
public boolean isWholeColumnReference() {
- return isWholeColumnReference(_firstCell, _lastCell);
+ return isWholeColumnReference(_version, _firstCell, _lastCell);
}
/**
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/util/CellRangeAddressBase.java Sun Jul 19 19:00:32 2015
@@ -24,8 +24,6 @@ import org.apache.poi.ss.SpreadsheetVers
* See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'<p/>
*
* Common subclass of 8-bit and 16-bit versions
- *
- * @author Josh Micich
*/
public abstract class CellRangeAddressBase {
Modified: poi/branches/common_sl/src/java/org/apache/poi/ss/util/SheetUtil.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/ss/util/SheetUtil.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/ss/util/SheetUtil.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/ss/util/SheetUtil.java Sun Jul 19 19:00:32 2015
@@ -93,10 +93,9 @@ public class SheetUtil {
* @param defaultCharWidth the width of a single character
* @param formatter formatter used to prepare the text to be measured
* @param useMergedCells whether to use merged cells
- * @return the width in pixels
+ * @return the width in pixels or -1 if cell is empty
*/
public static double getCellWidth(Cell cell, int defaultCharWidth, DataFormatter formatter, boolean useMergedCells) {
-
Sheet sheet = cell.getSheet();
Workbook wb = sheet.getWorkbook();
Row row = cell.getRow();
@@ -123,9 +122,6 @@ public class SheetUtil {
Font font = wb.getFontAt(style.getFontIndex());
- AttributedString str;
- TextLayout layout;
-
double width = -1;
if (cellType == Cell.CELL_TYPE_STRING) {
RichTextString rt = cell.getRichStringCellValue();
@@ -133,30 +129,14 @@ public class SheetUtil {
for (int i = 0; i < lines.length; i++) {
String txt = lines[i] + defaultChar;
- str = new AttributedString(txt);
+ AttributedString str = new AttributedString(txt);
copyAttributes(font, str, 0, txt.length());
if (rt.numFormattingRuns() > 0) {
// TODO: support rich text fragments
}
- layout = new TextLayout(str.getIterator(), fontRenderContext);
- if(style.getRotation() != 0){
- /*
- * Transform the text using a scale so that it's height is increased by a multiple of the leading,
- * and then rotate the text before computing the bounds. The scale results in some whitespace around
- * the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but
- * is added by the standard Excel autosize.
- */
- AffineTransform trans = new AffineTransform();
- trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
- trans.concatenate(
- AffineTransform.getScaleInstance(1, fontHeightMultiple)
- );
- width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention());
- } else {
- width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention());
- }
+ width = getCellWidth(defaultCharWidth, colspan, style, width, str);
}
} else {
String sval = null;
@@ -172,66 +152,49 @@ public class SheetUtil {
}
if(sval != null) {
String txt = sval + defaultChar;
- str = new AttributedString(txt);
+ AttributedString str = new AttributedString(txt);
copyAttributes(font, str, 0, txt.length());
- layout = new TextLayout(str.getIterator(), fontRenderContext);
- if(style.getRotation() != 0){
- /*
- * Transform the text using a scale so that it's height is increased by a multiple of the leading,
- * and then rotate the text before computing the bounds. The scale results in some whitespace around
- * the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but
- * is added by the standard Excel autosize.
- */
- AffineTransform trans = new AffineTransform();
- trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
- trans.concatenate(
- AffineTransform.getScaleInstance(1, fontHeightMultiple)
- );
- width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention());
- } else {
- width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention());
- }
+ width = getCellWidth(defaultCharWidth, colspan, style, width, str);
}
}
return width;
}
+ private static double getCellWidth(int defaultCharWidth, int colspan,
+ CellStyle style, double width, AttributedString str) {
+ TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
+ if(style.getRotation() != 0){
+ /*
+ * Transform the text using a scale so that it's height is increased by a multiple of the leading,
+ * and then rotate the text before computing the bounds. The scale results in some whitespace around
+ * the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but
+ * is added by the standard Excel autosize.
+ */
+ AffineTransform trans = new AffineTransform();
+ trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
+ trans.concatenate(
+ AffineTransform.getScaleInstance(1, fontHeightMultiple)
+ );
+ width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + style.getIndention());
+ } else {
+ width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + style.getIndention());
+ }
+ return width;
+ }
+
/**
* Compute width of a column and return the result
*
* @param sheet the sheet to calculate
* @param column 0-based index of the column
* @param useMergedCells whether to use merged cells
- * @return the width in pixels
+ * @return the width in pixels or -1 if all cells are empty
*/
- public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells){
- AttributedString str;
- TextLayout layout;
-
- Workbook wb = sheet.getWorkbook();
- DataFormatter formatter = new DataFormatter();
- Font defaultFont = wb.getFontAt((short) 0);
-
- str = new AttributedString(String.valueOf(defaultChar));
- copyAttributes(defaultFont, str, 0, 1);
- layout = new TextLayout(str.getIterator(), fontRenderContext);
- int defaultCharWidth = (int)layout.getAdvance();
-
- double width = -1;
- for (Row row : sheet) {
- Cell cell = row.getCell(column);
-
- if (cell == null) {
- continue;
- }
-
- double cellWidth = getCellWidth(cell, defaultCharWidth, formatter, useMergedCells);
- width = Math.max(width, cellWidth);
- }
- return width;
+ public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells) {
+ return getColumnWidth(sheet, column, useMergedCells, sheet.getFirstRowNum(), sheet.getLastRowNum());
}
-
+
/**
* Compute width of a column based on a subset of the rows and return the result
*
@@ -240,19 +203,16 @@ public class SheetUtil {
* @param useMergedCells whether to use merged cells
* @param firstRow 0-based index of the first row to consider (inclusive)
* @param lastRow 0-based index of the last row to consider (inclusive)
- * @return the width in pixels
+ * @return the width in pixels or -1 if cell is empty
*/
public static double getColumnWidth(Sheet sheet, int column, boolean useMergedCells, int firstRow, int lastRow){
- AttributedString str;
- TextLayout layout;
-
Workbook wb = sheet.getWorkbook();
DataFormatter formatter = new DataFormatter();
Font defaultFont = wb.getFontAt((short) 0);
- str = new AttributedString(String.valueOf(defaultChar));
+ AttributedString str = new AttributedString(String.valueOf(defaultChar));
copyAttributes(defaultFont, str, 0, 1);
- layout = new TextLayout(str.getIterator(), fontRenderContext);
+ TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
int defaultCharWidth = (int)layout.getAdvance();
double width = -1;
@@ -274,6 +234,30 @@ public class SheetUtil {
}
/**
+ * Check if the Fonts are installed correctly so that Java can compute the size of
+ * columns.
+ *
+ * If a Cell uses a Font which is not available on the operating system then Java may
+ * fail to return useful Font metrics and thus lead to an auto-computed size of 0.
+ *
+ * This method allows to check if computing the sizes for a given Font will succeed or not.
+ *
+ * @param font The Font that is used in the Cell
+ * @return true if computing the size for this Font will succeed, false otherwise
+ */
+ public static boolean canComputeColumnWidht(Font font) {
+ AttributedString str = new AttributedString("1");
+ copyAttributes(font, str, 0, "1".length());
+
+ TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
+ if(layout.getBounds().getWidth() > 0) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
* Copy text attributes from the supplied Font to Java2D AttributedString
*/
private static void copyAttributes(Font font, AttributedString str, int startIdx, int endIdx) {
Modified: poi/branches/common_sl/src/java/org/apache/poi/util/BitFieldFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/util/BitFieldFactory.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/util/BitFieldFactory.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/util/BitFieldFactory.java Sun Jul 19 19:00:32 2015
@@ -21,11 +21,8 @@ package org.apache.poi.util;
import java.util.*;
/**
- * Returns immutable Btfield instances.
- *
- * @author Jason Height (jheight at apache dot org)
+ * Returns immutable Bitfield instances.
*/
-
public class BitFieldFactory {
private static Map<Integer, BitField> instances = new HashMap<Integer, BitField>();
Modified: poi/branches/common_sl/src/java/org/apache/poi/util/CloseIgnoringInputStream.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/util/CloseIgnoringInputStream.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/util/CloseIgnoringInputStream.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/util/CloseIgnoringInputStream.java Sun Jul 19 19:00:32 2015
@@ -20,13 +20,11 @@ package org.apache.poi.util;
import java.io.FilterInputStream;
import java.io.InputStream;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-
/**
* A wrapper around an {@link InputStream}, which
* ignores close requests made to it.
*
- * Useful with {@link POIFSFileSystem}, where you want
+ * Useful with {@link org.apache.poi.poifs.filesystem.POIFSFileSystem}, where you want
* to control the close yourself.
*/
public class CloseIgnoringInputStream extends FilterInputStream {
Modified: poi/branches/common_sl/src/java/org/apache/poi/util/DrawingDump.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/util/DrawingDump.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/util/DrawingDump.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/util/DrawingDump.java Sun Jul 19 19:00:32 2015
@@ -18,12 +18,12 @@
package org.apache.poi.util;
+import java.io.File;
+import java.io.IOException;
+
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-
-import java.io.FileInputStream;
-import java.io.IOException;
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
/**
* Dump out the aggregated escher records
@@ -32,8 +32,8 @@ public class DrawingDump
{
public static void main( String[] args ) throws IOException
{
- POIFSFileSystem fs =
- new POIFSFileSystem(new FileInputStream(args[0]));
+ NPOIFSFileSystem fs =
+ new NPOIFSFileSystem(new File(args[0]));
HSSFWorkbook wb = new HSSFWorkbook(fs);
try {
System.out.println( "Drawing group:" );
Modified: poi/branches/common_sl/src/java/org/apache/poi/util/HexDump.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/util/HexDump.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/util/HexDump.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/util/HexDump.java Sun Jul 19 19:00:32 2015
@@ -245,12 +245,15 @@ public class HexDump {
{
StringBuffer retVal = new StringBuffer();
retVal.append('[');
- for(int x = 0; x < value.length; x++)
+ if (value != null && value.length > 0)
{
- if (x>0) {
- retVal.append(", ");
+ for(int x = 0; x < value.length; x++)
+ {
+ if (x>0) {
+ retVal.append(", ");
+ }
+ retVal.append(toHex(value[x]));
}
- retVal.append(toHex(value[x]));
}
retVal.append(']');
return retVal.toString();
Modified: poi/branches/common_sl/src/java/org/apache/poi/util/IOUtils.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/util/IOUtils.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/util/IOUtils.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/util/IOUtils.java Sun Jul 19 19:00:32 2015
@@ -22,120 +22,149 @@ import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PushbackInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
+import org.apache.poi.EmptyFileException;
+
public final class IOUtils {
+ private static final POILogger logger = POILogFactory.getLogger( IOUtils.class );
+
+ private IOUtils() {
+ // no instances of this class
+ }
+
+ /**
+ * Peeks at the first 8 bytes of the stream. Returns those bytes, but
+ * with the stream unaffected. Requires a stream that supports mark/reset,
+ * or a PushbackInputStream. If the stream has >0 but <8 bytes,
+ * remaining bytes will be zero.
+ * @throws EmptyFileException if the stream is empty
+ */
+ public static byte[] peekFirst8Bytes(InputStream stream) throws IOException, EmptyFileException {
+ // We want to peek at the first 8 bytes
+ stream.mark(8);
+
+ byte[] header = new byte[8];
+ int read = IOUtils.readFully(stream, header);
+
+ if (read < 1)
+ throw new EmptyFileException();
+
+ // Wind back those 8 bytes
+ if(stream instanceof PushbackInputStream) {
+ PushbackInputStream pin = (PushbackInputStream)stream;
+ pin.unread(header);
+ } else {
+ stream.reset();
+ }
+
+ return header;
+ }
+
+ /**
+ * Reads all the data from the input stream, and returns the bytes read.
+ */
+ public static byte[] toByteArray(InputStream stream) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ byte[] buffer = new byte[4096];
+ int read = 0;
+ while (read != -1) {
+ read = stream.read(buffer);
+ if (read > 0) {
+ baos.write(buffer, 0, read);
+ }
+ }
+
+ return baos.toByteArray();
+ }
+
+ /**
+ * Returns an array (that shouldn't be written to!) of the
+ * ByteBuffer. Will be of the requested length, or possibly
+ * longer if that's easier.
+ */
+ public static byte[] toByteArray(ByteBuffer buffer, int length) {
+ if(buffer.hasArray() && buffer.arrayOffset() == 0) {
+ // The backing array should work out fine for us
+ return buffer.array();
+ }
- private static final POILogger logger = POILogFactory
- .getLogger( IOUtils.class );
+ byte[] data = new byte[length];
+ buffer.get(data);
+ return data;
+ }
+
+ /**
+ * Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt>
+ */
+ public static int readFully(InputStream in, byte[] b) throws IOException {
+ return readFully(in, b, 0, b.length);
+ }
+
+ /**
+ * Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure
+ * that the entire len number of bytes is read.
+ * <p>
+ * If the end of file is reached before any bytes are read, returns -1. If
+ * the end of the file is reached after some bytes are read, returns the
+ * number of bytes read. If the end of the file isn't reached before len
+ * bytes have been read, will return len bytes.
+ */
+ public static int readFully(InputStream in, byte[] b, int off, int len) throws IOException {
+ int total = 0;
+ while (true) {
+ int got = in.read(b, off + total, len - total);
+ if (got < 0) {
+ return (total == 0) ? -1 : total;
+ }
+ total += got;
+ if (total == len) {
+ return total;
+ }
+ }
+ }
- private IOUtils() {
- // no instances of this class
- }
-
- /**
- * Reads all the data from the input stream, and returns the bytes read.
- */
- public static byte[] toByteArray(InputStream stream) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- byte[] buffer = new byte[4096];
- int read = 0;
- while (read != -1) {
- read = stream.read(buffer);
- if (read > 0) {
- baos.write(buffer, 0, read);
- }
- }
-
- return baos.toByteArray();
- }
-
- /**
- * Returns an array (that shouldn't be written to!) of the
- * ByteBuffer. Will be of the requested length, or possibly
- * longer if that's easier.
- */
- public static byte[] toByteArray(ByteBuffer buffer, int length) {
- if(buffer.hasArray() && buffer.arrayOffset() == 0) {
- // The backing array should work out fine for us
- return buffer.array();
- }
-
- byte[] data = new byte[length];
- buffer.get(data);
- return data;
- }
-
- /**
- * Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt>
- */
- public static int readFully(InputStream in, byte[] b) throws IOException {
- return readFully(in, b, 0, b.length);
- }
-
- /**
- * Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure
- * that the entire len number of bytes is read.
- * <p>
- * If the end of file is reached before any bytes are read, returns -1. If
- * the end of the file is reached after some bytes are read, returns the
- * number of bytes read. If the end of the file isn't reached before len
- * bytes have been read, will return len bytes.
- */
- public static int readFully(InputStream in, byte[] b, int off, int len) throws IOException {
- int total = 0;
- while (true) {
- int got = in.read(b, off + total, len - total);
- if (got < 0) {
- return (total == 0) ? -1 : total;
- }
- total += got;
- if (total == len) {
- return total;
- }
- }
- }
-
- /**
- * Same as the normal <tt>channel.read(b)</tt>, but tries to ensure
- * that the entire len number of bytes is read.
- * <p>
- * If the end of file is reached before any bytes are read, returns -1. If
- * the end of the file is reached after some bytes are read, returns the
- * number of bytes read. If the end of the file isn't reached before len
- * bytes have been read, will return len bytes.
- */
- public static int readFully(ReadableByteChannel channel, ByteBuffer b) throws IOException {
- int total = 0;
- while (true) {
- int got = channel.read(b);
- if (got < 0) {
- return (total == 0) ? -1 : total;
- }
- total += got;
- if (total == b.capacity() || b.position() == b.capacity()) {
- return total;
- }
- }
- }
-
- /**
- * Copies all the data from the given InputStream to the OutputStream. It
- * leaves both streams open, so you will still need to close them once done.
- */
- public static void copy(InputStream inp, OutputStream out) throws IOException {
- byte[] buff = new byte[4096];
- int count;
- while ((count = inp.read(buff)) != -1) {
- if (count > 0) {
- out.write(buff, 0, count);
- }
- }
- }
+ /**
+ * Same as the normal <tt>channel.read(b)</tt>, but tries to ensure
+ * that the entire len number of bytes is read.
+ * <p>
+ * If the end of file is reached before any bytes are read, returns -1. If
+ * the end of the file is reached after some bytes are read, returns the
+ * number of bytes read. If the end of the file isn't reached before len
+ * bytes have been read, will return len bytes.
+ */
+ public static int readFully(ReadableByteChannel channel, ByteBuffer b) throws IOException {
+ int total = 0;
+ while (true) {
+ int got = channel.read(b);
+ if (got < 0) {
+ return (total == 0) ? -1 : total;
+ }
+ total += got;
+ if (total == b.capacity() || b.position() == b.capacity()) {
+ return total;
+ }
+ }
+ }
+
+ /**
+ * Copies all the data from the given InputStream to the OutputStream. It
+ * leaves both streams open, so you will still need to close them once done.
+ */
+ public static void copy(InputStream inp, OutputStream out) throws IOException {
+ byte[] buff = new byte[4096];
+ int count;
+ while ((count = inp.read(buff)) != -1) {
+ if (count > 0) {
+ out.write(buff, 0, count);
+ }
+ }
+ }
public static long calculateChecksum(byte[] data) {
Checksum sum = new CRC32();
@@ -150,14 +179,10 @@ public final class IOUtils {
* @param closeable
* resource to close
*/
- public static void closeQuietly( final Closeable closeable )
- {
- try
- {
+ public static void closeQuietly( final Closeable closeable ) {
+ try {
closeable.close();
- }
- catch ( Exception exc )
- {
+ } catch ( Exception exc ) {
logger.log( POILogger.ERROR, "Unable to close resource: " + exc,
exc );
}
Modified: poi/branches/common_sl/src/java/org/apache/poi/util/NullLogger.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/java/org/apache/poi/util/NullLogger.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/java/org/apache/poi/util/NullLogger.java (original)
+++ poi/branches/common_sl/src/java/org/apache/poi/util/NullLogger.java Sun Jul 19 19:00:32 2015
@@ -27,12 +27,10 @@ package org.apache.poi.util;
* @author Glen Stampoultzis (glens at apache.org)
* @author Nicola Ken Barozzi (nicolaken at apache.org)
*/
-public class NullLogger extends POILogger
-{
+public class NullLogger extends POILogger {
@Override
- public void initialize(final String cat)
- {
- //do nothing
+ public void initialize(final String cat){
+ // do nothing
}
/**
@@ -45,147 +43,7 @@ public class NullLogger extends POILogge
@Override
public void log(final int level, final Object obj1)
{
- //do nothing
- }
-
- /**
- * Check if a logger is enabled to log at the specified level
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- */
-
- @Override
- public boolean check(final int level)
- {
- return false;
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first object to place in the message
- * @param obj2 second object to place in the message
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third Object to place in the message
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third Object to place in the message
- * @param obj4 fourth Object to place in the message
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Object obj4)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third Object to place in the message
- * @param obj4 fourth Object to place in the message
- * @param obj5 fifth Object to place in the message
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Object obj4, final Object obj5)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third Object to place in the message
- * @param obj4 fourth Object to place in the message
- * @param obj5 fifth Object to place in the message
- * @param obj6 sixth Object to place in the message
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Object obj4, final Object obj5,
- final Object obj6)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third Object to place in the message
- * @param obj4 fourth Object to place in the message
- * @param obj5 fifth Object to place in the message
- * @param obj6 sixth Object to place in the message
- * @param obj7 seventh Object to place in the message
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Object obj4, final Object obj5,
- final Object obj6, final Object obj7)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third Object to place in the message
- * @param obj4 fourth Object to place in the message
- * @param obj5 fifth Object to place in the message
- * @param obj6 sixth Object to place in the message
- * @param obj7 seventh Object to place in the message
- * @param obj8 eighth Object to place in the message
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Object obj4, final Object obj5,
- final Object obj6, final Object obj7, final Object obj8)
- {
- //do nothing
+ // do nothing
}
/**
@@ -195,289 +53,19 @@ public class NullLogger extends POILogge
* @param obj1 The object to log. This is converted to a string.
* @param exception An exception to be logged
*/
-
- @Override
- public void log(final int level, final Object obj1,
- final Throwable exception)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param exception An exception to be logged
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Throwable exception)
- {
- //do nothing
+ public void log(int level, Object obj1, final Throwable exception) {
+ // do nothing
}
+
/**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third object to place in the message
- * @param exception An error message to be logged
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Throwable exception)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third object to place in the message
- * @param obj4 fourth object to place in the message
- * @param exception An exception to be logged
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Object obj4,
- final Throwable exception)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third object to place in the message
- * @param obj4 fourth object to place in the message
- * @param obj5 fifth object to place in the message
- * @param exception An exception to be logged
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Object obj4, final Object obj5,
- final Throwable exception)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third object to place in the message
- * @param obj4 fourth object to place in the message
- * @param obj5 fifth object to place in the message
- * @param obj6 sixth object to place in the message
- * @param exception An exception to be logged
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Object obj4, final Object obj5,
- final Object obj6, final Throwable exception)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third object to place in the message
- * @param obj4 fourth object to place in the message
- * @param obj5 fifth object to place in the message
- * @param obj6 sixth object to place in the message
- * @param obj7 seventh object to place in the message
- * @param exception An exception to be logged
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Object obj4, final Object obj5,
- final Object obj6, final Object obj7,
- final Throwable exception)
- {
- //do nothing
- }
-
- /**
- * Log a message. Lazily appends Object parameters together.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param obj1 first Object to place in the message
- * @param obj2 second Object to place in the message
- * @param obj3 third object to place in the message
- * @param obj4 fourth object to place in the message
- * @param obj5 fifth object to place in the message
- * @param obj6 sixth object to place in the message
- * @param obj7 seventh object to place in the message
- * @param obj8 eighth object to place in the message
- * @param exception An exception to be logged
- */
-
- @Override
- public void log(final int level, final Object obj1, final Object obj2,
- final Object obj3, final Object obj4, final Object obj5,
- final Object obj6, final Object obj7, final Object obj8,
- final Throwable exception)
- {
- //do nothing
- }
-
- /**
- * Logs a formated message. The message itself may contain %
- * characters as place holders. This routine will attempt to match
- * the placeholder by looking at the type of parameter passed to
- * obj1.<p>
- *
- * If the parameter is an array, it traverses the array first and
- * matches parameters sequentially against the array items.
- * Otherwise the parameters after <code>message</code> are matched
- * in order.<p>
- *
- * If the place holder matches against a number it is printed as a
- * whole number. This can be overridden by specifying a precision
- * in the form %n.m where n is the padding for the whole part and
- * m is the number of decimal places to display. n can be excluded
- * if desired. n and m may not be more than 9.<p>
- *
- * If the last parameter (after flattening) is a Throwable it is
- * logged specially.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param message The message to log.
- * @param obj1 The first object to match against.
- */
-
- @Override
- public void logFormatted(final int level, final String message,
- final Object obj1)
- {
- //do nothing
- }
-
- /**
- * Logs a formated message. The message itself may contain %
- * characters as place holders. This routine will attempt to match
- * the placeholder by looking at the type of parameter passed to
- * obj1.<p>
- *
- * If the parameter is an array, it traverses the array first and
- * matches parameters sequentially against the array items.
- * Otherwise the parameters after <code>message</code> are matched
- * in order.<p>
- *
- * If the place holder matches against a number it is printed as a
- * whole number. This can be overridden by specifying a precision
- * in the form %n.m where n is the padding for the whole part and
- * m is the number of decimal places to display. n can be excluded
- * if desired. n and m may not be more than 9.<p>
- *
- * If the last parameter (after flattening) is a Throwable it is
- * logged specially.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param message The message to log.
- * @param obj1 The first object to match against.
- * @param obj2 The second object to match against.
- */
-
- @Override
- public void logFormatted(final int level, final String message,
- final Object obj1, final Object obj2)
- {
- //do nothing
- }
-
- /**
- * Logs a formated message. The message itself may contain %
- * characters as place holders. This routine will attempt to match
- * the placeholder by looking at the type of parameter passed to
- * obj1.<p>
- *
- * If the parameter is an array, it traverses the array first and
- * matches parameters sequentially against the array items.
- * Otherwise the parameters after <code>message</code> are matched
- * in order.<p>
- *
- * If the place holder matches against a number it is printed as a
- * whole number. This can be overridden by specifying a precision
- * in the form %n.m where n is the padding for the whole part and
- * m is the number of decimal places to display. n can be excluded
- * if desired. n and m may not be more than 9.<p>
- *
- * If the last parameter (after flattening) is a Throwable it is
- * logged specially.
- *
- * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param message The message to log.
- * @param obj1 The first object to match against.
- * @param obj2 The second object to match against.
- * @param obj3 The third object to match against.
- */
-
- @Override
- public void logFormatted(final int level, final String message,
- final Object obj1, final Object obj2,
- final Object obj3)
- {
- //do nothing
- }
-
- /**
- * Logs a formated message. The message itself may contain %
- * characters as place holders. This routine will attempt to match
- * the placeholder by looking at the type of parameter passed to
- * obj1.<p>
- *
- * If the parameter is an array, it traverses the array first and
- * matches parameters sequentially against the array items.
- * Otherwise the parameters after <code>message</code> are matched
- * in order.<p>
- *
- * If the place holder matches against a number it is printed as a
- * whole number. This can be overridden by specifying a precision
- * in the form %n.m where n is the padding for the whole part and
- * m is the number of decimal places to display. n can be excluded
- * if desired. n and m may not be more than 9.<p>
- *
- * If the last parameter (after flattening) is a Throwable it is
- * logged specially.
+ * Check if a logger is enabled to log at the specified level
*
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
- * @param message The message to log.
- * @param obj1 The first object to match against.
- * @param obj2 The second object to match against.
- * @param obj3 The third object to match against.
- * @param obj4 The forth object to match against.
*/
-
@Override
- public void logFormatted(final int level, final String message,
- final Object obj1, final Object obj2,
- final Object obj3, final Object obj4)
- {
- //do nothing
+ public boolean check(final int level) {
+ return false;
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org