From 1757e4af53392edc9468f59f0f0be685c60daa86 Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Thu, 7 Jul 2011 09:59:51 +0000 Subject: [PATCH] fix generics warning git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1143740 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hwpf/model/BytePropertyNode.java | 4 ++- .../src/org/apache/poi/hwpf/model/CHPX.java | 6 ++--- .../poi/hwpf/model/CachedPropertyNode.java | 6 ++--- .../poi/hwpf/model/GenericPropertyNode.java | 2 +- .../src/org/apache/poi/hwpf/model/PAPX.java | 2 +- .../apache/poi/hwpf/model/PropertyNode.java | 26 ++++++++++++------- .../src/org/apache/poi/hwpf/model/SEPX.java | 2 +- .../org/apache/poi/hwpf/model/TextPiece.java | 2 +- 8 files changed, 29 insertions(+), 21 deletions(-) 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 59ac18e7b1..2bc5f004cf 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 940f20438f..7aebf89f02 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 565cdb2cb8..51928e6cd5 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 28c380383f..7b2730d79a 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 6ea71ebccf..1707ccd71a 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 6c5a23972a..251458e3f6 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 880d4956ee..b6ae393d67 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 1ae5f604d2..50e1127b5d 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; -- 2.39.5