diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java b/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java index 59ac18e7b..2bc5f004c 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java @@ -24,7 +24,9 @@ package org.apache.poi.hwpf.model; * It handles the conversion as required between bytes * and characters. */ -public abstract class BytePropertyNode extends PropertyNode { +public abstract class BytePropertyNode> extends + PropertyNode +{ private final int startBytes; private final int endBytes; diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java index 940f20438..7aebf89f0 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/CHPX.java @@ -17,9 +17,9 @@ package org.apache.poi.hwpf.model; -import org.apache.poi.hwpf.usermodel.CharacterProperties; -import org.apache.poi.hwpf.sprm.SprmBuffer; import org.apache.poi.hwpf.sprm.CharacterSprmUncompressor; +import org.apache.poi.hwpf.sprm.SprmBuffer; +import org.apache.poi.hwpf.usermodel.CharacterProperties; /** * DANGER - works in bytes! @@ -31,7 +31,7 @@ import org.apache.poi.hwpf.sprm.CharacterSprmUncompressor; * @author Ryan Ackley */ -public final class CHPX extends BytePropertyNode +public final class CHPX extends BytePropertyNode { public CHPX(int fcStart, int fcEnd, CharIndexTranslator translator, byte[] grpprl) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/CachedPropertyNode.java b/src/scratchpad/src/org/apache/poi/hwpf/model/CachedPropertyNode.java index 565cdb2cb..51928e6cd 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/CachedPropertyNode.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/CachedPropertyNode.java @@ -17,12 +17,12 @@ package org.apache.poi.hwpf.model; -import org.apache.poi.hwpf.sprm.SprmBuffer; - import java.lang.ref.SoftReference; +import org.apache.poi.hwpf.sprm.SprmBuffer; + public final class CachedPropertyNode - extends PropertyNode + extends PropertyNode { protected SoftReference _propCache; diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/GenericPropertyNode.java b/src/scratchpad/src/org/apache/poi/hwpf/model/GenericPropertyNode.java index 28c380383..7b2730d79 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/GenericPropertyNode.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/GenericPropertyNode.java @@ -18,7 +18,7 @@ package org.apache.poi.hwpf.model; public final class GenericPropertyNode - extends PropertyNode + extends PropertyNode { public GenericPropertyNode(int start, int end, byte[] buf) { diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java index 6ea71ebcc..1707ccd71 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPX.java @@ -34,7 +34,7 @@ import org.apache.poi.util.LittleEndian; * @author Ryan Ackley */ -public final class PAPX extends BytePropertyNode { +public final class PAPX extends BytePropertyNode { private ParagraphHeight _phe; private int _hugeGrpprlOffset = -1; diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java index 6c5a23972..251458e3f 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java @@ -17,11 +17,11 @@ package org.apache.poi.hwpf.model; +import java.util.Arrays; + import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogger; -import java.util.Arrays; - /** * Represents a lightweight node in the Trees used to store content * properties. @@ -31,7 +31,7 @@ import java.util.Arrays; * * @author Ryan Ackley */ -public abstract class PropertyNode implements Comparable, Cloneable +public abstract class PropertyNode> implements Comparable, Cloneable { private final static POILogger _logger = POILogFactory.getLogger(PropertyNode.class); protected Object _buf; @@ -114,16 +114,22 @@ public abstract class PropertyNode implements Comparable, Cloneable protected boolean limitsAreEqual(Object o) { - return ((PropertyNode)o).getStart() == _cpStart && - ((PropertyNode)o).getEnd() == _cpEnd; + return ((PropertyNode)o).getStart() == _cpStart && + ((PropertyNode)o).getEnd() == _cpEnd; } + @Override + public int hashCode() + { + return this._cpStart * 31 + this._buf.hashCode(); + } + public boolean equals(Object o) { if (limitsAreEqual(o)) { - Object testBuf = ((PropertyNode)o)._buf; + Object testBuf = ((PropertyNode)o)._buf; if (testBuf instanceof byte[] && _buf instanceof byte[]) { return Arrays.equals((byte[])testBuf, (byte[])_buf); @@ -133,18 +139,18 @@ public abstract class PropertyNode implements Comparable, Cloneable return false; } - public Object clone() + public T clone() throws CloneNotSupportedException { - return super.clone(); + return (T) super.clone(); } /** * Used for sorting in collections. */ - public int compareTo(Object o) + public int compareTo(T o) { - int cpEnd = ((PropertyNode)o).getEnd(); + int cpEnd = o.getEnd(); if(_cpEnd == cpEnd) { return 0; diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java b/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java index 880d4956e..b6ae393d6 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/SEPX.java @@ -23,7 +23,7 @@ import org.apache.poi.hwpf.usermodel.SectionProperties; /** */ -public final class SEPX extends BytePropertyNode +public final class SEPX extends BytePropertyNode { SectionDescriptor _sed; diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java b/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java index 1ae5f604d..50e1127b5 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java @@ -28,7 +28,7 @@ import java.io.UnsupportedEncodingException; * @author Ryan Ackley */ -public final class TextPiece extends PropertyNode implements Comparable +public final class TextPiece extends PropertyNode { private boolean _usesUnicode;