Accessing and removing states

In addition to the API used to assert states, another API is available for accessing and removing states. Most of the functions for accessing states are available from the class IltObject.
For example, the Boolean predicate hasState can be used to verify whether the telecom object is in a given state. In all the following examples, neast is the variable that contains the network element North East.
neast.hasState(IltOSI.State.Usage.Idle);
Sometimes, specific accesses are granted using the functional interfaces on the classes IltObjectState and IltState. The following code shows how to access the state object and then set the accessors for retrieving a given state.

How to access a state object and set accessors for retrieving a state

IltOSIObjectState osiObjectState = 
          (IltOSIObjectState)neast.getObjectState();
IltOSI.State osiState = osiObjectState.getState();
osiState.getOperationalState();
osiState.getUsageState();
osiState.getAdministrativeState();
When primary or secondary states are added, the same functional interface is used, but with different consequences. The primary state is unique (in the OSI state system, it is a triplet; in the Bellcore state system, it is a single value), as opposed to secondary states (for example, the values associated with the Misc dictionary can be added without limitation). Consequently, when the member function setState is used, this function replaces the primary state, although it adds one more secondary state. There are two ways to remove states created in this way:
  • You can use the clearState member function, which removes secondary states or resets the primary state to its default value.
  • You can use the resetState member function, which removes all the secondary states and resets the primary state to its default value.