fix generics warning

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1143740 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-07-07 09:59:51 +00:00
parent ad4cef7557
commit d1eb54b129
8 changed files with 29 additions and 21 deletions

View File

@ -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<T extends BytePropertyNode<T>> extends
PropertyNode<T>
{
private final int startBytes;
private final int endBytes;

View File

@ -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<CHPX>
{
public CHPX(int fcStart, int fcEnd, CharIndexTranslator translator, byte[] grpprl)

View File

@ -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<CachedPropertyNode>
{
protected SoftReference _propCache;

View File

@ -18,7 +18,7 @@
package org.apache.poi.hwpf.model;
public final class GenericPropertyNode
extends PropertyNode
extends PropertyNode<GenericPropertyNode>
{
public GenericPropertyNode(int start, int end, byte[] buf)
{

View File

@ -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<PAPX> {
private ParagraphHeight _phe;
private int _hugeGrpprlOffset = -1;

View File

@ -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<T extends PropertyNode<T>> implements Comparable<T>, 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;

View File

@ -23,7 +23,7 @@ import org.apache.poi.hwpf.usermodel.SectionProperties;
/**
*/
public final class SEPX extends BytePropertyNode
public final class SEPX extends BytePropertyNode<SEPX>
{
SectionDescriptor _sed;

View File

@ -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<TextPiece>
{
private boolean _usesUnicode;