@@ -32,19 +32,20 @@ this software and associated documentation files (the "Software"), to deal in
3232 */
3333
3434public class IndexElement implements Comparable {
35- private IndexElementKey key ;
36- private Object element ;
35+ final private IndexElementKey key ;
36+ private Object element ;
37+ final private boolean ex ;
3738
38- public IndexElement (IndexElementKey key , Object element ) {
39+ public IndexElement (IndexElementKey key , Object element , boolean ex ) {
3940 this .key = key ;
4041 this .element = element ;
42+ this .ex = ex ;
4143 }
4244
4345 public int compareTo (final Object obj ) {
4446 final IndexElement j = (IndexElement )obj ;
4547 final int res = this .getKey ().compareTo (j .getKey ());
46- final String clname = this .getElement ().getClass ().getSimpleName ();
47- if (clname .equals ("Integer" )&&res ==0 ) {
48+ if (this .ex && res == 0 ) {
4849 if ((Integer )this .getElement () < (Integer )j .getElement ()) { return -1 ; } else if ((Integer )this .getElement () > (Integer )j .getElement ()) { return 1 ; }
4950 return 0 ;
5051 }
@@ -55,10 +56,6 @@ public IndexElementKey getKey() {
5556 return key ;
5657 }
5758
58- public void setKey (IndexElementKey key ) {
59- this .key = key ;
60- }
61-
6259 public Object getElement () {
6360 return element ;
6461 }
@@ -68,26 +65,7 @@ public void setElement(Object element) {
6865 }
6966
7067 public String ElementToString () {
71- String clname = this .element .getClass ().getSimpleName ();
72- if (clname .equals ("Integer" )) {
73- return "" + (Integer )this .element ;
74- }
75- if (clname .equals ("Long" )) {
76- return "" + (Long )this .element ;
77- }
78- if (clname .equals ("Float" )) {
79- return "" + (Float )this .element ;
80- }
81- if (clname .equals ("Double" )) {
82- return "" + (Double )this .element ;
83- }
84- if (clname .equals ("String" )) {
85- return "" + (String )this .element ;
86- }
87- if (clname .equals ("Date" )) {
88- return "" + (Date )this .element ;
89- }
90- return "Datatype not recognized" ;
68+ return "" + this .element ;
9169 }
9270
9371}
0 commit comments