View Javadoc

1   // -- FILE ------------------------------------------------------------------
2   // name       : AsnIntegralNumber.java
3   // project    : Panter: LI
4   // created    : lep - 2007.01.18
5   // language   : java
6   // environment: JDK 1.5.0
7   // copyright  : (c) 2006 by Panter llc, Switzerland
8   // license    : this is free software licensed under the GPL. see COPYING
9   // --------------------------------------------------------------------------
10  package ch.panter.li.bi.asn;
11  
12  
13  public interface AsnIntegralNumber extends Comparable<Object>
14  {
15  
16    /** The value bits of this instance as an abstract number (Integer, Long, BigInteger).
17     Always safe to call, independent of the result of isValueAnInt().
18     @return the value bits of this instance as an abstract number
19     */
20    public Number getValue();
21  
22    /** Determines whether this instances value matches the one of the given number.
23     @param compare the value to compare our value to
24     @return true if the two numbers represent the same numerical value, false otherwise
25     */
26    public boolean hasSameNumericalValue( final Number compare );
27    
28    /** Determines whether the value of this tag can be represented in a
29     java int. Depending on the result of this method one of the getValueAsInt()
30     or getValueBits() must be used to access the value.
31     @return true if it is safe to call getValueAsInt(), false if getValueBits()
32     must be used.
33     */
34    public boolean isValueAnInt();
35  
36    /** The value of this instance as a java int. May only be called if isValueAnInt()
37     returned true.
38     @return the value of this instance as a java int
39     @throws IllegalStateException in case the value is too large for a java int
40     */
41    public int getValueAsInt();
42  
43    /** The value bits of this instance as an abstract number (Long, BigInteger).
44     May only be called if isValueAnInt() returned false.
45     @return the value bits of this instance as an abstract number
46     @throws IllegalStateException in case the value fits into a java int
47     */
48    public Number getValueLarge();
49  
50  } // interface AsnIntegralNumber
51  
52  // -- EOF -------------------------------------------------------------------