|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.data.NumberedNames
public class NumberedNames
A numbered list of names, or a named list of numbers, depending on how you look at it.
This class is designed to solve the frequent problem of associating a sequential ID with a human-readable name. It can be used as a canonicalization structure, but is more often used to represent a long string as a short ID in binary files. The Partner ROVER format uses this concept extensively to encode graphicTypes and dataTypes.
Names are handled case-insensitively and stored with the case they were first
built with. This structure can build the coding sequentially, or can be
initialized from a list or DynamicStringArray. You can retrieve the
results as a Naming or as an array of Strings as you prefer.
This class is poorly suited to non-sequential numberings. You can have some
holes, but if you have a wide distribution of codes you'd be better off using
a OneToOneMapping instead.
Copyright 2001-2006 Partner Software, Inc.
| Constructor Summary | |
|---|---|
NumberedNames()
|
|
NumberedNames(java.util.List<java.lang.String> list)
|
|
| Method Summary | |
|---|---|
java.lang.String[] |
asArray()
Returns the encoding as an array of Strings. |
java.util.ArrayList<java.lang.String> |
asArrayList()
Returns the encoding as an ArrayList of Strings. |
Naming<java.lang.Integer> |
asNaming()
Returns the encoding as a Naming, mapping the name to its numeric ID. |
int |
ensureNumberFor(java.lang.String name)
This is probably the most useful method. |
java.lang.String |
nameFor(int number)
Returns the assigned name for the given number. |
int |
numberFor(java.lang.String name)
Returns the assigned number for the given name. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public NumberedNames()
public NumberedNames(java.util.List<java.lang.String> list)
| Method Detail |
|---|
public int numberFor(java.lang.String name)
ensureNumberFor(String).
name - name to look up the number for
public java.lang.String nameFor(int number)
number - number to look up the name of
public int ensureNumberFor(java.lang.String name)
name - name to look up
public java.lang.String toString()
toString in class java.lang.Objectpublic java.util.ArrayList<java.lang.String> asArrayList()
public Naming<java.lang.Integer> asNaming()
public java.lang.String[] asArray()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||