QJCC homepage

biz.chitec.quarterback.util
Class NumberedString

java.lang.Object
  extended bybiz.chitec.quarterback.util.NumberedString
All Implemented Interfaces:
java.io.Serializable

public class NumberedString
extends java.lang.Object
implements java.io.Serializable

Data type class combining a number, a String and an additional number if needed.

Version:
$Id: a4b59c9a0f6667fd5fed71cfbfd49912559efb4e $
Author:
Dirk Hillbrecht 1997-1999, chitec/Dirk Hillbrecht 2000, cantamen/Dirk Hillbrecht 2005 Distributed under the terms of the GNU LGPL.
See Also:
Serialized Form

Field Summary
 int addnr
           
 java.lang.String name
           
 int nr
           
 
Constructor Summary
NumberedString(int n, java.lang.String s)
          Constructs new NumberedString with number and string.
NumberedString(int n, java.lang.String s, int a)
          Constructs new NumberedString with number, string and additional number.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this to another NumberedString, always based on name field.
 int compareTo(java.lang.Object o, boolean byname)
          Compares this to another NumberedString.
 boolean equals(java.lang.Object o)
          Checks equality with another object.
 int getAddnr()
          Returns additional number.
 java.lang.String getName()
          Returns String.
 int getNr()
          Returns number.
static NumberedString getNSfromListbyNSIdx(java.util.List v, int nsidx)
          Returns a NumberedString out of a List of NumberedString by number.
static boolean listContainsNS(java.util.List v, int nsidx)
          Checks whether a List of NumberedStrings contains a certain NumberedString which is given by number.
 void setName(java.lang.String x)
          Sets the name
 java.lang.String toString()
          Creates debug output.
static boolean vectorContainsNS(java.util.List v, int nsidx)
          Deprecated. Use listContainsNS
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nr

public int nr

name

public java.lang.String name

addnr

public int addnr
Constructor Detail

NumberedString

public NumberedString(int n,
                      java.lang.String s,
                      int a)
Constructs new NumberedString with number, string and additional number.


NumberedString

public NumberedString(int n,
                      java.lang.String s)
Constructs new NumberedString with number and string. Additional number is not used (and set to -1).

Method Detail

getNr

public int getNr()
Returns number.


setName

public void setName(java.lang.String x)
Sets the name


getName

public java.lang.String getName()
Returns String.


getAddnr

public int getAddnr()
Returns additional number.


equals

public boolean equals(java.lang.Object o)
Checks equality with another object. True only if other object is NumberedString and has the same content (compared by value).


compareTo

public int compareTo(java.lang.Object o,
                     boolean byname)
Compares this to another NumberedString. Returns -1 if this is smaller, 0 if both are equal, 1 if this is larger. Comparison is done either on the name parts of the NumberedStrings or on the nr parts depending on the parameter byname.

This method is specially useful when it comes to sorting NumberedStrings for representation in a list or something like that.


compareTo

public int compareTo(java.lang.Object o)
Compares this to another NumberedString, always based on name field.


toString

public java.lang.String toString()
Creates debug output.


getNSfromListbyNSIdx

public static NumberedString getNSfromListbyNSIdx(java.util.List v,
                                                  int nsidx)
Returns a NumberedString out of a List of NumberedString by number.


vectorContainsNS

public static boolean vectorContainsNS(java.util.List v,
                                       int nsidx)
Deprecated. Use listContainsNS

Checks whether a List of NumberedStrings contains a certain NumberedString which is given by number.


listContainsNS

public static boolean listContainsNS(java.util.List v,
                                     int nsidx)
Checks whether a List of NumberedStrings contains a certain NumberedString which is given by number. Entries which are not a NumberedString are silently ignored

Parameters:
v - List containing objects, hopefully some NumberedStrings among them
nsidx - number of String to search for
Returns:
flag if list contains a NumberedString with the number in question

QJCC homepage