org.apache.tools.ant.utilClass DeweyDecimal
- java.lang.Object
- org.apache.tools.ant.util.DeweyDecimal
- All Implemented Interfaces:
- java.lang.Comparable<DeweyDecimal>
- Direct Known Subclasses:
- DeweyDecimal
public class DeweyDecimal extends java.lang.Object implements java.lang.Comparable<DeweyDecimal>Utility class to contain version numbers in "Dewey Decimal" syntax. Numbers in the "Dewey Decimal" syntax consist of positive decimal integers separated by periods ".". For example, "2.0" or "1.2.3.4.5.6.7". This allows an extensible number to be used to represent major, minor, micro, etc versions. The version number must begin with a number.
Constructor Summary
Constructors 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.
Method Summary
All Methods Instance Methods Concrete Methods 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 inDeweyDecimal
.int
hashCode()
boolean
isEqual(DeweyDecimal other)
Returntrue
if thisDeweyDecimal
is equal to the otherDeweyDecimal
.boolean
isGreaterThan(DeweyDecimal other)
Returntrue
if thisDeweyDecimal
is greater than the otherDeweyDecimal
.boolean
isGreaterThanOrEqual(DeweyDecimal other)
Returntrue
if thisDeweyDecimal
is greater than or equal to the otherDeweyDecimal
.boolean
isLessThan(DeweyDecimal other)
Returntrue
if thisDeweyDecimal
is less than the otherDeweyDecimal
.boolean
isLessThanOrEqual(DeweyDecimal other)
Returntrue
if thisDeweyDecimal
is less than or equal to the otherDeweyDecimal
.java.lang.String
toString()
Return string representation ofDeweyDecimal
.
Constructor Detail
DeweyDecimal
public DeweyDecimal(int[] components)Construct a DeweyDecimal from an array of integer components.
- Parameters:
components
- an array of integer components.
DeweyDecimal
public DeweyDecimal(java.lang.String string) throws java.lang.NumberFormatExceptionConstruct a DeweyDecimal from string in DeweyDecimal format.
- Parameters:
string
- the string in dewey decimal format- Throws:
java.lang.NumberFormatException
- if string is malformed
Method Detail
getSize
public int getSize()Return number of components inDeweyDecimal
.
- Returns:
- the number of components in dewey decimal
get
public int get(int index)Return the component at specified index.
- Parameters:
index
- the index of components- Returns:
- the value of component at index
isEqual
public boolean isEqual(DeweyDecimal other)Returntrue
if thisDeweyDecimal
is equal to the otherDeweyDecimal
.
- Parameters:
other
- the other DeweyDecimal- Returns:
- true if equal to other DeweyDecimal, false otherwise
isLessThan
public boolean isLessThan(DeweyDecimal other)Returntrue
if thisDeweyDecimal
is less than the otherDeweyDecimal
.
- Parameters:
other
- the other DeweyDecimal- Returns:
- true if less than other DeweyDecimal, false otherwise
isLessThanOrEqual
public boolean isLessThanOrEqual(DeweyDecimal other)Returntrue
if thisDeweyDecimal
is less than or equal to the otherDeweyDecimal
.
- Parameters:
other
- the other DeweyDecimal- Returns:
- true if less than or equal to other DeweyDecimal, false otherwise
isGreaterThan
public boolean isGreaterThan(DeweyDecimal other)Returntrue
if thisDeweyDecimal
is greater than the otherDeweyDecimal
.
- Parameters:
other
- the other DeweyDecimal- Returns:
- true if greater than other DeweyDecimal, false otherwise
isGreaterThanOrEqual
public boolean isGreaterThanOrEqual(DeweyDecimal other)Returntrue
if thisDeweyDecimal
is greater than or equal to the otherDeweyDecimal
.
- Parameters:
other
- the other DeweyDecimal- Returns:
- true if greater than or equal to other DeweyDecimal, false otherwise
toString
public java.lang.String toString()Return string representation ofDeweyDecimal
.
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string representation of DeweyDecimal.
compareTo
public int compareTo(DeweyDecimal other)Compares this DeweyDecimal with another one.
- Specified by:
compareTo
in interfacejava.lang.Comparable<DeweyDecimal>
- Parameters:
other
- another DeweyDecimal to compare with- Returns:
- result
- See Also:
Comparable.compareTo(Object)
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object