add toString() methods to PieceDescriptor and TextPiece; add hashCode() to PieceDescriptor
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1143733 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
65787fc1b9
commit
4c9a35ee4d
@ -97,10 +97,40 @@ public final class PieceDescriptor
|
||||
return 8;
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
PieceDescriptor pd = (PieceDescriptor)o;
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + descriptor;
|
||||
result = prime * result + prm;
|
||||
result = prime * result + ( unicode ? 1231 : 1237 );
|
||||
return result;
|
||||
}
|
||||
|
||||
return descriptor == pd.descriptor && prm == pd.prm && unicode == pd.unicode;
|
||||
}
|
||||
@Override
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
return true;
|
||||
if ( obj == null )
|
||||
return false;
|
||||
if ( getClass() != obj.getClass() )
|
||||
return false;
|
||||
PieceDescriptor other = (PieceDescriptor) obj;
|
||||
if ( descriptor != other.descriptor )
|
||||
return false;
|
||||
if ( prm != other.prm )
|
||||
return false;
|
||||
if ( unicode != other.unicode )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "PieceDescriptor (pos: " + getFilePosition() + "; "
|
||||
+ ( isUnicode() ? "unicode" : "non-unicode" ) + ")";
|
||||
}
|
||||
}
|
||||
|
@ -185,4 +185,10 @@ public final class TextPiece extends PropertyNode implements Comparable
|
||||
{
|
||||
return getStart();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "TextPiece from " + getStart() + " to " + getEnd() + " ("
|
||||
+ getPieceDescriptor() + ")";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user