65 |
private int end; |
private int end; |
66 |
|
|
67 |
/** |
/** |
68 |
|
* This is the field attribute value. |
69 |
|
*/ |
70 |
|
private Format.Field field_attribute; |
71 |
|
|
72 |
|
/** |
73 |
|
* This method initializes a new instance of <code>FieldPosition</code> |
74 |
|
* to have the specified field attribute. The attribute will be used as |
75 |
|
* an id. |
76 |
|
* |
77 |
|
* @param field The field format attribute. |
78 |
|
*/ |
79 |
|
public FieldPosition (Format.Field field) |
80 |
|
{ |
81 |
|
this.field_attribute = field; |
82 |
|
} |
83 |
|
|
84 |
|
/** |
85 |
|
* This method initializes a new instance of <code>FieldPosition</code> |
86 |
|
* to have the specified field attribute. The attribute will be used as |
87 |
|
* an id is non null. The integer field id is only used if the Format.Field |
88 |
|
* attribute is not used by the formatter. |
89 |
|
* |
90 |
|
* @param field The field format attribute. |
91 |
|
* @param field_id The field identifier value. |
92 |
|
*/ |
93 |
|
public FieldPosition (Format.Field field, int field_id) |
94 |
|
{ |
95 |
|
this.field_attribute = field; |
96 |
|
this.field_id = field_id; |
97 |
|
} |
98 |
|
|
99 |
|
/** |
100 |
* This method initializes a new instance of <code>FieldPosition</code> to |
* This method initializes a new instance of <code>FieldPosition</code> to |
101 |
* have the specified field id. |
* have the specified field id. |
102 |
* |
* |
117 |
return field_id; |
return field_id; |
118 |
} |
} |
119 |
|
|
120 |
|
public Format.Field getFieldAttribute () |
121 |
|
{ |
122 |
|
return field_attribute; |
123 |
|
} |
124 |
|
|
125 |
/** |
/** |
126 |
* This method returns the beginning index for this field. |
* This method returns the beginning index for this field. |
127 |
* |
* |
169 |
* <ul> |
* <ul> |
170 |
* <li>The specified object is not <code>null</code>. |
* <li>The specified object is not <code>null</code>. |
171 |
* <li>The specified object is an instance of <code>FieldPosition</code>. |
* <li>The specified object is an instance of <code>FieldPosition</code>. |
172 |
* <li>The specified object has the same field identifier and beginning |
* <li>The specified object has the same field identifier, field attribute |
173 |
* and ending index as this object. |
* and beginning and ending index as this object. |
174 |
* </ul> |
* </ul> |
175 |
* |
* |
176 |
* @param obj The object to test for equality to this object. |
* @param obj The object to test for equality to this object. |
180 |
*/ |
*/ |
181 |
public boolean equals (Object obj) |
public boolean equals (Object obj) |
182 |
{ |
{ |
183 |
if (! (obj instanceof FieldPosition)) |
if (this == obj) |
184 |
|
return true; |
185 |
|
|
186 |
|
if (obj == null || obj.getClass() != this.getClass()) |
187 |
return false; |
return false; |
188 |
|
|
189 |
FieldPosition fp = (FieldPosition) obj; |
FieldPosition fp = (FieldPosition) obj; |
190 |
return (field_id == fp.field_id |
return (field_id == fp.field_id |
191 |
|
&& (field_attribute == fp.field_attribute |
192 |
|
|| (field_attribute != null |
193 |
|
&& field_attribute.equals(fp.field_attribute))) |
194 |
&& begin == fp.begin |
&& begin == fp.begin |
195 |
&& end == fp.end); |
&& end == fp.end); |
196 |
} |
} |
197 |
|
|
198 |
|
|
199 |
|
/** |
200 |
|
* This method returns a hash value for this object |
201 |
|
* |
202 |
|
* @return A hash value for this object. |
203 |
|
*/ |
204 |
|
public int hashCode () |
205 |
|
{ |
206 |
|
int hash = 5; |
207 |
|
|
208 |
|
hash = 31 * hash + field_id; |
209 |
|
hash = 31 * hash + begin; |
210 |
|
hash = 31 * hash + end; |
211 |
|
hash = 31 * hash + |
212 |
|
(null == field_attribute ? 0 : field_attribute.hashCode()); |
213 |
|
|
214 |
|
return hash; |
215 |
|
} |
216 |
|
|
217 |
/** |
/** |
218 |
* This method returns a <code>String</code> representation of this |
* This method returns a <code>String</code> representation of this |
219 |
* object. |
* object. |
222 |
*/ |
*/ |
223 |
public String toString () |
public String toString () |
224 |
{ |
{ |
225 |
return (getClass ().getName () + "[field=" + getField () + ",beginIndex=" |
return (getClass ().getName () |
226 |
+ getBeginIndex () + ",endIndex=" + getEndIndex () + "]"); |
+ "[field=" + getField () |
227 |
|
+ ",attribute=" + getFieldAttribute () |
228 |
|
+ ",beginIndex=" + getBeginIndex () |
229 |
|
+ ",endIndex=" + getEndIndex () |
230 |
|
+ "]"); |
231 |
} |
} |
232 |
} |
} |