poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1143733 - in /poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model: PieceDescriptor.java TextPiece.java
Date Thu, 07 Jul 2011 09:51:21 GMT
Author: sergey
Date: Thu Jul  7 09:51:21 2011
New Revision: 1143733

URL: http://svn.apache.org/viewvc?rev=1143733&view=rev
Log:
add toString() methods to PieceDescriptor and TextPiece; add hashCode() to PieceDescriptor

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PieceDescriptor.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PieceDescriptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PieceDescriptor.java?rev=1143733&r1=1143732&r2=1143733&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PieceDescriptor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PieceDescriptor.java Thu Jul  7
09:51:21 2011
@@ -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" ) + ")";
+    }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java?rev=1143733&r1=1143732&r2=1143733&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java Thu Jul  7 09:51:21
2011
@@ -185,4 +185,10 @@ public final class TextPiece extends Pro
    {
      return getStart();
    }
+
+    public String toString()
+    {
+        return "TextPiece from " + getStart() + " to " + getEnd() + " ("
+                + getPieceDescriptor() + ")";
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message