public class DeweyDecimal extends java.lang.Object implements java.lang.Comparable<DeweyDecimal>
Constructor and Description |
---|
DeweyDecimal(int[] components)
Construct a DeweyDecimal from an array of integer components.
|
DeweyDecimal(java.lang.String string)
Construct a DeweyDecimal from string in DeweyDecimal format.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(DeweyDecimal other)
Compares this DeweyDecimal with another one.
|
boolean |
equals(java.lang.Object o) |
int |
get(int index)
Return the component at specified index.
|
int |
getSize()
Return number of components in
DeweyDecimal . |
int |
hashCode() |
boolean |
isEqual(DeweyDecimal other)
Return
true if this DeweyDecimal is
equal to the other DeweyDecimal . |
boolean |
isGreaterThan(DeweyDecimal other)
Return
true if this DeweyDecimal is
greater than the other DeweyDecimal . |
boolean |
isGreaterThanOrEqual(DeweyDecimal other)
Return
true if this DeweyDecimal is
greater than or equal to the other DeweyDecimal . |
boolean |
isLessThan(DeweyDecimal other)
Return
true if this DeweyDecimal is
less than the other DeweyDecimal . |
boolean |
isLessThanOrEqual(DeweyDecimal other)
Return
true if this DeweyDecimal is
less than or equal to the other DeweyDecimal . |
java.lang.String |
toString()
Return string representation of
DeweyDecimal . |
public DeweyDecimal(int[] components)
components
- an array of integer components.public DeweyDecimal(java.lang.String string) throws java.lang.NumberFormatException
string
- the string in dewey decimal formatjava.lang.NumberFormatException
- if string is malformedpublic int getSize()
DeweyDecimal
.public int get(int index)
index
- the index of componentspublic boolean isEqual(DeweyDecimal other)
true
if this DeweyDecimal
is
equal to the other DeweyDecimal
.other
- the other DeweyDecimalpublic boolean isLessThan(DeweyDecimal other)
true
if this DeweyDecimal
is
less than the other DeweyDecimal
.other
- the other DeweyDecimalpublic boolean isLessThanOrEqual(DeweyDecimal other)
true
if this DeweyDecimal
is
less than or equal to the other DeweyDecimal
.other
- the other DeweyDecimalpublic boolean isGreaterThan(DeweyDecimal other)
true
if this DeweyDecimal
is
greater than the other DeweyDecimal
.other
- the other DeweyDecimalpublic boolean isGreaterThanOrEqual(DeweyDecimal other)
true
if this DeweyDecimal
is
greater than or equal to the other DeweyDecimal
.other
- the other DeweyDecimalpublic java.lang.String toString()
DeweyDecimal
.toString
in class java.lang.Object
public int compareTo(DeweyDecimal other)
compareTo
in interface java.lang.Comparable<DeweyDecimal>
other
- another DeweyDecimal to compare withComparable.compareTo(Object)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object