// dummy function that returns NA
// don't care about the implementation, we are not interested in evaluation
// and this method will never be called
- FreeRefFunction NA = new FreeRefFunction() {
- @Override
- public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
- return ErrorEval.NA;
- }
- };
+ FreeRefFunction NA = (args, ec) -> ErrorEval.NA;
_functionsByName = new HashMap<>();
_functionsByName.put("BDP", NA);
_functionsByName.put("BDH", NA);
* mixing visitors and acceptors
*/
protected ShapeVisitorAcceptor getAcceptor() {
- return new ShapeVisitorAcceptor() {
- @Override
- public boolean accept(XDGFShape shape) {
- return !shape.isDeleted();
- }
- };
+ return shape -> !shape.isDeleted();
}
public void setAcceptor(ShapeVisitorAcceptor acceptor) {
private CTColComparator() {}
- public static final Comparator<CTCol> BY_MAX = new Comparator<CTCol>() {
- @Override
- public int compare(CTCol col1, CTCol col2) {
- long col1max = col1.getMax();
- long col2max = col2.getMax();
- return Long.compare(col1max, col2max);
- }
+ public static final Comparator<CTCol> BY_MAX = (col1, col2) -> {
+ long col1max = col1.getMax();
+ long col2max = col2.getMax();
+ return Long.compare(col1max, col2max);
};
- public static final Comparator<CTCol> BY_MIN_MAX = new Comparator<CTCol>() {
- @Override
- public int compare(CTCol col1, CTCol col2) {
- long col11min = col1.getMin();
- long col2min = col2.getMin();
- return col11min < col2min ? -1 : col11min > col2min ? 1 : BY_MAX.compare(col1, col2);
- }
+ public static final Comparator<CTCol> BY_MIN_MAX = (col1, col2) -> {
+ long col11min = col1.getMin();
+ long col2min = col2.getMin();
+ return col11min < col2min ? -1 : col11min > col2min ? 1 : BY_MAX.compare(col1, col2);
};
}
public void listByName(PrintStream out) {
ArrayList<MAPIProperty> all = new ArrayList<>(MAPIProperty.getAll());
- all.sort(new Comparator<MAPIProperty>() {
- public int compare(MAPIProperty a, MAPIProperty b) {
- return a.name.compareTo(b.name);
- }
- });
+ all.sort((a, b) -> a.name.compareTo(b.name));
list(all, out);
}
public void listById(PrintStream out) {
ArrayList<MAPIProperty> all = new ArrayList<>(MAPIProperty.getAll());
- all.sort(new Comparator<MAPIProperty>() {
- public int compare(MAPIProperty a, MAPIProperty b) {
- return Integer.compare(a.id, b.id);
- }
- });
+ all.sort((a, b) -> Integer.compare(a.id, b.id));
list(all, out);
}
private void list(ArrayList<MAPIProperty> list, PrintStream out) {
chpxToFileOrder.put( chpx, Integer.valueOf( counter++ ) );
}
}
- final Comparator<CHPX> chpxFileOrderComparator = new Comparator<CHPX>()
- {
- public int compare( CHPX o1, CHPX o2 )
- {
- Integer i1 = chpxToFileOrder.get( o1 );
- Integer i2 = chpxToFileOrder.get( o2 );
- return i1.compareTo( i2 );
- }
+ final Comparator<CHPX> chpxFileOrderComparator = (o1, o2) -> {
+ Integer i1 = chpxToFileOrder.get( o1 );
+ Integer i2 = chpxToFileOrder.get( o2 );
+ return i1.compareTo( i2 );
};
LOG.atDebug().log("CHPX's order map created in {} ms", box(currentTimeMillis() - start));
papxToFileOrder.put( papx, Integer.valueOf( counter++ ) );
}
}
- final Comparator<PAPX> papxFileOrderComparator = new Comparator<PAPX>()
- {
- public int compare( PAPX o1, PAPX o2 )
- {
- Integer i1 = papxToFileOrder.get( o1 );
- Integer i2 = papxToFileOrder.get( o2 );
- return i1.compareTo( i2 );
- }
+ final Comparator<PAPX> papxFileOrderComparator = (o1, o2) -> {
+ Integer i1 = papxToFileOrder.get( o1 );
+ Integer i2 = papxToFileOrder.get( o2 );
+ return i1.compareTo( i2 );
};
LOG.atDebug().log("PAPX's order map created in {} ms", box(currentTimeMillis() - start));
dir.getEntry(fileName).delete();
}
- return dir.createDocument(fileName, bos.getWriteIndex(), new POIFSWriterListener(){
- public void processPOIFSWriterEvent(POIFSWriterEvent event) {
- try {
- event.getStream().write(buf, 0, event.getLimit());
- } catch (IOException e) {
- throw new EncryptedDocumentException(e);
- }
+ return dir.createDocument(fileName, bos.getWriteIndex(), event -> {
+ try {
+ event.getStream().write(buf, 0, event.getLimit());
+ } catch (IOException e) {
+ throw new EncryptedDocumentException(e);
}
});
}
final EncryptionInfo info = getEncryptionInfo();
final BinaryRC4EncryptionHeader header = (BinaryRC4EncryptionHeader)info.getHeader();
final BinaryRC4EncryptionVerifier verifier = (BinaryRC4EncryptionVerifier)info.getVerifier();
- EncryptionRecord er = new EncryptionRecord() {
- @Override
- public void write(LittleEndianByteArrayOutputStream bos) {
- bos.writeShort(info.getVersionMajor());
- bos.writeShort(info.getVersionMinor());
- header.write(bos);
- verifier.write(bos);
- }
+ EncryptionRecord er = bos -> {
+ bos.writeShort(info.getVersionMajor());
+ bos.writeShort(info.getVersionMinor());
+ header.write(bos);
+ verifier.write(bos);
};
DataSpaceMapUtils.createEncryptionEntry(dir, "EncryptionInfo", er);
}
final StandardEncryptionHeader header = (StandardEncryptionHeader)info.getHeader();
final StandardEncryptionVerifier verifier = (StandardEncryptionVerifier)info.getVerifier();
- EncryptionRecord er = new EncryptionRecord(){
- @Override
- public void write(LittleEndianByteArrayOutputStream bos) {
- bos.writeShort(info.getVersionMajor());
- bos.writeShort(info.getVersionMinor());
- bos.writeInt(info.getEncryptionFlags());
- header.write(bos);
- verifier.write(bos);
- }
+ EncryptionRecord er = bos -> {
+ bos.writeShort(info.getVersionMajor());
+ bos.writeShort(info.getVersionMinor());
+ bos.writeInt(info.getEncryptionFlags());
+ header.write(bos);
+ verifier.write(bos);
};
createEncryptionEntry(dir, "EncryptionInfo", er);
* Convenience implementation for situations where all cell definitions remain fixed after
* evaluation begins.
*/
- IStabilityClassifier TOTALLY_IMMUTABLE = new IStabilityClassifier() {
- public boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex) {
- return true;
- }
- };
+ IStabilityClassifier TOTALLY_IMMUTABLE = (sheetIndex, rowIndex, columnIndex) -> true;
/**
* Checks if a cell's value(/formula) is fixed - in other words - not expected to be modified
return new NumberEval(temp);
}
- private static final I_MatchPredicate defaultPredicate = new I_MatchPredicate() {
+ private static final I_MatchPredicate defaultPredicate = valueEval -> {
- public boolean matches(ValueEval valueEval) {
-
- if(valueEval instanceof NumberEval) {
- // only numbers are counted
- return true;
- }
- if(valueEval == MissingArgEval.instance) {
- // oh yeah, and missing arguments
- return true;
- }
-
- // error values and string values not counted
- return false;
+ if(valueEval instanceof NumberEval) {
+ // only numbers are counted
+ return true;
}
+ if(valueEval == MissingArgEval.instance) {
+ // oh yeah, and missing arguments
+ return true;
+ }
+
+ // error values and string values not counted
+ return false;
};
/**
return new NumberEval(temp);
}
- private static final I_MatchPredicate defaultPredicate = new I_MatchPredicate() {
+ private static final I_MatchPredicate defaultPredicate = valueEval -> {
+ // Note - observed behavior of Excel:
+ // Error values like #VALUE!, #REF!, #DIV/0!, #NAME? etc don't cause this COUNTA to return an error
+ // in fact, they seem to get counted
- public boolean matches(ValueEval valueEval) {
- // Note - observed behavior of Excel:
- // Error values like #VALUE!, #REF!, #DIV/0!, #NAME? etc don't cause this COUNTA to return an error
- // in fact, they seem to get counted
-
- if(valueEval == BlankEval.instance) {
- return false;
- }
- // Note - everything but BlankEval counts
- return true;
+ if(valueEval == BlankEval.instance) {
+ return false;
}
+ // Note - everything but BlankEval counts
+ return true;
};
private static final I_MatchPredicate subtotalPredicate = new I_MatchAreaPredicate() {
*/
public final class Sumx2my2 extends XYNumericFunction {
- private static final Accumulator XSquaredMinusYSquaredAccumulator = new Accumulator() {
- @Override
- public double accumulate(double x, double y) {
- return x * x - y * y;
- }
- };
+ private static final Accumulator XSquaredMinusYSquaredAccumulator = (x, y) -> x * x - y * y;
@Override
protected Accumulator createAccumulator() {
*/
public final class Sumx2py2 extends XYNumericFunction {
- private static final Accumulator XSquaredPlusYSquaredAccumulator = new Accumulator() {
- @Override
- public double accumulate(double x, double y) {
- return x * x + y * y;
- }
- };
+ private static final Accumulator XSquaredPlusYSquaredAccumulator = (x, y) -> x * x + y * y;
@Override
protected Accumulator createAccumulator() {
*/
public final class Sumxmy2 extends XYNumericFunction {
- private static final Accumulator XMinusYSquaredAccumulator = new Accumulator() {
- @Override
- public double accumulate(double x, double y) {
- double xmy = x - y;
- return xmy * xmy;
- }
+ private static final Accumulator XMinusYSquaredAccumulator = (x, y) -> {
+ double xmy = x - y;
+ return xmy * xmy;
};
@Override