## com.bbn.openmap.tools.symbology.milStd2525
Class CodePosition

    java.lang.Object
      com.bbn.openmap.tools.symbology.milStd2525.CodePosition

Direct Known Subclasses:
  CodeAffiliation, CodeBattleDimension, CodeCategory, CodeFunctionID, CodeMETOCCategory, CodeMOOTWCategory, CodeMOOTWModifier, CodeOrderOfBattle, CodeScheme, CodeSizeModifier, CodeStatus, CodeWarfightingModifier

public class CodePosition
extends java.lang.Object

The CodePosition class is a base class used to interpret and organize role settings for a symbol. The SymbolCode describes a symbol and its role, with different characters having defined meanings and optional values, depending on the symbol. The CodePosition object defines a character and meaning for a character in a certain place. A SymbolPart refers to a particlar CodePosition that uniquely defines it, giving it some organizational meaning. SymbolParts that share a parent can get to the parent's CodePositin to see that meaning as well.

CodePositions have some intelligence for parsing position properties and hierarchy properties, which allow the whole symbol tree to be defined.

CodePositions server a couple of different roles. Some CodePosition objects organize the kinds of set values that may be applicable for a certain character position, and can offer those choices. These organizational CodePositions won't have a SymbolPart to represent itself. Other CodePositions, including the choices and those tied directly to SymbolParts in the SymbolPart tree, don't offer choices but can provide SymbolParts to represent themselves in the symbol.

Field Summary
`protected java.util.List` `choices` A list of CodePosition choices for this position.
`boolean` `DEBUG`
`protected int` `endIndex`
`protected int` `hierarchyNumber`
`protected java.lang.String` `id`
`static java.lang.String` `NameProperty` Property file property for pretty name 'name'
`protected CodePosition` `nextPosition`
`static java.lang.String` `NextProperty` Property file property for a classname representing the next position in the position tree 'next'.
`static char` `NO_CHAR`
`static int` `NO_NUMBER`
`protected java.lang.String` `prettyName`
`protected int` `startIndex`
`protected SymbolPart` `symbolPart`

Constructor Summary
`CodePosition()`
`CodePosition(java.lang.String name, int start, int end)`

Method Summary
`void` `addPositionChoice(CodePosition cp)` Add the CodePosition to the choices, creating the choices List if needed.
`protected CodePosition` `addPositionChoice(int index, java.lang.String entry, java.lang.String prefix, java.util.Properties props)` Method to add a position to the choices for this particular code position.
`boolean` `codeMatches(java.lang.String queryCode)` A query method that answers of the given 15 digit code applies to this symbol part.
`int` `getEndIndex()` Get the ending index of the span that this position represents.
`CodePosition` `getFromChoices(int hierarchyNumber)` Get a CodePosition from this list of available possibilities given the hierarchy number for the position.
`int` `getHierarchyNumber()` The SymbolPart tree can be represented by a hierarchy number system, and this system is what is used in the hierarchy properties file to build the symbol tree.
`java.lang.String` `getHierarchyNumberString()` Return a string version of the hierarchy number.
`java.lang.String` `getID()` Get the character, in the symbol code, that this position represents.
`CodePosition` `getNextPosition()` Return the next CodePosition.
`protected CodePosition` `getNULLCodePosition()`
`java.util.List` `getPositionChoices()` Get the current list of CodePosition possibilies.
`java.lang.String` `getPrettyName()` Get the pretty name that states what this position and character represents.
`int` `getStartIndex()` Get the starting index of the span that this position represents.
`protected SymbolPart` `getSymbolPart(java.lang.String entry, java.lang.String prefix, java.util.Properties props)` A method called when parsing position properties.
`protected void` `parseHierarchy(java.lang.String hCode, java.util.Properties props, SymbolPart parent)`
`protected void` `parsePositions(java.lang.String prefix, java.util.Properties props)` This method reads Properties to add choices to this class as options for what values are valid in this position.
`java.lang.String` `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### NO_CHAR

    public static final char NO_CHAR

See Also:
  Constant Field Values

### NO_NUMBER

    public static final int NO_NUMBER

See Also:
  Constant Field Values

### hierarchyNumber

    protected int hierarchyNumber

### id

    protected java.lang.String id

### prettyName

    protected java.lang.String prettyName

### startIndex

    protected int startIndex

### endIndex

    protected int endIndex

### nextPosition

    protected CodePosition nextPosition

### symbolPart

    protected SymbolPart symbolPart

### DEBUG

    public boolean DEBUG

### NameProperty

    public static final java.lang.String NameProperty

  Property file property for pretty name 'name'

  See Also:
    Constant Field Values

### NextProperty

    public static final java.lang.String NextProperty

  Property file property for a classname representing the next position in the position tree 'next'.

  See Also:
    Constant Field Values

### choices

    protected java.util.List choices

  A list of CodePosition choices for this position. This is only used for a single instance of the CodePosition that in turn holds this list of possible versions.

Constructor Detail

### CodePosition

    public CodePosition()

### CodePosition

    public CodePosition(java.lang.String name,
                        int start,
                        int end)

Method Detail

### codeMatches

    public boolean codeMatches(java.lang.String queryCode)

  A query method that answers of the given 15 digit code applies to this symbol part.

  Parameters:
    `queryCode` -
  Returns:
    true if the code applies to this position.

### getPositionChoices

    public java.util.List getPositionChoices()

  Get the current list of CodePosition possibilies. Only returns a list for the CodePositions used to parse the position properties.

### getFromChoices

    public CodePosition getFromChoices(int hierarchyNumber)

  Get a CodePosition from this list of available possibilities given the hierarchy number for the position. Not all positions have a hierarchy number, but the number given in the positions properties will probably suffice.

### addPositionChoice

    protected CodePosition addPositionChoice(int index,
                                             java.lang.String entry,
                                             java.lang.String prefix,
                                             java.util.Properties props)

  Method to add a position to the choices for this particular code position.

  Parameters:
    `index` - the hierarhical index for this position choice. This really only becomes important for those CodePositions which are used for interpreting the hierarchy properties. Other positions can use them for convenience, and this value will probably be just an ordering number for this choice out of all the other choices for the position.
    `entry` - this should be character or characters used in the symbol code for this particular position choice.
    `prefix` - the scoping property prefix used for all the properties. The entry is discovered by looking in the properties for this 'prefix.index'. Then other properties are discovered by looking for 'prefix.entry.propertyKey' properties.
    `props` - the position properties.

### addPositionChoice

    public void addPositionChoice(CodePosition cp)

  Add the CodePosition to the choices, creating the choices List if needed.

### parsePositions

    protected void parsePositions(java.lang.String prefix,
                                  java.util.Properties props)

  This method reads Properties to add choices to this class as options for what values are valid in this position.

### getSymbolPart

    protected SymbolPart getSymbolPart(java.lang.String entry,
                                       java.lang.String prefix,
                                       java.util.Properties props)

  A method called when parsing position properties.

  Parameters:
    `entry` - should be prefix of the overall position class along with the symbol representation for that position.
    `prefix` - should just be the prefix for the overall position class, including the period before the symbol representation for that position.
    `props` - the position properties.

### parseHierarchy

    protected void parseHierarchy(java.lang.String hCode,
                                  java.util.Properties props,
                                  SymbolPart parent)

### getHierarchyNumber

    public int getHierarchyNumber()

  The SymbolPart tree can be represented by a hierarchy number system, and this system is what is used in the hierarchy properties file to build the symbol tree.

### getHierarchyNumberString

    public java.lang.String getHierarchyNumberString()

  Return a string version of the hierarchy number.

### getID

    public java.lang.String getID()

  Get the character, in the symbol code, that this position represents.

### getPrettyName

    public java.lang.String getPrettyName()

  Get the pretty name that states what this position and character represents.

### getStartIndex

    public int getStartIndex()

  Get the starting index of the span that this position represents. This value is a java index value starting at 0.

### getEndIndex

    public int getEndIndex()

  Get the ending index of the span that this position represents. This value is a java index value starting at 0.

### getNextPosition

    public CodePosition getNextPosition()

  Return the next CodePosition. An organizational tool to help build the SymbolPart tree when parsing the hierarchy properties.

### toString

    public java.lang.String toString()

### getNULLCodePosition

    protected CodePosition getNULLCodePosition()

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details