net.sf.jabb.util.col
Class ComparableArray

java.lang.Object
  extended by net.sf.jabb.util.col.ComparableArray
All Implemented Interfaces:
Serializable, Comparable<Object>

public class ComparableArray
extends Object
implements Comparable<Object>, Serializable

Encapsulates multiple Comparable (implements Comparable Interface) values into one object, which is suitable to be used as key object of Map.
把多个可比较(实现了Comparable)值封装在这一个对象里,适合用来作为Map的key。

It supports hashCode(), toString(), equals(), compareTo() methods.

它支持hashCode(), toString(), equals(), compareTo()方法。

Classes that are Comparable include:
可比较(实现了Comparable)的类包括:

Authenticator.RequestorType, BigDecimal, BigInteger, Boolean, Byte, ByteBuffer, Calendar, Character, CharBuffer, Charset, ClientInfoStatus, CollationKey, Component.BaselineResizeBehavior, CompositeName, CompoundName, Date, Date, Desktop.Action, Diagnostic.Kind, Dialog.ModalExclusionType, Dialog.ModalityType, Double, DoubleBuffer, DropMode, ElementKind, ElementType, Enum, File, Float, FloatBuffer, Formatter.BigDecimalLayoutForm, FormSubmitEvent.MethodType, GregorianCalendar, GroupLayout.Alignment, IntBuffer, Integer, JavaFileObject.Kind, JTable.PrintMode, KeyRep.Type, LayoutStyle.ComponentPlacement, LdapName, Long, LongBuffer, MappedByteBuffer, MemoryType, MessageContext.Scope, Modifier, MultipleGradientPaint.ColorSpaceType, MultipleGradientPaint.CycleMethod, NestingKind, Normalizer.Form, ObjectName, ObjectStreamField, Proxy.Type, Rdn, Resource.AuthenticationType, RetentionPolicy, RoundingMode, RowFilter.ComparisonType, RowIdLifetime, RowSorterEvent.Type, Service.Mode, Short, ShortBuffer, SOAPBinding.ParameterStyle, SOAPBinding.Style, SOAPBinding.Use, SortOrder, SourceVersion, SSLEngineResult.HandshakeStatus, SSLEngineResult.Status, StandardLocation, String, SwingWorker.StateValue, Thread.State, Time, Timestamp, TimeUnit, TrayIcon.MessageType, TypeKind, URI, UUID, WebParam.Mode, XmlAccessOrder, XmlAccessType, XmlNsForm

and IntegerArray, LongArray, NumberArray.

Author:
Zhengmao HU (James)
See Also:
Serialized Form

Field Summary
protected  Comparable[] values
           
 
Constructor Summary
ComparableArray(Comparable... values)
          Constructs an instance that encapsulates specified Comparable values.
创建一个包含这些可比较值的实例。
 
Method Summary
 int compareTo(Object obj)
           
 boolean equals(Object obj)
           
 Object getValue(int index)
          Gets the value in specified position.
获得指定位置的值。
 Object[] getValues()
          Gets all the values encapsulated in this object.
获得所有值。
 int hashCode()
          Gets the calculated hash code.
获得计算得到的hash值。
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

values

protected Comparable[] values
Constructor Detail

ComparableArray

public ComparableArray(Comparable... values)
Constructs an instance that encapsulates specified Comparable values.
创建一个包含这些可比较值的实例。

Parameters:
values - Comparable values that will be encapsulated.
一批将被封装的可比较值。
Method Detail

getValues

public Object[] getValues()
Gets all the values encapsulated in this object.
获得所有值。

Returns:
array of values encapsulated.

getValue

public Object getValue(int index)
Gets the value in specified position.
获得指定位置的值。

Parameters:
index - position (position of the first one is 0)
Returns:
the value

hashCode

public int hashCode()
Gets the calculated hash code.
获得计算得到的hash值。

Overrides:
hashCode in class Object

compareTo

public int compareTo(Object obj)
Specified by:
compareTo in interface Comparable<Object>

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.