summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2003-11-27 10:08:33 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2003-11-27 10:08:33 +0000
commit546c6a51a93b40d0c698f26a413f83fd459680d7 (patch)
treec2bdc3b8394f16e21eb8b45b26236303d929d75a /libjava
parent30c163f6fc8dacd55e65db2f52108faa0a20d5c5 (diff)
downloadgcc-546c6a51a93b40d0c698f26a413f83fd459680d7.tar.gz
2003-11-27 Dalibor Topic <robilad@kaffe.org>
* java/text/FieldPosition.java (equals): Adapted to handle field_attribute. Added fast-circuit check for comparison to self. Replaced use of instanceof by getClass to fix symmetry for derived types. (toString): Adapted to handle field_attribute. Improved readability. (hashCode): New method. 2003-11-27 Guilhem Lavaux <guilhem@kaffe.org> * java/text/FieldPosition.java (field_attribute): New field. (FieldPosition (Format.Field), FieldPosition(Format.Field, int), getFieldAttribute): New methods. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73988 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog15
-rw-r--r--libjava/java/text/FieldPosition.java76
2 files changed, 86 insertions, 5 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index fb7e8f7cd9d..a7a388d5dda 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,18 @@
+2003-11-27 Dalibor Topic <robilad@kaffe.org>
+
+ * java/text/FieldPosition.java (equals): Adapted to handle
+ field_attribute. Added fast-circuit check for comparison to self.
+ Replaced use of instanceof by getClass to fix symmetry for derived
+ types.
+ (toString): Adapted to handle field_attribute. Improved readability.
+ (hashCode): New method.
+
+2003-11-27 Guilhem Lavaux <guilhem@kaffe.org>
+
+ * java/text/FieldPosition.java (field_attribute): New field.
+ (FieldPosition (Format.Field), FieldPosition(Format.Field, int),
+ getFieldAttribute): New methods.
+
2003-11-27 Guilhem Lavaux <guilhem@kaffe.org>
* java/text/DecimalFormatSymbols.java (locale): New field.
diff --git a/libjava/java/text/FieldPosition.java b/libjava/java/text/FieldPosition.java
index b31ce707a9f..56f19cde682 100644
--- a/libjava/java/text/FieldPosition.java
+++ b/libjava/java/text/FieldPosition.java
@@ -65,6 +65,38 @@ public class FieldPosition
private int end;
/**
+ * This is the field attribute value.
+ */
+ private Format.Field field_attribute;
+
+ /**
+ * This method initializes a new instance of <code>FieldPosition</code>
+ * to have the specified field attribute. The attribute will be used as
+ * an id.
+ *
+ * @param field The field format attribute.
+ */
+ public FieldPosition (Format.Field field)
+ {
+ this.field_attribute = field;
+ }
+
+ /**
+ * This method initializes a new instance of <code>FieldPosition</code>
+ * to have the specified field attribute. The attribute will be used as
+ * an id is non null. The integer field id is only used if the Format.Field
+ * attribute is not used by the formatter.
+ *
+ * @param field The field format attribute.
+ * @param field_id The field identifier value.
+ */
+ public FieldPosition (Format.Field field, int field_id)
+ {
+ this.field_attribute = field;
+ this.field_id = field_id;
+ }
+
+ /**
* This method initializes a new instance of <code>FieldPosition</code> to
* have the specified field id.
*
@@ -85,6 +117,11 @@ public class FieldPosition
return field_id;
}
+ public Format.Field getFieldAttribute ()
+ {
+ return field_attribute;
+ }
+
/**
* This method returns the beginning index for this field.
*
@@ -132,8 +169,8 @@ public class FieldPosition
* <ul>
* <li>The specified object is not <code>null</code>.
* <li>The specified object is an instance of <code>FieldPosition</code>.
- * <li>The specified object has the same field identifier and beginning
- * and ending index as this object.
+ * <li>The specified object has the same field identifier, field attribute
+ * and beginning and ending index as this object.
* </ul>
*
* @param obj The object to test for equality to this object.
@@ -143,15 +180,40 @@ public class FieldPosition
*/
public boolean equals (Object obj)
{
- if (! (obj instanceof FieldPosition))
+ if (this == obj)
+ return true;
+
+ if (obj == null || obj.getClass() != this.getClass())
return false;
FieldPosition fp = (FieldPosition) obj;
return (field_id == fp.field_id
+ && (field_attribute == fp.field_attribute
+ || (field_attribute != null
+ && field_attribute.equals(fp.field_attribute)))
&& begin == fp.begin
&& end == fp.end);
}
+
+ /**
+ * This method returns a hash value for this object
+ *
+ * @return A hash value for this object.
+ */
+ public int hashCode ()
+ {
+ int hash = 5;
+
+ hash = 31 * hash + field_id;
+ hash = 31 * hash + begin;
+ hash = 31 * hash + end;
+ hash = 31 * hash +
+ (null == field_attribute ? 0 : field_attribute.hashCode());
+
+ return hash;
+ }
+
/**
* This method returns a <code>String</code> representation of this
* object.
@@ -160,7 +222,11 @@ public class FieldPosition
*/
public String toString ()
{
- return (getClass ().getName () + "[field=" + getField () + ",beginIndex="
- + getBeginIndex () + ",endIndex=" + getEndIndex () + "]");
+ return (getClass ().getName ()
+ + "[field=" + getField ()
+ + ",attribute=" + getFieldAttribute ()
+ + ",beginIndex=" + getBeginIndex ()
+ + ",endIndex=" + getEndIndex ()
+ + "]");
}
}