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:
Sergey Vladimirov 2011-07-07 09:51:21 +00:00
parent 65787fc1b9
commit 4c9a35ee4d
2 changed files with 41 additions and 5 deletions

View File

@ -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" ) + ")";
}
}

View File

@ -185,4 +185,10 @@ public final class TextPiece extends PropertyNode implements Comparable
{
return getStart();
}
public String toString()
{
return "TextPiece from " + getStart() + " to " + getEnd() + " ("
+ getPieceDescriptor() + ")";
}
}