Replace custom hashCode code with Objects.hash() / Arrays.deepHashCode()

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871913 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2019-12-23 00:15:55 +00:00
parent ba6152503e
commit 66471836f5
56 changed files with 411 additions and 716 deletions

View File

@ -197,7 +197,7 @@ public class EscherComplexProperty extends EscherProperty {
@Override
public int hashCode() {
return getId() * 11;
return Arrays.deepHashCode(new Object[]{complexData, getId()});
}
@Override

View File

@ -18,6 +18,7 @@
package org.apache.poi.ddf;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import org.apache.poi.util.GenericRecordUtil;
@ -35,7 +36,7 @@ public class EscherSimpleProperty extends EscherProperty
/**
* The id is distinct from the actual property number. The id includes the property number the blip id
* flag and an indicator whether the property is complex or not.
*
*
* @param id the property id
* @param propertyValue the property value
*/
@ -57,7 +58,7 @@ public class EscherSimpleProperty extends EscherProperty
/**
* Constructs a new escher property. The three parameters are combined to form a property id.
*
*
* @param propertyNumber the property number
* @param isComplex true, if its a complex property
* @param isBlipId true, if its a blip
@ -142,9 +143,8 @@ public class EscherSimpleProperty extends EscherProperty
* require the use of such things.
*/
@Override
public int hashCode()
{
return propertyValue;
public int hashCode() {
return Objects.hash(propertyValue, getId());
}
@Override

View File

@ -17,6 +17,8 @@
package org.apache.poi.hpsf;
import java.util.Objects;
/**
* This class represents custom properties in the document summary
* information stream. The difference to normal properties is that custom
@ -39,7 +41,7 @@ public class CustomProperty extends Property
/**
* Creates a {@link CustomProperty} without a name by copying the
* underlying {@link Property}' attributes.
*
*
* @param property the property to copy
*/
public CustomProperty(final Property property) {
@ -48,7 +50,7 @@ public class CustomProperty extends Property
/**
* Creates a {@link CustomProperty} with a name.
*
*
* @param property This property's attributes are copied to the new custom
* property.
* @param name The new custom property's name.
@ -81,11 +83,11 @@ public class CustomProperty extends Property
* Compares two custom properties for equality. The method returns
* {@code true} if all attributes of the two custom properties are
* equal.
*
*
* @param o The custom property to compare with.
* @return {@code true} if both custom properties are equal, else
* {@code false}.
*
*
* @see java.util.AbstractSet#equals(java.lang.Object)
*/
public boolean equalsContents(final Object o) {
@ -108,11 +110,11 @@ public class CustomProperty extends Property
*/
@Override
public int hashCode() {
return (int) this.getID();
return Objects.hash(name, getID());
}
@Override
public boolean equals(Object o) {
return (o instanceof CustomProperty) ? equalsContents(o) : false;
return (o instanceof CustomProperty) && equalsContents(o);
}
}

View File

@ -25,6 +25,7 @@ import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
@ -67,10 +68,10 @@ public class Property {
/**
* Default codepage for {@link CodePageString CodePageStrings}
*/
public static final int DEFAULT_CODEPAGE = CodePageUtil.CP_WINDOWS_1252;
public static final int DEFAULT_CODEPAGE = CodePageUtil.CP_WINDOWS_1252;
private static final POILogger LOG = POILogFactory.getLogger(Property.class);
/** The property's ID. */
private long id;
@ -369,13 +370,7 @@ public class Property {
*/
@Override
public int hashCode() {
long hashCode = 0;
hashCode += id;
hashCode += type;
if (value != null) {
hashCode += value.hashCode();
}
return (int) (hashCode & 0x0ffffffffL );
return Objects.hash(id,type,value);
}
@ -388,7 +383,7 @@ public class Property {
public String toString() {
return toString(Property.DEFAULT_CODEPAGE, null);
}
public String toString(int codepage, PropertyIDMap idMap) {
final StringBuilder b = new StringBuilder();
b.append("Property[");
@ -419,7 +414,7 @@ public class Property {
} catch (Exception e) {
LOG.log(POILogger.WARN, "can't serialize string", e);
}
// skip length field
if(bos.size() > 2*LittleEndianConsts.INT_SIZE) {
final String hex = HexDump.dump(bos.toByteArray(), -2*LittleEndianConsts.INT_SIZE, 2*LittleEndianConsts.INT_SIZE);
@ -448,7 +443,7 @@ public class Property {
final long sec = tu.toSeconds(l);
l -= TimeUnit.SECONDS.toNanos(sec);
final long ms = tu.toMillis(l);
String str = String.format(Locale.ROOT, "%02d:%02d:%02d.%03d",hr,min,sec,ms);
b.append(str);
} else {
@ -461,7 +456,7 @@ public class Property {
b.append("null");
} else {
b.append(value);
String decoded = decodeValueFromID();
if (decoded != null) {
b.append(" (");
@ -479,7 +474,7 @@ public class Property {
}
return Variant.getVariantName(getType());
}
private String decodeValueFromID() {
try {
switch((int)getID()) {
@ -493,7 +488,7 @@ public class Property {
}
return null;
}
/**
* Writes the property to an output stream.
*

View File

@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -219,7 +220,7 @@ public class Section {
if (id == PropertyIDMap.PID_CODEPAGE) {
continue;
}
int pLen = propLen(offset2Id, off, size);
leis.setReadIndex(Math.toIntExact(this._offset + off));
@ -241,7 +242,7 @@ public class Section {
setProperty(new Property(id, leis, pLen, codepage));
}
}
sectionBytes.write(src, Math.toIntExact(_offset), size);
padSectionBytes();
}
@ -621,7 +622,7 @@ public class Section {
dic = PropertyIDMap.getDocumentSummaryInformationProperties();
}
}
return (dic != null && dic.containsKey(pid)) ? dic.get(pid) : PropertyIDMap.UNDEFINED;
}
@ -940,17 +941,9 @@ public class Section {
*/
@Override
public int hashCode() {
long hashCode = 0;
hashCode += getFormatID().hashCode();
final Property[] pa = getProperties();
for (Property aPa : pa) {
hashCode += aPa.hashCode();
}
return Math.toIntExact(hashCode & 0x0ffffffffL);
return Arrays.deepHashCode(new Object[]{getFormatID(),getProperties()});
}
/**
* @see Object#toString()
*/
@ -958,7 +951,7 @@ public class Section {
public String toString() {
return toString(null);
}
public String toString(PropertyIDMap idMap) {
final StringBuilder b = new StringBuilder();
final Property[] pa = getProperties();

View File

@ -18,6 +18,8 @@
package org.apache.poi.hssf.record;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndianOutput;
@ -1799,18 +1801,17 @@ public final class ExtendedFormatRecord extends StandardRecord {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + field_1_font_index;
result = prime * result + field_2_format_index;
result = prime * result + field_3_cell_options;
result = prime * result + field_4_alignment_options;
result = prime * result + field_5_indention_options;
result = prime * result + field_6_border_options;
result = prime * result + field_7_palette_options;
result = prime * result + field_8_adtl_palette_options;
result = prime * result + field_9_fill_palette_options;
return result;
return Objects.hash(
field_1_font_index
, field_2_format_index
, field_3_cell_options
, field_4_alignment_options
, field_5_indention_options
, field_6_border_options
, field_7_palette_options
, field_8_adtl_palette_options
, field_9_fill_palette_options
);
}
/**

View File

@ -458,22 +458,18 @@ public final class FontRecord extends StandardRecord {
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime
* result
+ ((field_11_font_name == null) ? 0 : field_11_font_name
.hashCode());
result = prime * result + field_1_font_height;
result = prime * result + field_2_attributes;
result = prime * result + field_3_color_palette_index;
result = prime * result + field_4_bold_weight;
result = prime * result + field_5_super_sub_script;
result = prime * result + field_6_underline;
result = prime * result + field_7_family;
result = prime * result + field_8_charset;
result = prime * result + field_9_zero;
return result;
return Objects.hash(
field_1_font_height
, field_2_attributes
, field_3_color_palette_index
, field_4_bold_weight
, field_5_super_sub_script
, field_6_underline
, field_7_family
, field_8_charset
, field_9_zero
, field_11_font_name
);
}
/**

View File

@ -222,20 +222,7 @@ public class ExtRst implements Comparable<ExtRst> {
@Override
public int hashCode() {
int hash = reserved;
hash = 31*hash+formattingFontIndex;
hash = 31*hash+formattingOptions;
hash = 31*hash+numberOfRuns;
hash = 31*hash+phoneticText.hashCode();
if (phRuns != null) {
for (PhRun ph : phRuns) {
hash = 31*hash+ph.phoneticTextFirstCharacterOffset;
hash = 31*hash+ph.realTextFirstCharacterOffset;
hash = 31*hash+ph.realTextLength;
}
}
return hash;
return Arrays.deepHashCode(new Object[]{reserved, formattingFontIndex, formattingOptions, numberOfRuns, phoneticText, phRuns});
}
public ExtRst copy() {

View File

@ -17,6 +17,8 @@
package org.apache.poi.hssf.record.common;
import java.util.Objects;
import org.apache.poi.hssf.record.cont.ContinuableRecordOutput;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianInput;
@ -52,4 +54,9 @@ public class PhRun {
out.writeShort(realTextFirstCharacterOffset);
out.writeShort(realTextLength);
}
@Override
public int hashCode() {
return Objects.hash(phoneticTextFirstCharacterOffset, realTextFirstCharacterOffset, realTextLength);
}
}

View File

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.poi.common.Duplicatable;
@ -103,13 +104,8 @@ public class UnicodeString implements Comparable<UnicodeString>, Duplicatable {
}
}
public int hashCode()
{
int stringHash = 0;
if (field_3_string != null) {
stringHash = field_3_string.hashCode();
}
return field_1_charCount + stringHash;
public int hashCode() {
return Objects.hash(field_1_charCount, field_3_string);
}
/**

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hssf.usermodel;
import java.util.Objects;
import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherBSERecord;
import org.apache.poi.ddf.EscherContainerRecord;
@ -162,18 +164,18 @@ public class HSSFComment extends HSSFTextbox implements Comment {
public boolean isVisible() {
return _note.getFlags() == NoteRecord.NOTE_VISIBLE;
}
@Override
public CellAddress getAddress() {
return new CellAddress(getRow(), getColumn());
}
@Override
public void setAddress(CellAddress address) {
setRow(address.getRow());
setColumn(address.getColumn());
}
@Override
public void setAddress(int row, int col) {
setRow(row);
@ -246,7 +248,7 @@ public class HSSFComment extends HSSFTextbox implements Comment {
protected NoteRecord getNoteRecord() {
return _note;
}
/**
* Do we know which cell this comment belongs to?
*/
@ -288,14 +290,14 @@ public class HSSFComment extends HSSFTextbox implements Comment {
NoteRecord note = (NoteRecord) getNoteRecord().cloneViaReserialise();
return new HSSFComment(spContainer, obj, txo, note);
}
public void setBackgroundImage(int pictureIndex){
setPropertyValue(new EscherSimpleProperty( EscherPropertyTypes.FILL__PATTERNTEXTURE, false, true, pictureIndex));
setPropertyValue(new EscherSimpleProperty( EscherPropertyTypes.FILL__FILLTYPE, false, false, FILL_TYPE_PICTURE));
EscherBSERecord bse = getPatriarch().getSheet().getWorkbook().getWorkbook().getBSERecord(pictureIndex);
bse.setRef(bse.getRef() + 1);
}
public void resetBackgroundImage(){
EscherSimpleProperty property = getOptRecord().lookup(EscherPropertyTypes.FILL__PATTERNTEXTURE);
if (null != property){
@ -305,7 +307,7 @@ public class HSSFComment extends HSSFTextbox implements Comment {
}
setPropertyValue(new EscherSimpleProperty( EscherPropertyTypes.FILL__FILLTYPE, false, false, FILL_TYPE_SOLID));
}
public int getBackgroundImageId(){
EscherSimpleProperty property = getOptRecord().lookup(EscherPropertyTypes.FILL__PATTERNTEXTURE);
return property == null ? 0 : property.getPropertyValue();
@ -332,6 +334,6 @@ public class HSSFComment extends HSSFTextbox implements Comment {
@Override
public int hashCode() {
return ((getRow()*17) + getColumn())*31;
return Objects.hash(getRow(),getColumn());
}
}

View File

@ -17,13 +17,15 @@
package org.apache.poi.hssf.usermodel;
import java.util.Objects;
import org.apache.poi.hssf.record.FontRecord;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Font;
/**
* Represents a Font used in a workbook.
*
*
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createFont()
* @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(int)
* @see org.apache.poi.hssf.usermodel.HSSFCellStyle#setFont(HSSFFont)
@ -207,7 +209,7 @@ public final class HSSFFont implements Font {
{
return font.getColorPaletteIndex();
}
/**
* get the color value for the font
*/
@ -216,7 +218,7 @@ public final class HSSFFont implements Font {
HSSFPalette pallette = wb.getCustomPalette();
return pallette.getColor( getColor() );
}
/**
* sets the font to be bold or not
*/
@ -227,7 +229,7 @@ public final class HSSFFont implements Font {
else
font.setBoldWeight(BOLDWEIGHT_NORMAL);
}
/**
* get if the font is bold or not
*/
@ -344,11 +346,7 @@ public final class HSSFFont implements Font {
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((font == null) ? 0 : font.hashCode());
result = prime * result + index;
return result;
return Objects.hash(font,index);
}
public boolean equals(Object obj) {

View File

@ -22,6 +22,7 @@ import java.util.EnumMap;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import org.apache.poi.ss.usermodel.Color;
import org.apache.poi.util.Removal;
@ -348,10 +349,7 @@ public class HSSFColor implements Color {
@Override
public int hashCode() {
int result = color != null ? color.hashCode() : 0;
result = 31 * result + index;
result = 31 * result + index2;
return result;
return Objects.hash(color,index,index2);
}
/**

View File

@ -17,11 +17,18 @@
package org.apache.poi.ss.formula;
import java.text.CollationKey;
import java.text.Collator;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.apache.poi.ss.formula.eval.BlankEval;
import org.apache.poi.ss.formula.eval.BoolEval;
@ -66,25 +73,25 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
private final Sheet sheet;
private final ConditionalFormatting formatting;
private final ConditionalFormattingRule rule;
/* cached values */
private final CellRangeAddress[] regions;
private CellRangeAddress topLeftRegion;
/**
* Depending on the rule type, it may want to know about certain values in the region when evaluating {@link #matches(CellReference)},
* such as top 10, unique, duplicate, average, etc. This collection stores those if needed so they are not repeatedly calculated
*/
private final Map<CellRangeAddress, Set<ValueAndFormat>> meaningfulRegionValues = new HashMap<>();
private final int priority;
private final int formattingIndex;
private final int ruleIndex;
private final String formula1;
private final String formula2;
private final String text;
// cached for performance, used with cell text comparisons, which are case insensitive and need to be Locale aware (contains, starts with, etc.)
// cached for performance, used with cell text comparisons, which are case insensitive and need to be Locale aware (contains, starts with, etc.)
private final String lowerText;
private final OperatorEnum operator;
@ -93,7 +100,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
private final ExcelNumberFormat numberFormat;
// cached for performance, used to format numeric cells for string comparisons. See Bug #61764 for explanation
private final DecimalFormat decimalTextFormat;
/**
*
* @param workbookEvaluator
@ -113,11 +120,11 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
this.rule = rule;
this.formattingIndex = formattingIndex;
this.ruleIndex = ruleIndex;
this.priority = rule.getPriority();
this.regions = regions;
for (CellRangeAddress region : regions) {
if (topLeftRegion == null) topLeftRegion = region;
else if (region.getFirstColumn() < topLeftRegion.getFirstColumn()
@ -127,15 +134,15 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
formula1 = rule.getFormula1();
formula2 = rule.getFormula2();
text = rule.getText();
lowerText = text == null ? null : text.toLowerCase(LocaleUtil.getUserLocale());
numberFormat = rule.getNumberFormat();
operator = OperatorEnum.values()[rule.getComparisonOperation()];
type = rule.getConditionType();
// Excel uses the stored text representation from the XML apparently, in tests done so far
decimalTextFormat = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
decimalTextFormat.setMaximumFractionDigits(340); // DecimalFormat.DOUBLE_FRACTION_DIGITS, which is default scoped
@ -147,91 +154,91 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
public Sheet getSheet() {
return sheet;
}
/**
* @return the formatting
*/
public ConditionalFormatting getFormatting() {
return formatting;
}
/**
* @return conditional formatting index
*/
public int getFormattingIndex() {
return formattingIndex;
}
/**
* @return Excel number format string to apply to matching cells, or null to keep the cell default
*/
public ExcelNumberFormat getNumberFormat() {
return numberFormat;
}
/**
* @return the rule
*/
public ConditionalFormattingRule getRule() {
return rule;
}
/**
* @return rule index
*/
public int getRuleIndex() {
return ruleIndex;
}
/**
* @return the regions
*/
public CellRangeAddress[] getRegions() {
return regions;
}
/**
* @return the priority
*/
public int getPriority() {
return priority;
}
/**
* @return the formula1
*/
public String getFormula1() {
return formula1;
}
/**
* @return the formula2
*/
public String getFormula2() {
return formula2;
}
/**
* @return condition text if any, or null
*/
public String getText() {
return text;
}
/**
* @return the operator
*/
public OperatorEnum getOperator() {
return operator;
}
/**
* @return the type
*/
public ConditionType getType() {
return type;
}
/**
* Defined as equal sheet name and formatting and rule indexes
* @see java.lang.Object#equals(java.lang.Object)
@ -255,7 +262,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
* This can be seen by creating 4 rules applying to two different ranges and examining the XML.
* <p>
* HSSF priority is based on definition/persistence order.
*
*
* @param o
* @return comparison based on sheet name, formatting index, and rule priority
*/
@ -265,7 +272,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
if (cmp != 0) {
return cmp;
}
final int x = getPriority();
final int y = o.getPriority();
// logic from Integer.compare()
@ -280,15 +287,12 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
return Integer.compare(getRuleIndex(), o.getRuleIndex());
}
@Override
public int hashCode() {
int hash = sheet.getSheetName().hashCode();
hash = 31 * hash + formattingIndex;
hash = 31 * hash + ruleIndex;
return hash;
return Objects.hash(sheet.getSheetName(),formattingIndex,ruleIndex);
}
/**
* @param ref
* @return true if this rule evaluates to true for the given cell
@ -302,28 +306,28 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
break;
}
}
if (region == null) {
// cell not in range of this rule
return false;
}
final ConditionType ruleType = getRule().getConditionType();
// these rules apply to all cells in a region. Specific condition criteria
// may specify no special formatting for that value partition, but that's display logic
if (ruleType.equals(ConditionType.COLOR_SCALE)
|| ruleType.equals(ConditionType.DATA_BAR)
|| ruleType.equals(ConditionType.ICON_SET)) {
return true;
return true;
}
Cell cell = null;
final Row row = sheet.getRow(ref.getRow());
if (row != null) {
cell = row.getCell(ref.getCol());
}
if (ruleType.equals(ConditionType.CELL_VALUE_IS)) {
// undefined cells never match a VALUE_IS condition
if (cell == null) return false;
@ -335,11 +339,11 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
if (ruleType.equals(ConditionType.FILTER)) {
return checkFilter(cell, ref, topLeftRegion);
}
// TODO: anything else, we don't handle yet, such as top 10
return false;
}
/**
* @param cell the cell to check for
* @param region for adjusting relative formulas
@ -347,48 +351,48 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
*/
private boolean checkValue(Cell cell, CellRangeAddress region) {
if (cell == null || DataValidationEvaluator.isType(cell, CellType.BLANK)
|| DataValidationEvaluator.isType(cell,CellType.ERROR)
|| (DataValidationEvaluator.isType(cell,CellType.STRING)
|| DataValidationEvaluator.isType(cell,CellType.ERROR)
|| (DataValidationEvaluator.isType(cell,CellType.STRING)
&& (cell.getStringCellValue() == null || cell.getStringCellValue().isEmpty())
)
) {
return false;
}
ValueEval eval = unwrapEval(workbookEvaluator.evaluate(rule.getFormula1(), ConditionalFormattingEvaluator.getRef(cell), region));
String f2 = rule.getFormula2();
ValueEval eval2 = BlankEval.instance;
if (f2 != null && f2.length() > 0) {
eval2 = unwrapEval(workbookEvaluator.evaluate(f2, ConditionalFormattingEvaluator.getRef(cell), region));
}
// we assume the cell has been evaluated, and the current formula value stored
if (DataValidationEvaluator.isType(cell, CellType.BOOLEAN)
&& (eval == BlankEval.instance || eval instanceof BoolEval)
&& (eval2 == BlankEval.instance || eval2 instanceof BoolEval)
if (DataValidationEvaluator.isType(cell, CellType.BOOLEAN)
&& (eval == BlankEval.instance || eval instanceof BoolEval)
&& (eval2 == BlankEval.instance || eval2 instanceof BoolEval)
) {
return operator.isValid(cell.getBooleanCellValue(), eval == BlankEval.instance ? null : ((BoolEval) eval).getBooleanValue(), eval2 == BlankEval.instance ? null : ((BoolEval) eval2).getBooleanValue());
}
if (DataValidationEvaluator.isType(cell, CellType.NUMERIC)
if (DataValidationEvaluator.isType(cell, CellType.NUMERIC)
&& (eval == BlankEval.instance || eval instanceof NumberEval )
&& (eval2 == BlankEval.instance || eval2 instanceof NumberEval)
&& (eval2 == BlankEval.instance || eval2 instanceof NumberEval)
) {
return operator.isValid(cell.getNumericCellValue(), eval == BlankEval.instance ? null : ((NumberEval) eval).getNumberValue(), eval2 == BlankEval.instance ? null : ((NumberEval) eval2).getNumberValue());
}
if (DataValidationEvaluator.isType(cell, CellType.STRING)
&& (eval == BlankEval.instance || eval instanceof StringEval )
&& (eval2 == BlankEval.instance || eval2 instanceof StringEval)
&& (eval2 == BlankEval.instance || eval2 instanceof StringEval)
) {
return operator.isValid(cell.getStringCellValue(), eval == BlankEval.instance ? null : ((StringEval) eval).getStringValue(), eval2 == BlankEval.instance ? null : ((StringEval) eval2).getStringValue());
}
return operator.isValidForIncompatibleTypes();
}
private ValueEval unwrapEval(ValueEval eval) {
ValueEval comp = eval;
while (comp instanceof RefEval) {
RefEval ref = (RefEval) comp;
comp = ref.getInnerValueEval(ref.getFirstSheetIndex());
@ -402,7 +406,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
*/
private boolean checkFormula(CellReference ref, CellRangeAddress region) {
ValueEval comp = unwrapEval(workbookEvaluator.evaluate(rule.getFormula1(), ref, region));
// Copied for now from DataValidationEvaluator.ValidationEnum.FORMULA#isValidValue()
if (comp instanceof BlankEval) {
return true;
@ -420,7 +424,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
return false; // anything else is false, such as text
}
private boolean checkFilter(Cell cell, CellReference ref, CellRangeAddress region) {
final ConditionFilterType filterType = rule.getConditionFilterType();
if (filterType == null) {
@ -439,22 +443,22 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
case TOP_10:
// from testing, Excel only operates on numbers and dates (which are stored as numbers) in the range.
// numbers stored as text are ignored, but numbers formatted as text are treated as numbers.
if (! cv.isNumber()) {
return false;
}
return getMeaningfulValues(region, false, new ValueFunction() {
@Override
public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
final ConditionFilterData conf = rule.getFilterConfiguration();
if (! conf.getBottom()) {
allValues.sort(Collections.reverseOrder());
} else {
Collections.sort(allValues);
}
int limit = Math.toIntExact(conf.getRank());
if (conf.getPercent()) {
limit = allValues.size() * limit / 100;
@ -473,9 +477,9 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
@Override
public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
Collections.sort(allValues);
final Set<ValueAndFormat> unique = new HashSet<>();
for (int i = 0; i < allValues.size(); i++) {
final ValueAndFormat v = allValues.get(i);
// skip this if the current value matches the next one, or is the last one and matches the previous one
@ -486,7 +490,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
unique.add(v);
}
return unique;
}
}).contains(cv);
@ -497,9 +501,9 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
@Override
public Set<ValueAndFormat> evaluate(List<ValueAndFormat> allValues) {
Collections.sort(allValues);
final Set<ValueAndFormat> dup = new HashSet<>();
for (int i = 0; i < allValues.size(); i++) {
final ValueAndFormat v = allValues.get(i);
// skip this if the current value matches the next one, or is the last one and matches the previous one
@ -515,7 +519,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
case ABOVE_AVERAGE:
// from testing, Excel only operates on numbers and dates (which are stored as numbers) in the range.
// numbers stored as text are ignored, but numbers formatted as text are treated as numbers.
final ConditionFilterData conf = rule.getFilterConfiguration();
// actually ordered, so iteration order is predictable
@ -538,23 +542,23 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
return avgSet;
}
}));
Double val = cv.isNumber() ? cv.getValue() : null;
if (val == null) {
return false;
}
double avg = values.get(0).value.doubleValue();
double stdDev = values.get(1).value.doubleValue();
/*
* use StdDev, aboveAverage, equalAverage to find:
* comparison value
* operator type
*/
Double comp = Double.valueOf(conf.getStdDev() > 0 ? (avg + (conf.getAboveAverage() ? 1 : -1) * stdDev * conf.getStdDev()) : avg) ;
final OperatorEnum op;
if (conf.getAboveAverage()) {
if (conf.getEqualAverage()) {
@ -611,11 +615,11 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
return false;
}
}
/**
* from testing, Excel only operates on numbers and dates (which are stored as numbers) in the range.
* numbers stored as text are ignored, but numbers formatted as text are treated as numbers.
*
*
* @param region
* @return the meaningful values in the range of cells specified
*/
@ -624,9 +628,9 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
if (values != null) {
return values;
}
List<ValueAndFormat> allValues = new ArrayList<>((region.getLastColumn() - region.getFirstColumn() + 1) * (region.getLastRow() - region.getFirstRow() + 1));
for (int r=region.getFirstRow(); r <= region.getLastRow(); r++) {
final Row row = sheet.getRow(r);
if (row == null) {
@ -640,10 +644,10 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
}
}
values = func.evaluate(allValues);
meaningfulRegionValues.put(region, values);
return values;
}
@ -671,7 +675,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
* TODO: when we get to use Java 8, this is obviously a Lambda Function.
*/
protected interface ValueFunction {
/**
*
* @param values
@ -679,11 +683,11 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
*/
Set<ValueAndFormat> evaluate(List<ValueAndFormat> values);
}
/**
* Not calling it OperatorType to avoid confusion for now with other classes.
* Definition order matches OOXML type ID indexes.
* Note that this has NO_COMPARISON as the first item, unlike the similar
* Note that this has NO_COMPARISON as the first item, unlike the similar
* DataValidation operator enum. Thanks, Microsoft.
*/
public static enum OperatorEnum {
@ -731,7 +735,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
return cellValue.compareTo(v1) < 0 || cellValue.compareTo(v2) > 0;
}
public boolean isValidForIncompatibleTypes() {
return true;
}
@ -767,7 +771,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
return cellValue.compareTo(v1) != 0;
}
public boolean isValidForIncompatibleTypes() {
return true;
}
@ -833,7 +837,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
}
},
;
/**
* Evaluates comparison using operator instance rules
* @param cellValue won't be null, assumption is previous checks handled that
@ -842,7 +846,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
* @return true if the comparison is valid
*/
public abstract <C extends Comparable<C>> boolean isValid(C cellValue, C v1, C v2);
/**
* Called when the cell and comparison values are of different data types
* Needed for negation operators, which should return true.
@ -852,43 +856,43 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
return false;
}
}
/**
* Note: this class has a natural ordering that is inconsistent with equals.
*/
protected static class ValueAndFormat implements Comparable<ValueAndFormat> {
private final Double value;
private final String string;
private final String format;
private final DecimalFormat decimalTextFormat;
public ValueAndFormat(Double value, String format, DecimalFormat df) {
this.value = value;
this.format = format;
string = null;
decimalTextFormat = df;
}
public ValueAndFormat(String value, String format) {
this.value = null;
this.format = format;
string = value;
decimalTextFormat = null;
}
public boolean isNumber() {
return value != null;
}
public Double getValue() {
return value;
}
public String getString() {
return string;
}
public String toString() {
if(isNumber()) {
return decimalTextFormat.format(getValue().doubleValue());
@ -896,7 +900,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
return getString();
}
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ValueAndFormat)) {
@ -907,7 +911,7 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
&& Objects.equals(format, o.format)
&& Objects.equals(string, o.string));
}
/**
* Note: this class has a natural ordering that is inconsistent with equals.
* @param o
@ -925,20 +929,20 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
if (cmp != 0) {
return cmp;
}
if (string == null && o.string != null) {
return 1;
}
if (o.string == null && string != null) {
return -1;
}
return string == null ? 0 : string.compareTo(o.string);
}
@Override
public int hashCode() {
return (string == null ? 0 : string.hashCode()) * 37 * 37 + 37 * (value == null ? 0 : value.hashCode()) + (format == null ? 0 : format.hashCode());
return Objects.hash(string,value,format);
}
}
}

View File

@ -20,6 +20,7 @@ package org.apache.poi.ss.util;
import static org.apache.poi.util.StringUtil.endsWithIgnoreCase;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -32,11 +33,11 @@ import org.apache.poi.ss.usermodel.Cell;
* cell references, and POI usermodel style row=0, column=0
* style references. Handles sheet-based and sheet-free references
* as well, eg "Sheet1!A1" and "$B$72"</p>
*
*
* <p>Use <tt>CellReference</tt> when the concept of
* relative/absolute does apply (such as a cell reference in a formula).
* Use {@link CellAddress} when you want to refer to the location of a cell in a sheet
* when the concept of relative/absolute does not apply (such as the anchor location
* when the concept of relative/absolute does not apply (such as the anchor location
* of a cell comment).
* <tt>CellReference</tt>s have a concept of "sheet", while <tt>CellAddress</tt>es do not.</p>
*/
@ -370,7 +371,7 @@ public class CellReference {
private static final class CellRefParts {
final String sheetName;
final String rowRef;
final String colRef;
final String colRef;
private CellRefParts(String sheetName, String rowRef, String colRef) {
this.sheetName = sheetName;
@ -381,7 +382,7 @@ public class CellReference {
/**
* Separates the sheet name, row, and columns from a cell reference string.
*
*
* @param reference is a string that identifies a cell within the sheet or workbook
* reference may not refer to a cell in an external workbook
* reference may be absolute or relative.
@ -584,12 +585,6 @@ public class CellReference {
@Override
public int hashCode() {
int result = 17;
result = 31 * result + _rowIndex;
result = 31 * result + _colIndex;
result = 31 * result + (_isRowAbs ? 1 : 0);
result = 31 * result + (_isColAbs ? 1 : 0);
result = 31 * result + (_sheetName == null ? 0 : _sheetName.hashCode());
return result;
return Objects.hash(_rowIndex,_colIndex,_isRowAbs,_isColAbs,_sheetName);
}
}

View File

@ -19,6 +19,7 @@ package org.apache.poi.openxml4j.opc;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Objects;
/**
* A part relationship.
@ -129,11 +130,7 @@ public final class PackageRelationship {
@Override
public int hashCode() {
return this.id.hashCode()
+ this.relationshipType.hashCode()
+ (this.source == null ? 0 : this.source.hashCode())
+ this.targetMode.hashCode()
+ this.targetUri.hashCode();
return Objects.hash(id,relationshipType,source,targetMode,targetUri);
}
/* Getters */

View File

@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -128,9 +129,9 @@ public final class ContentType {
* quoted-pair = "\" CHAR
*/
patternTypeSubType = Pattern.compile("^(" + token + "+)/(" +
patternTypeSubType = Pattern.compile("^(" + token + "+)/(" +
token + "+)$");
patternTypeSubTypeParams = Pattern.compile("^(" + token + "+)/(" +
patternTypeSubTypeParams = Pattern.compile("^(" + token + "+)/(" +
token + "+)(;" + parameter + ")*$");
patternParams = Pattern.compile(";" + parameter);
}
@ -160,7 +161,7 @@ public final class ContentType {
if (mMediaType.groupCount() >= 2) {
this.type = mMediaType.group(1);
this.subType = mMediaType.group(2);
// Parameters
this.parameters = new HashMap<>();
// Java RegExps are unhelpful, and won't do multiple group captures
@ -175,7 +176,7 @@ public final class ContentType {
// missing media type and subtype
this.type = "";
this.subType = "";
this.parameters = Collections.emptyMap();
this.parameters = Collections.emptyMap();
}
}
@ -212,7 +213,7 @@ public final class ContentType {
@Override
public int hashCode() {
return this.toString().hashCode();
return Objects.hash(type,subType,parameters);
}
/* Getters */
@ -234,14 +235,14 @@ public final class ContentType {
public String getType() {
return this.type;
}
/**
* Does this content type have any parameters associated with it?
*/
public boolean hasParameters() {
return (parameters != null) && !parameters.isEmpty();
}
/**
* Return the parameter keys
*/

View File

@ -17,6 +17,8 @@
package org.apache.poi.xssf.binary;
import java.util.Objects;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Internal;
@ -97,12 +99,7 @@ public class XSSFHyperlinkRecord {
@Override
public int hashCode() {
int result = cellRangeAddress != null ? cellRangeAddress.hashCode() : 0;
result = 31 * result + (relId != null ? relId.hashCode() : 0);
result = 31 * result + (location != null ? location.hashCode() : 0);
result = 31 * result + (toolTip != null ? toolTip.hashCode() : 0);
result = 31 * result + (display != null ? display.hashCode() : 0);
return result;
return Objects.hash(cellRangeAddress,relId,location,toolTip,display);
}
@Override

View File

@ -18,6 +18,7 @@
package org.apache.poi.hslf.model.textproperties;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import org.apache.poi.common.Duplicatable;
@ -100,11 +101,7 @@ public class HSLFTabStop implements TabStop, Duplicatable, GenericRecord {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + position;
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
return Objects.hash(position, type);
}
@Override

View File

@ -21,6 +21,7 @@ import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import org.apache.poi.sl.usermodel.TabStop.TabStopType;
@ -123,7 +124,7 @@ public class HSLFTabStopPropCollection extends TextProp {
@Override
public int hashCode() {
return 31 * super.hashCode() + tabStops.hashCode();
return Objects.hash(super.hashCode(), tabStops);
}
@Override

View File

@ -26,6 +26,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import org.apache.poi.common.Duplicatable;
@ -334,13 +335,7 @@ public class TextPropCollection implements GenericRecord, Duplicatable {
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + charactersCovered;
result = prime * result + maskSpecial;
result = prime * result + indentLevel;
result = prime * result + textProps.hashCode();
return result;
return Objects.hash(charactersCovered,maskSpecial,indentLevel,textProps);
}
/**
* compares most properties apart of the covered characters length

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.BKFAbstractType;
import org.apache.poi.util.Internal;
@ -63,13 +65,8 @@ public final class BookmarkFirstDescriptor extends BKFAbstractType implements
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_ibkl;
result = prime * result + field_2_bkf_flags;
return result;
public int hashCode() {
return Objects.hash(field_1_ibkl,field_2_bkf_flags);
}
public boolean isEmpty()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.FibBaseAbstractType;
import org.apache.poi.util.Internal;
@ -25,7 +27,7 @@ import org.apache.poi.util.Internal;
* <p>
* Class and fields descriptions are quoted from Microsoft Office Word 97-2007
* Binary File Format and [MS-DOC] - v20110608 Word (.doc) Binary File Format.
*
*
* @author Andrew C. Oliver; Sergey Vladimirov; according to Microsoft Office
* Word 97-2007 Binary File Format Specification [*.doc] and [MS-DOC] -
* v20110608 Word (.doc) Binary File Format
@ -84,22 +86,8 @@ public class FibBase extends FibBaseAbstractType {
@Override
@SuppressWarnings( "deprecation" )
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + field_10_flags2;
result = prime * result + field_11_Chs;
result = prime * result + field_12_chsTables;
result = prime * result + field_13_fcMin;
result = prime * result + field_14_fcMac;
result = prime * result + field_1_wIdent;
result = prime * result + field_2_nFib;
result = prime * result + field_3_unused;
result = prime * result + field_4_lid;
result = prime * result + field_5_pnNext;
result = prime * result + field_6_flags1;
result = prime * result + field_7_nFibBack;
result = prime * result + field_8_lKey;
result = prime * result + field_9_envr;
return result;
return Objects.hash(field_1_wIdent, field_2_nFib, field_3_unused, field_4_lid, field_5_pnNext, field_6_flags1,
field_7_nFibBack, field_8_lKey, field_9_envr, field_10_flags2, field_11_Chs, field_12_chsTables,
field_13_fcMin, field_14_fcMac);
}
}

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.FibRgW97AbstractType;
import org.apache.poi.util.Internal;
@ -24,7 +26,7 @@ import org.apache.poi.util.Internal;
* <p>
* Class and fields descriptions are quoted from Microsoft Office Word 97-2007
* Binary File Format and [MS-DOC] - v20110608 Word (.doc) Binary File Format.
*
*
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary
* File Format Specification [*.doc] and [MS-DOC] - v20110608 Word
* (.doc) Binary File Format
@ -86,25 +88,10 @@ public class FibRgW97 extends FibRgW97AbstractType
@Override
@SuppressWarnings( "deprecation" )
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_10_reserved10;
result = prime * result + field_11_reserved11;
result = prime * result + field_12_reserved12;
result = prime * result + field_13_reserved13;
result = prime * result + field_14_lidFE;
result = prime * result + field_1_reserved1;
result = prime * result + field_2_reserved2;
result = prime * result + field_3_reserved3;
result = prime * result + field_4_reserved4;
result = prime * result + field_5_reserved5;
result = prime * result + field_6_reserved6;
result = prime * result + field_7_reserved7;
result = prime * result + field_8_reserved8;
result = prime * result + field_9_reserved9;
return result;
public int hashCode() {
return Objects.hash(field_1_reserved1, field_2_reserved2, field_3_reserved3, field_4_reserved4,
field_5_reserved5, field_6_reserved6, field_7_reserved7, field_8_reserved8, field_9_reserved9,
field_10_reserved10, field_11_reserved11, field_12_reserved12, field_13_reserved13, field_14_lidFE);
}
}

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.FRDAbstractType;
import org.apache.poi.util.Internal;
@ -61,12 +63,8 @@ public final class FootnoteReferenceDescriptor extends FRDAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_nAuto;
return result;
public int hashCode() {
return Objects.hash(field_1_nAuto);
}
public boolean isEmpty()

View File

@ -17,6 +17,8 @@
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.HRESIAbstractType;
import org.apache.poi.hwpf.usermodel.CharacterProperties;
import org.apache.poi.util.Internal;
@ -24,7 +26,7 @@ import org.apache.poi.util.LittleEndian;
/**
* Hyphenation. Substructure of the {@link CharacterProperties}.
*
*
* @author Sergey Vladimirov ( vlsergey {at} gmail {dot} com )
*/
@Internal
@ -79,13 +81,8 @@ public final class Hyphenation extends HRESIAbstractType implements Cloneable
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_hres;
result = prime * result + field_2_chHres;
return result;
public int hashCode() {
return Objects.hash(field_1_hres,field_2_chHres);
}
public boolean isEmpty()

View File

@ -28,7 +28,7 @@ import org.apache.poi.util.LittleEndian;
/**
* The LFOData structure contains the Main Document CP of the corresponding LFO,
* as well as an array of LVL override data.
*
*
* @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/
@Internal
@ -104,8 +104,6 @@ public class LFOData
@Override
public int hashCode() {
int result = _cp;
result = 31 * result + Arrays.hashCode(_rgLfoLvl);
return result;
return Arrays.deepHashCode(_rgLfoLvl);
}
}

View File

@ -80,7 +80,7 @@ public final class ListData
/**
* Gets the level associated to a particular List at a particular index.
*
*
* @param index
* 1-based index
* @return a list level
@ -106,13 +106,8 @@ public final class ListData
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode( _levels );
result = prime * result + ( ( _lstf == null ) ? 0 : _lstf.hashCode() );
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{_levels,_lstf});
}
public int numLevels()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.util.Internal;
/**
@ -81,13 +83,8 @@ public final class ListFormatOverrideLevel
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + _base.hashCode();
result = prime * result + ( _lvl != null ? _lvl.hashCode() : 0 );
return result;
public int hashCode() {
return Objects.hash(_base,_lvl);
}
public boolean isFormatting()

View File

@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.NoSuchElementException;
import java.util.Objects;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -162,13 +163,8 @@ public final class ListTables
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + _listMap.hashCode();
result = prime * result + ( ( _plfLfo == null ) ? 0 : _plfLfo.hashCode() );
return result;
public int hashCode() {
return Objects.hash(_listMap,_plfLfo);
}
@Override

View File

@ -27,7 +27,7 @@ import org.apache.poi.util.Internal;
* <p>
* Class and fields descriptions are quoted from Microsoft Office Word 97-2007
* Binary File Format and [MS-DOC] - v20110608 Word (.doc) Binary File Format
*
*
* @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/
@Internal
@ -111,38 +111,12 @@ public class PICF extends PICFAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_10_padding2;
result = prime * result + field_11_dxaGoal;
result = prime * result + field_12_dyaGoal;
result = prime * result + field_13_mx;
result = prime * result + field_14_my;
result = prime * result + field_15_dxaReserved1;
result = prime * result + field_16_dyaReserved1;
result = prime * result + field_17_dxaReserved2;
result = prime * result + field_18_dyaReserved2;
result = prime * result + field_19_fReserved;
result = prime * result + field_1_lcb;
result = prime * result + field_20_bpp;
result = prime * result + Arrays.hashCode( field_21_brcTop80 );
result = prime * result + Arrays.hashCode( field_22_brcLeft80 );
result = prime * result + Arrays.hashCode( field_23_brcBottom80 );
result = prime * result + Arrays.hashCode( field_24_brcRight80 );
result = prime * result + field_25_dxaReserved3;
result = prime * result + field_26_dyaReserved3;
result = prime * result + field_27_cProps;
result = prime * result + field_2_cbHeader;
result = prime * result + field_3_mm;
result = prime * result + field_4_xExt;
result = prime * result + field_5_yExt;
result = prime * result + field_6_swHMF;
result = prime * result + field_7_grf;
result = prime * result + field_8_padding;
result = prime * result + field_9_mmPM;
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{field_1_lcb, field_2_cbHeader, field_3_mm, field_4_xExt, field_5_yExt,
field_6_swHMF, field_7_grf, field_8_padding, field_9_mmPM, field_10_padding2, field_11_dxaGoal,
field_12_dyaGoal, field_13_mx, field_14_my, field_15_dxaReserved1, field_16_dyaReserved1, field_17_dxaReserved2,
field_18_dyaReserved2, field_19_fReserved, field_20_bpp, field_21_brcTop80, field_22_brcLeft80,
field_23_brcBottom80, field_24_brcRight80, field_25_dxaReserved3, field_26_dyaReserved3, field_27_cProps});
}
}

View File

@ -18,6 +18,7 @@
package org.apache.poi.hwpf.model;
import java.nio.charset.Charset;
import java.util.Objects;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -89,12 +90,7 @@ public final class PieceDescriptor {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + descriptor;
result = prime * result + ( ( prm == null ) ? 0 : prm.hashCode() );
result = prime * result + ( unicode ? 1231 : 1237 );
return result;
return Objects.hash(descriptor,prm,unicode);
}
/**

View File

@ -32,7 +32,7 @@ import org.apache.poi.util.POILogger;
* <p>
* Documentation quoted from Page 424 of 621. [MS-DOC] -- v20110315 Word (.doc)
* Binary File Format
*
*
* @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/
public class PlfLfo
@ -49,7 +49,7 @@ public class PlfLfo
private LFOData[] _rgLfoData;
PlfLfo( byte[] tableStream, int fcPlfLfo, int lcbPlfLfo )
{
/*
@ -192,14 +192,8 @@ public class PlfLfo
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + _lfoMac;
result = prime * result + Arrays.hashCode( _rgLfo );
result = prime * result + Arrays.hashCode( _rgLfoData );
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{_lfoMac, _rgLfo, _rgLfoData});
}
void writeTo( FileInformationBlock fib, ByteArrayOutputStream outputStream )

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
@ -103,12 +105,8 @@ public final class PropertyModifier implements Cloneable
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + value;
return result;
public int hashCode() {
return Objects.hash(value);
}
public boolean isComplex()

View File

@ -19,6 +19,7 @@ package org.apache.poi.hwpf.model;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Objects;
import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
@ -147,7 +148,7 @@ public abstract class PropertyNode<T extends PropertyNode<T>> implements Compara
@Override
public int hashCode() {
return this._cpStart * 31 + this._buf.hashCode();
return Objects.hash(_cpStart,_buf);
}
public boolean equals(Object o) {

View File

@ -17,6 +17,8 @@
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.util.Internal;
@ -67,12 +69,8 @@ public final class SavedByEntry
*
* @return the hash code.
*/
public int hashCode()
{
int hash = 29;
hash = hash * 13 + userName.hashCode();
hash = hash * 13 + saveLocation.hashCode();
return hash;
public int hashCode() {
return Objects.hash(userName,saveLocation);
}
/**

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.StdfBaseAbstractType;
import org.apache.poi.util.Internal;
@ -59,16 +61,8 @@ class StdfBase extends StdfBaseAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_info1;
result = prime * result + field_2_info2;
result = prime * result + field_3_info3;
result = prime * result + field_4_bchUpe;
result = prime * result + field_5_grfstd;
return result;
public int hashCode() {
return Objects.hash(field_1_info1, field_2_info2, field_3_info3, field_4_bchUpe, field_5_grfstd);
}
public byte[] serialize()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.StdfPost2000AbstractType;
import org.apache.poi.util.Internal;
@ -55,15 +57,8 @@ class StdfPost2000 extends StdfPost2000AbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_info1;
result = prime * result
+ (int) ( field_2_rsid ^ ( field_2_rsid >>> 32 ) );
result = prime * result + field_3_info3;
return result;
public int hashCode() {
return Objects.hash(field_1_info1, field_2_rsid, field_3_info3);
}
public byte[] serialize()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.StshifAbstractType;
import org.apache.poi.util.Internal;
@ -67,20 +69,9 @@ class Stshif extends StshifAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_cstd;
result = prime * result + field_2_cbSTDBaseInFile;
result = prime * result + field_3_info3;
result = prime * result + field_4_stiMaxWhenSaved;
result = prime * result + field_5_istdMaxFixedWhenSaved;
result = prime * result + field_6_nVerBuiltInNamesWhenSaved;
result = prime * result + field_7_ftcAsci;
result = prime * result + field_8_ftcFE;
result = prime * result + field_9_ftcOther;
return result;
public int hashCode() {
return Objects.hash(field_1_cstd, field_2_cbSTDBaseInFile, field_3_info3, field_4_stiMaxWhenSaved,
field_5_istdMaxFixedWhenSaved, field_6_nVerBuiltInNamesWhenSaved, field_7_ftcAsci, field_8_ftcFE, field_9_ftcOther);
}
public byte[] serialize()

View File

@ -220,13 +220,7 @@ public final class StyleDescription {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((_name == null) ? 0 : _name.hashCode());
result = prime * result
+ ((_stdfBase == null) ? 0 : _stdfBase.hashCode());
result = prime * result + Arrays.hashCode(_upxs);
return result;
return Arrays.deepHashCode(new Object[]{_name,_stdfBase,_upxs});
}
@Override

View File

@ -316,7 +316,7 @@ public class TextPieceTable implements CharIndexTranslator {
@Override
public int hashCode() {
return _textPieces.size();
return _textPieces.hashCode();
}
public boolean isIndexInTable(int bytePos) {

View File

@ -28,7 +28,7 @@ import org.apache.poi.util.LittleEndian;
* <p>
* Documentation quoted from Page 424 of 621. [MS-DOC] -- v20110315 Word (.doc)
* Binary File Format
*
*
* @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/
public class Xst
@ -118,13 +118,8 @@ public class Xst
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + _cch;
result = prime * result + Arrays.hashCode( _rgtchar );
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{_cch,_rgtchar});
}
public void serialize( byte[] data, int startOffset )

View File

@ -34,7 +34,7 @@ import org.apache.poi.util.Internal;
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author S. Ryan Ackley
@ -423,89 +423,20 @@ public abstract class CHPAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_grpfChp;
result = prime * result + field_2_hps;
result = prime * result + field_3_ftcAscii;
result = prime * result + field_4_ftcFE;
result = prime * result + field_5_ftcOther;
result = prime * result + field_6_ftcBi;
result = prime * result + field_7_dxaSpace;
result = prime * result
+ ((field_8_cv == null) ? 0 : field_8_cv.hashCode());
result = prime * result + field_9_ico;
result = prime * result + field_10_pctCharWidth;
result = prime * result + field_11_lidDefault;
result = prime * result + field_12_lidFE;
result = prime * result + field_13_kcd;
result = prime * result + ( field_14_fUndetermine? 1231 : 1237 );
result = prime * result + field_15_iss;
result = prime * result + ( field_16_fSpecSymbol? 1231 : 1237 );
result = prime * result + field_17_idct;
result = prime * result + field_18_idctHint;
result = prime * result + field_19_kul;
result = prime * result
+ ((field_20_hresi == null) ? 0 : field_20_hresi.hashCode());
result = prime * result + field_21_hpsKern;
result = prime * result + field_22_hpsPos;
result = prime * result
+ ((field_23_shd == null) ? 0 : field_23_shd.hashCode());
result = prime * result
+ ((field_24_brc == null) ? 0 : field_24_brc.hashCode());
result = prime * result + field_25_ibstRMark;
result = prime * result + field_26_sfxtText;
result = prime * result + ( field_27_fDblBdr? 1231 : 1237 );
result = prime * result + ( field_28_fBorderWS? 1231 : 1237 );
result = prime * result + field_29_ufel;
result = prime * result + field_30_copt;
result = prime * result + field_31_hpsAsci;
result = prime * result + field_32_hpsFE;
result = prime * result + field_33_hpsBi;
result = prime * result + field_34_ftcSym;
result = prime * result + field_35_xchSym;
result = prime * result + field_36_fcPic;
result = prime * result + field_37_fcObj;
result = prime * result + field_38_lTagObj;
result = prime * result + field_39_fcData;
result = prime * result
+ ((field_40_hresiOld == null) ? 0 : field_40_hresiOld.hashCode());
result = prime * result + field_41_ibstRMarkDel;
result = prime * result
+ ((field_42_dttmRMark == null) ? 0 : field_42_dttmRMark.hashCode());
result = prime * result
+ ((field_43_dttmRMarkDel == null) ? 0 : field_43_dttmRMarkDel.hashCode());
result = prime * result + field_44_istd;
result = prime * result + field_45_idslRMReason;
result = prime * result + field_46_idslReasonDel;
result = prime * result + field_47_cpg;
result = prime * result + field_48_Highlight;
result = prime * result + field_49_CharsetFlags;
result = prime * result + field_50_chse;
result = prime * result + ( field_51_fPropRMark? 1231 : 1237 );
result = prime * result + field_52_ibstPropRMark;
result = prime * result
+ ((field_53_dttmPropRMark == null) ? 0 : field_53_dttmPropRMark.hashCode());
result = prime * result + ( field_54_fConflictOrig? 1231 : 1237 );
result = prime * result + ( field_55_fConflictOtherDel? 1231 : 1237 );
result = prime * result + field_56_wConflict;
result = prime * result + field_57_IbstConflict;
result = prime * result
+ ((field_58_dttmConflict == null) ? 0 : field_58_dttmConflict.hashCode());
result = prime * result + ( field_59_fDispFldRMark? 1231 : 1237 );
result = prime * result + field_60_ibstDispFldRMark;
result = prime * result
+ ((field_61_dttmDispFldRMark == null) ? 0 : field_61_dttmDispFldRMark.hashCode());
result = prime * result + Arrays.hashCode( field_62_xstDispFldRMark );
result = prime * result + field_63_fcObjp;
result = prime * result + field_64_lbrCRJ;
result = prime * result + ( field_65_fSpecVanish? 1231 : 1237 );
result = prime * result + ( field_66_fHasOldProps? 1231 : 1237 );
result = prime * result + ( field_67_fSdtVanish? 1231 : 1237 );
result = prime * result + field_68_wCharScale;
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{field_1_grpfChp, field_2_hps, field_3_ftcAscii, field_4_ftcFE, field_5_ftcOther,
field_6_ftcBi, field_7_dxaSpace, field_8_cv, field_9_ico, field_10_pctCharWidth, field_11_lidDefault,
field_12_lidFE, field_13_kcd, field_14_fUndetermine, field_15_iss, field_16_fSpecSymbol, field_17_idct,
field_18_idctHint, field_19_kul, field_20_hresi, field_21_hpsKern, field_22_hpsPos, field_23_shd,
field_24_brc, field_25_ibstRMark, field_26_sfxtText, field_27_fDblBdr, field_28_fBorderWS, field_29_ufel,
field_30_copt, field_31_hpsAsci, field_32_hpsFE, field_33_hpsBi, field_34_ftcSym, field_35_xchSym,
field_36_fcPic, field_37_fcObj, field_38_lTagObj, field_39_fcData, field_40_hresiOld, field_41_ibstRMarkDel,
field_42_dttmRMark, field_43_dttmRMarkDel, field_44_istd, field_45_idslRMReason, field_46_idslReasonDel,
field_47_cpg, field_48_Highlight, field_49_CharsetFlags, field_50_chse, field_51_fPropRMark,
field_52_ibstPropRMark, field_53_dttmPropRMark, field_54_fConflictOrig, field_55_fConflictOtherDel,
field_56_wConflict, field_57_IbstConflict, field_58_dttmConflict, field_59_fDispFldRMark,
field_60_ibstDispFldRMark, field_61_dttmDispFldRMark, field_62_xstDispFldRMark, field_63_fcObjp,
field_64_lbrCRJ, field_65_fSpecVanish, field_66_fHasOldProps, field_67_fSdtVanish, field_68_wCharScale});
}
public String toString()
@ -922,7 +853,7 @@ public abstract class CHPAbstractType
/**
* Emphasis mark.
*
* @return One of
* @return One of
* <li>{@link #KCD_NON}
* <li>{@link #KCD_DOT}
* <li>{@link #KCD_COMMA}
@ -939,7 +870,7 @@ public abstract class CHPAbstractType
* Emphasis mark.
*
* @param field_13_kcd
* One of
* One of
* <li>{@link #KCD_NON}
* <li>{@link #KCD_DOT}
* <li>{@link #KCD_COMMA}
@ -973,7 +904,7 @@ public abstract class CHPAbstractType
/**
* Superscript/subscript indices.
*
* @return One of
* @return One of
* <li>{@link #ISS_NONE}
* <li>{@link #ISS_SUPERSCRIPTED}
* <li>{@link #ISS_SUBSCRIPTED}
@ -988,7 +919,7 @@ public abstract class CHPAbstractType
* Superscript/subscript indices.
*
* @param field_15_iss
* One of
* One of
* <li>{@link #ISS_NONE}
* <li>{@link #ISS_SUPERSCRIPTED}
* <li>{@link #ISS_SUBSCRIPTED}
@ -1056,7 +987,7 @@ public abstract class CHPAbstractType
/**
* Underline code.
*
* @return One of
* @return One of
* <li>{@link #KUL_NONE}
* <li>{@link #KUL_SINGLE}
* <li>{@link #KUL_BY_WORD}
@ -1088,7 +1019,7 @@ public abstract class CHPAbstractType
* Underline code.
*
* @param field_19_kul
* One of
* One of
* <li>{@link #KUL_NONE}
* <li>{@link #KUL_SINGLE}
* <li>{@link #KUL_BY_WORD}
@ -1227,7 +1158,7 @@ public abstract class CHPAbstractType
/**
* Text animation.
*
* @return One of
* @return One of
* <li>{@link #SFXTTEXT_NO}
* <li>{@link #SFXTTEXT_LAS_VEGAS_LIGHTS}
* <li>{@link #SFXTTEXT_BACKGROUND_BLINK}
@ -1246,7 +1177,7 @@ public abstract class CHPAbstractType
* Text animation.
*
* @param field_26_sfxtText
* One of
* One of
* <li>{@link #SFXTTEXT_NO}
* <li>{@link #SFXTTEXT_LAS_VEGAS_LIGHTS}
* <li>{@link #SFXTTEXT_BACKGROUND_BLINK}
@ -1930,7 +1861,7 @@ public abstract class CHPAbstractType
/**
* Line BReak code for xchCRJ.
*
* @return One of
* @return One of
* <li>{@link #LBRCRJ_NONE}
* <li>{@link #LBRCRJ_LEFT}
* <li>{@link #LBRCRJ_RIGHT}
@ -1946,7 +1877,7 @@ public abstract class CHPAbstractType
* Line BReak code for xchCRJ.
*
* @param field_64_lbrCRJ
* One of
* One of
* <li>{@link #LBRCRJ_NONE}
* <li>{@link #LBRCRJ_LEFT}
* <li>{@link #LBRCRJ_RIGHT}
@ -2692,7 +2623,7 @@ public abstract class CHPAbstractType
/**
* Sets the itypFELayout field value.
*
*
*/
@Internal
public void setItypFELayout( short value )
@ -2701,7 +2632,7 @@ public abstract class CHPAbstractType
}
/**
*
*
* @return the itypFELayout field value.
*/
@Internal

View File

@ -18,6 +18,8 @@
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -28,18 +30,18 @@ import org.apache.poi.util.LittleEndian;
descriptions are quoted from [MS-DOC] -- v20121003 Word (.doc) Binary
File Format; Copyright (c) 2012 Microsoft Corporation; Release:
October 8, 2012
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to [MS-DOC] -- v20121003 Word
(.doc) Binary File Format; Copyright (c) 2012 Microsoft Corporation;
Release: October 8, 2012
*/
@Internal
public abstract class FFDataBaseAbstractType
@ -134,16 +136,8 @@ public abstract class FFDataBaseAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result
+ (int) ( field_1_version ^ ( field_1_version >>> 32 ) );
result = prime * result + field_2_bits;
result = prime * result + field_3_cch;
result = prime * result + field_4_hps;
return result;
public int hashCode() {
return Objects.hash(field_1_version, field_2_bits, field_3_cch, field_4_hps);
}
public String toString()
@ -247,7 +241,7 @@ public abstract class FFDataBaseAbstractType
/**
* Sets the iType field value.
* An unsigned integer that specifies the type of the form field.
* An unsigned integer that specifies the type of the form field.
*/
@Internal
public void setIType( byte value )
@ -256,7 +250,7 @@ public abstract class FFDataBaseAbstractType
}
/**
* An unsigned integer that specifies the type of the form field.
* An unsigned integer that specifies the type of the form field.
* @return the iType field value.
*/
@Internal

View File

@ -18,21 +18,23 @@
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
/**
* The FibRgLw95 structure is the third section of the FIB for Word95.
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov
*/
@Internal
public abstract class FibRgLw95AbstractType
@ -155,25 +157,10 @@ public abstract class FibRgLw95AbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_cbMac;
result = prime * result + field_2_reserved1;
result = prime * result + field_3_reserved2;
result = prime * result + field_4_reserved3;
result = prime * result + field_5_reserved4;
result = prime * result + field_6_ccpText;
result = prime * result + field_7_ccpFtn;
result = prime * result + field_8_ccpHdd;
result = prime * result + field_9_ccpMcr;
result = prime * result + field_10_ccpAtn;
result = prime * result + field_11_ccpEdn;
result = prime * result + field_12_ccpTxbx;
result = prime * result + field_13_ccpHdrTxbx;
result = prime * result + field_14_reserved5;
return result;
public int hashCode() {
return Objects.hash(field_1_cbMac, field_2_reserved1, field_3_reserved2, field_4_reserved3, field_5_reserved4,
field_6_ccpText, field_7_ccpFtn, field_8_ccpHdd, field_9_ccpMcr, field_10_ccpAtn, field_11_ccpEdn,
field_12_ccpTxbx, field_13_ccpHdrTxbx, field_14_reserved5);
}
public String toString()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -23,17 +25,17 @@ import org.apache.poi.util.LittleEndian;
* The FibRgLw97 structure is the third section of the FIB. This contains an array of
4-byte values. <p>Class and fields descriptions are quoted from Microsoft Office Word
97-2007 Binary File Format and [MS-DOC] - v20110608 Word (.doc) Binary File Format
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
Specification [*.doc] and [MS-DOC] - v20110608 Word (.doc) Binary File Format
*/
@Internal
public abstract class FibRgLw97AbstractType
@ -205,33 +207,12 @@ public abstract class FibRgLw97AbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_cbMac;
result = prime * result + field_2_reserved1;
result = prime * result + field_3_reserved2;
result = prime * result + field_4_ccpText;
result = prime * result + field_5_ccpFtn;
result = prime * result + field_6_ccpHdd;
result = prime * result + field_7_reserved3;
result = prime * result + field_8_ccpAtn;
result = prime * result + field_9_ccpEdn;
result = prime * result + field_10_ccpTxbx;
result = prime * result + field_11_ccpHdrTxbx;
result = prime * result + field_12_reserved4;
result = prime * result + field_13_reserved5;
result = prime * result + field_14_reserved6;
result = prime * result + field_15_reserved7;
result = prime * result + field_16_reserved8;
result = prime * result + field_17_reserved9;
result = prime * result + field_18_reserved10;
result = prime * result + field_19_reserved11;
result = prime * result + field_20_reserved12;
result = prime * result + field_21_reserved13;
result = prime * result + field_22_reserved14;
return result;
public int hashCode() {
return Objects.hash(field_1_cbMac, field_2_reserved1, field_3_reserved2, field_4_ccpText, field_5_ccpFtn,
field_6_ccpHdd, field_7_reserved3, field_8_ccpAtn, field_9_ccpEdn, field_10_ccpTxbx, field_11_ccpHdrTxbx,
field_12_reserved4, field_13_reserved5, field_14_reserved6, field_15_reserved7, field_16_reserved8,
field_17_reserved9, field_18_reserved10, field_19_reserved11, field_20_reserved12, field_21_reserved13,
field_22_reserved14);
}
public String toString()

View File

@ -18,6 +18,8 @@
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
@ -27,17 +29,17 @@ import org.apache.poi.util.Internal;
an LVL or LVLF and HTML lists. The values do not define list properties. <p>Class and
fields descriptions are quoted from [MS-DOC] -- v20110315 Word (.doc) Binary File Format
specification
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to [MS-DOC] -- v20110315 Word (.doc) Binary File Format
specification
*/
@Internal
public abstract class GrfhicAbstractType
@ -98,12 +100,8 @@ public abstract class GrfhicAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_grfhic;
return result;
public int hashCode() {
return Objects.hash(field_1_grfhic);
}
public String toString()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.hwpf.model.Grfhic;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -23,17 +25,17 @@ import org.apache.poi.util.LittleEndian;
/**
* List Format Override (LFO). <p>Class and fields descriptions are quoted from
[MS-DOC] --v20110315; Word (.doc) Binary File Format
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to [MS-DOC] --v20110315; Word (.doc) Binary File Format;
Copyright (c) Microsoft Corporation
*/
@Internal
public abstract class LFOAbstractType
@ -122,19 +124,9 @@ public abstract class LFOAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_lsid;
result = prime * result + field_2_unused1;
result = prime * result + field_3_unused2;
result = prime * result + field_4_clfolvl;
result = prime * result + field_5_ibstFltAutoNum;
result = prime * result
+ ((field_6_grfhic == null) ? 0 : field_6_grfhic.hashCode());
result = prime * result + field_7_unused3;
return result;
public int hashCode() {
return Objects.hash(field_1_lsid, field_2_unused1, field_3_unused2, field_4_clfolvl, field_5_ibstFltAutoNum,
field_6_grfhic, field_7_unused3);
}
public String toString()

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -25,17 +27,17 @@ import org.apache.poi.util.LittleEndian;
information of a corresponding LVL. <p>Class and fields descriptions are quoted from
Microsoft Office Word 97-2007 Binary File Format and [MS-DOC] - v20110608 Word (.doc) Binary
File Format
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
Specification [*.doc] and [MS-DOC] - v20110608 Word (.doc) Binary File Format
*/
@Internal
public abstract class LFOLVLBaseAbstractType
@ -99,13 +101,8 @@ public abstract class LFOLVLBaseAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_iStartAt;
result = prime * result + field_2_flags;
return result;
public int hashCode() {
return Objects.hash(field_1_iStartAt,field_2_flags);
}
public String toString()

View File

@ -27,17 +27,17 @@ import org.apache.poi.util.LittleEndian;
* The LSTF structure contains formatting properties that apply to an entire list.
<p>Class and fields descriptions are quoted from Microsoft Office Word 97-2007 Binary
File Format and [MS-DOC] - v20110608 Word (.doc) Binary File Format
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
Specification [*.doc] and [MS-DOC] - v20110608 Word (.doc) Binary File Format
*/
@Internal
public abstract class LSTFAbstractType
@ -123,16 +123,8 @@ public abstract class LSTFAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_lsid;
result = prime * result + field_2_tplc;
result = prime * result + Arrays.hashCode( field_3_rgistdPara );
result = prime * result + field_4_flags;
result = prime * result + field_5_grfhic.hashCode();
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{field_1_lsid, field_2_tplc, field_3_rgistdPara, field_4_flags, field_5_grfhic});
}
public String toString()

View File

@ -28,17 +28,17 @@ import org.apache.poi.util.LittleEndian;
* The LVLF structure contains formatting properties for an individual level in a
list. <p>Class and fields descriptions are quoted from Microsoft Office Word 97-2007
Binary File Format and [MS-DOC] - v20110608 Word (.doc) Binary File Format
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
Specification [*.doc] and [MS-DOC] - v20110608 Word (.doc) Binary File Format
*/
@Internal
public abstract class LVLFAbstractType
@ -155,22 +155,10 @@ public abstract class LVLFAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_iStartAt;
result = prime * result + field_2_nfc;
result = prime * result + field_3_info;
result = prime * result + Arrays.hashCode( field_4_rgbxchNums );
result = prime * result + field_5_ixchFollow;
result = prime * result + field_6_dxaIndentSav;
result = prime * result + field_7_unused2;
result = prime * result + field_8_cbGrpprlChpx;
result = prime * result + field_9_cbGrpprlPapx;
result = prime * result + field_10_ilvlRestartLim;
result = prime * result + field_11_grfhic.hashCode();
return result;
public int hashCode() {
return Arrays.deepHashCode(new Object[]{field_1_iStartAt, field_2_nfc, field_3_info, field_4_rgbxchNums,
field_5_ixchFollow, field_6_dxaIndentSav, field_7_unused2, field_8_cbGrpprlChpx, field_9_cbGrpprlPapx,
field_10_ilvlRestartLim, field_11_grfhic});
}
public String toString()

View File

@ -17,6 +17,8 @@
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -26,16 +28,16 @@ import org.apache.poi.util.LittleEndian;
shading. As an exception to the constraints that are specified by Ico and Ipat, a Shd80 can
be set to Shd80Nil and specifies that no shading is applied. <p>Class and fields
descriptions are quoted from Word (.doc) Binary File Format by Microsoft Corporation
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to Word (.doc) Binary File Format by Microsoft Corporation.
*/
@Internal
public abstract class SHD80AbstractType
@ -91,12 +93,8 @@ public abstract class SHD80AbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_value;
return result;
public int hashCode() {
return Objects.hash(field_1_value);
}
public String toString()

View File

@ -18,6 +18,8 @@
package org.apache.poi.hwpf.model.types;
import java.util.Objects;
import org.apache.poi.hwpf.model.Colorref;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian;
@ -26,16 +28,16 @@ import org.apache.poi.util.LittleEndian;
* The Shd structure specifies the colors and pattern that are used for background shading. <p>Class
and
fields descriptions are quoted from Word (.doc) Binary File Format by Microsoft Corporation
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to Word (.doc) Binary File Format by Microsoft Corporation.
*/
@Internal
public abstract class SHDAbstractType
@ -100,14 +102,8 @@ public abstract class SHDAbstractType
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_cvFore.hashCode();
result = prime * result + field_2_cvBack.hashCode();
result = prime * result + field_3_ipat;
return result;
public int hashCode() {
return Objects.hash(field_1_cvFore,field_2_cvBack,field_3_ipat);
}
public String toString()

View File

@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.poi.hwpf.model.BookmarksTables;
import org.apache.poi.hwpf.model.GenericPropertyNode;
@ -31,7 +32,7 @@ import org.apache.poi.hwpf.model.PropertyNode;
/**
* Implementation of user-friendly interface for document bookmarks
*
*
* @author Sergey Vladimirov (vlsergey {at} gmail {doc} com)
*/
public class BookmarksImpl implements Bookmarks
@ -100,9 +101,8 @@ public class BookmarksImpl implements Bookmarks
}
@Override
public int hashCode()
{
return 31 + ( first == null ? 0 : first.hashCode() );
public int hashCode() {
return Objects.hash(first);
}
public void setName( String name )

View File

@ -25,7 +25,7 @@ import org.apache.poi.util.LittleEndian;
* This data structure is used by a paragraph to determine how it should drop
* its first letter. I think its the visual effect that will show a giant first
* letter to a paragraph. I've seen this used in the first paragraph of a book
*
*
* @author Ryan Ackley
*/
public final class DropCapSpecifier implements Cloneable
@ -81,8 +81,7 @@ public final class DropCapSpecifier implements Cloneable
}
@Override
public int hashCode()
{
public int hashCode() {
return _fdct;
}

View File

@ -16,6 +16,8 @@
==================================================================== */
package org.apache.poi.hwpf.usermodel;
import java.util.Objects;
import org.apache.poi.hwpf.model.types.TLPAbstractType;
public class TableAutoformatLookSpecifier extends TLPAbstractType implements
@ -65,13 +67,8 @@ public class TableAutoformatLookSpecifier extends TLPAbstractType implements
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + field_1_itl;
result = prime * result + field_2_tlp_flags;
return result;
public int hashCode() {
return Objects.hash(field_1_itl,field_2_tlp_flags);
}
public boolean isEmpty()