Cisco Systems, Inc.

com.pcube.apps.engage.policy
Class ServiceArray

java.lang.Object
  extended by com.pcube.apps.engage.policy.ServiceArray
All Implemented Interfaces:
Formattable, java.beans.VetoableChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class ServiceArray
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, Formattable, java.beans.VetoableChangeListener

An array of Services. The ServiceArray belongs to a Policy. It holds Policy.MAX_SERVICESServices, but not all of them are used.
An unused Service in the array is considered as non existing. You can set the Service index if that index does not hold a valid Service.

See Also:
Serialized Form

Constructor Summary
ServiceArray(Policy policy)
          ServiceArray Constructor.
 
Method Summary
 boolean add(Service newService)
          Adds the Service to this ServiceArray.
 java.lang.Object clone()
           
 boolean contains(Service service)
          Checks if the specified Service is in this ServiceArray.
 boolean contains(java.lang.String serviceName)
          Checks if the specified Service is in this ServiceArray.
 void fromStream(java.io.BufferedReader in, Formatter f)
          Method fromStream
 Service getAt(int serviceIndex)
          Gets the Service in this ServiceArray in the specific index.
 java.util.List getAvailableCounterIndices(AccountingScope scope)
           
 java.lang.String[] getCounterNames(AccountingScope scope)
           
 Service getDefaultService()
           
 int getIndexOfItem(java.lang.String serviceName)
          Gets the index of the Service bearing the specific name in this ServiceArray.
 com.pcube.apps.engage.management.PrimitiveList getInternalServiceArray()
           
 int getNextFreeCounterId(AccountingScope scope)
           
 java.lang.String[] getNonDescendentServiceNames(Service service)
           
 int getNumOfUsedServices()
          Gets the number of valid Services in this ServiceArray.
 Service getService(java.lang.String serviceName)
          Gets the Service from this ServiceArray by the Service's name.
 int getServiceIndex(java.lang.String serviceName)
          Gets the service index of the Service bearing the specific name.
 java.lang.String[] getServiceNames()
          Gets the names of the Services in this ServiceArray.
 boolean isServiceIndexUsed(int serviceIndex)
          Checks if the specified index is used in this ServiceArray.
 java.util.Iterator iterator()
           
 java.util.ListIterator listIterator()
           
 boolean remove(int serviceIndex)
          Removes the Service that is in a certain index in this ServiceArray.
 boolean remove(java.lang.String serviceName)
          Removes the specified Service from this ServiceArray.
 void setServiceIndex(java.lang.String serviceName, int newServiceIndex)
          Sets the index for the Service bearing the specific name in this ServiceArray.
 void toStream(java.io.PrintStream out, Formatter f)
          Method toStream
 java.lang.String toString()
           
 void vetoableChange(java.beans.PropertyChangeEvent arg0)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServiceArray

public ServiceArray(Policy policy)
ServiceArray Constructor.

Parameters:
policy - the policy this ServiceArray belongs to
Method Detail

add

public boolean add(Service newService)
            throws DuplicateItemException
Adds the Service to this ServiceArray. The position of the Service in this ServiceArray is not predicted; the first available index is taken.

Parameters:
newService - the Service to add
Returns:
true if addition succeeded, false otherwise
Throws:
DuplicateItemException - if a Service with duplicate parameters is already in this ServiceArray
java.lang.IndexOutOfBoundsException - if this ServiceArray is full with Policy.MAX_SERVICES Services

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

contains

public boolean contains(Service service)
Checks if the specified Service is in this ServiceArray.

Parameters:
service - Service whose presence in this ServiceArray is to be tested.
Returns:
true if this ServiceArray contains the specified Service

contains

public boolean contains(java.lang.String serviceName)
Checks if the specified Service is in this ServiceArray.

Parameters:
serviceName - Service whose presence in this ServiceArray is to be tested.
Returns:
true if this ServiceArray contains the specified Service

fromStream

public void fromStream(java.io.BufferedReader in,
                       Formatter f)
                throws ImportExportException
Description copied from interface: Formattable
Method fromStream

Specified by:
fromStream in interface Formattable
Throws:
ImportExportException
See Also:
Formattable.fromStream(java.io.BufferedReader, com.pcube.apps.engage.common.Formatter)

getAt

public Service getAt(int serviceIndex)
              throws ItemNotFoundException
Gets the Service in this ServiceArray in the specific index.

Parameters:
serviceIndex - the index of the Service in this ServiceArray
Returns:
the Service
Throws:
ItemNotFoundException - if the index is out of bound or the Service in the index is not used

getAvailableCounterIndices

public java.util.List getAvailableCounterIndices(AccountingScope scope)
Parameters:
scope -
Returns:

getCounterNames

public java.lang.String[] getCounterNames(AccountingScope scope)
Parameters:
global -
Returns:

getDefaultService

public Service getDefaultService()
Returns:

getIndexOfItem

public int getIndexOfItem(java.lang.String serviceName)
Gets the index of the Service bearing the specific name in this ServiceArray.

Parameters:
serviceName - the desired Service name
Returns:
the Service's index if in ServiceArray, -1 otherwise

getInternalServiceArray

public com.pcube.apps.engage.management.PrimitiveList getInternalServiceArray()

getNextFreeCounterId

public int getNextFreeCounterId(AccountingScope scope)
Parameters:
scope -
Returns:
-1 if no free counter id is available

getNonDescendentServiceNames

public java.lang.String[] getNonDescendentServiceNames(Service service)
Parameters:
service -
Returns:

getNumOfUsedServices

public int getNumOfUsedServices()
Gets the number of valid Services in this ServiceArray. Invalid Services are considered ones which are in indices which are not used.

Returns:
the the number of valid Services in this ServiceArray

getService

public Service getService(java.lang.String serviceName)
                   throws ItemNotFoundException
Gets the Service from this ServiceArray by the Service's name.

Parameters:
serviceName - the desired Service's name
Returns:
the Service
Throws:
ItemNotFoundException - if the Service is not found in this ServiceArray

getServiceIndex

public int getServiceIndex(java.lang.String serviceName)
                    throws ItemNotFoundException
Gets the service index of the Service bearing the specific name.

Parameters:
serviceName - the desired Service's name
Returns:
the Service's logical index
Throws:
ItemNotFoundException - if no such Service exists in this ServiceArray

getServiceNames

public java.lang.String[] getServiceNames()
Gets the names of the Services in this ServiceArray. The returned String array is Policy.MAX_SERVICESlong.

Returns:
String array. The name of the Service at index i appears at the position i in the array. If the Service in index i is not used, the String array at index i is null.

isServiceIndexUsed

public boolean isServiceIndexUsed(int serviceIndex)
Checks if the specified index is used in this ServiceArray.

Parameters:
serviceIndex - the index to test
Returns:
true if the specified index is used, false otherwise

iterator

public java.util.Iterator iterator()

listIterator

public java.util.ListIterator listIterator()

remove

public boolean remove(int serviceIndex)
               throws ItemNotFoundException
Removes the Service that is in a certain index in this ServiceArray.

Parameters:
serviceIndex - the removed Service's index in this ServiceArray
Returns:
true if removal succeeded, false otherwise
Throws:
ItemNotFoundException

remove

public boolean remove(java.lang.String serviceName)
               throws ItemNotFoundException
Removes the specified Service from this ServiceArray.

Parameters:
serviceName - the removed Service's name
Returns:
true if removal succeeded, false otherwise
Throws:
ItemNotFoundException - if a Service bearing such a name does not exist in this ServiceArray

setServiceIndex

public void setServiceIndex(java.lang.String serviceName,
                            int newServiceIndex)
                     throws ItemNotFoundException
Sets the index for the Service bearing the specific name in this ServiceArray. The limitation is that the Service is in this ServiceArray and that the index is not used.

Parameters:
serviceName - the Service's name
newServiceIndex - the new Service's index
Throws:
ItemNotFoundException - if a Service bearing such a name does not exist in this ServiceArray

toStream

public void toStream(java.io.PrintStream out,
                     Formatter f)
Description copied from interface: Formattable
Method toStream

Specified by:
toStream in interface Formattable
See Also:
Formattable.toStream(java.io.PrintStream, com.pcube.apps.engage.common.Formatter)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

vetoableChange

public void vetoableChange(java.beans.PropertyChangeEvent arg0)
                    throws java.beans.PropertyVetoException
Specified by:
vetoableChange in interface java.beans.VetoableChangeListener
Throws:
java.beans.PropertyVetoException

Cisco Systems, Inc.

Copyright © 2013 Cisco Systems, Inc. Confidential.