Cisco Systems, Inc.

com.pcube.apps.engage.policy
Class PackageArray

java.lang.Object
  extended by com.pcube.apps.engage.policy.PackageArray
All Implemented Interfaces:
Formattable, java.io.Serializable, java.lang.Cloneable

public class PackageArray
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, Formattable

An array of packages. this PackageArray belongs to a Policy. It holds MAX_PACKAGES Packages, but not all of them are used. An unused Package in the array is considered as non existing. You can set the Package index if that index does not hold a valid Package.

See Also:
Serialized Form

Constructor Summary
PackageArray(Policy policy)
          PackageArray Constructor.
 
Method Summary
 boolean add(Package item)
          Adds the Package to this PackageArray.
 java.lang.Object clone()
          Producing an identical object to this object.
 boolean contains(Package item)
          Checks if the Package is in this PackageArray.
 boolean contains(java.lang.String item)
          Checks if a Package bearing the specific name is in this PackageArray.
static Package findNearestAncestorWithExclusiveCounter(Policy policy, Package pkg, java.lang.String parentPkgName, boolean exclusiveCounter)
           
 void fromStream(java.io.BufferedReader in, Formatter f)
          Reading this object from a BufferedReader
static java.lang.String generatetHypotheticalCounterName(Policy policy, Package pkg, java.lang.String parentPkgName, boolean exclusiveCounter)
           
static java.lang.String generatetHypotheticalCounterName(Policy policy, Package pkg, java.lang.String parentPkgName, boolean exclusiveCounter, java.lang.String nameSuffix)
           
 java.lang.String[] getAppliedPackagesNames()
           
 Package getAt(int index)
          Gets the Package in this PackageArray in the specific index.
 java.lang.Integer[] getAvailableCounterIndices()
           
 java.lang.String[] getCounterNames()
           
 int getDefaultPackageIndex()
          Gets the index of the default Package - the Package that all of the subscribers belong to prior to being associated explicitly to another Package.
 int getGlobalRulePackageIndex()
           
 int getIndexOfItem(java.lang.String pkgName)
          Gets the index of the Package bearing the specific name in this PackageArray.
 com.pcube.apps.engage.management.PrimitiveList getInternalList()
           
static int getMaxUsageCounters()
           
 int getNextFreeCounterIndex()
           
 java.lang.String[] getNonDecendentPackages(Package pkg)
           
 int getNumOfUsedPackages()
           
 Package getPackage(java.lang.String packageName)
          Gets the Package from this PackageArray by the Package's name.
 java.lang.String[] getPackagesNames()
          Gets the names of the Packages in this PackageArray.
 int getSize()
          Gets the number of valid Packages in this PackageArray.
 int getUnknownSubscriberPackageIndex()
          Gets the index of the Unknown Subscriber Package.
 boolean isIndexAllowedFor8k()
           
 boolean isPackageIndexUsed(int index)
          Checks if a certain index is occupied in this PackageArray.
 java.util.Iterator iterator()
           
 java.util.Iterator iterator(boolean includeUnknownSubs)
           
 boolean remove(int index)
          Removes the Package that is in a certain index in this PackageArray.
 boolean remove(java.lang.String item)
          Removes the Package bearing a specific name from this PackageArray.
 void removeDefaultPackage()
          Removes the default Package.
 void removeUnknownSubscriberPackage()
          Removes the unknown subscriber Package.
 void setPackageIndex(java.lang.String packageName, int newIndex)
          Sets the index for the Package bearing the specific name in this PackageArray.
 void toStream(java.io.PrintStream out, Formatter f)
          Writing this object to a PrintStream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackageArray

public PackageArray(Policy policy)
PackageArray Constructor.

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

findNearestAncestorWithExclusiveCounter

public static Package findNearestAncestorWithExclusiveCounter(Policy policy,
                                                              Package pkg,
                                                              java.lang.String parentPkgName,
                                                              boolean exclusiveCounter)

generatetHypotheticalCounterName

public static java.lang.String generatetHypotheticalCounterName(Policy policy,
                                                                Package pkg,
                                                                java.lang.String parentPkgName,
                                                                boolean exclusiveCounter)

generatetHypotheticalCounterName

public static java.lang.String generatetHypotheticalCounterName(Policy policy,
                                                                Package pkg,
                                                                java.lang.String parentPkgName,
                                                                boolean exclusiveCounter,
                                                                java.lang.String nameSuffix)

getMaxUsageCounters

public static int getMaxUsageCounters()
Returns:

add

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

Parameters:
item - the Package to add
Returns:
true if addition succeeded, false otherwise
Throws:
DuplicateItemException - if a Package with duplicate parameters is already in this PackageArray
java.lang.IndexOutOfBoundsException - if this PackageArray is full with MAX_PACKAGES Packages

getNextFreeCounterIndex

public int getNextFreeCounterIndex()

clone

public java.lang.Object clone()
Producing an identical object to this object.

Overrides:
clone in class java.lang.Object
Returns:
a newly alocated object similar to this object.

contains

public boolean contains(Package item)
Checks if the Package is in this PackageArray.

Parameters:
item - the queried Package
Returns:
true if found, false otherwise

contains

public boolean contains(java.lang.String item)
Checks if a Package bearing the specific name is in this PackageArray.

Parameters:
item - the desired Package name
Returns:
true if found, false otherwise

fromStream

public void fromStream(java.io.BufferedReader in,
                       Formatter f)
                throws ImportExportException
Reading this object from a BufferedReader

Specified by:
fromStream in interface Formattable
Parameters:
in - the BufferedReader
f - the formatter used to read this object from the BufferedReader
Throws:
ImportExportException

getAt

public Package getAt(int index)
              throws ItemNotFoundException
Gets the Package in this PackageArray in the specific index.

Parameters:
index - the index of the Package in this PackageArray
Returns:
the Package
Throws:
ItemNotFoundException - if the index is out of bound or the Package in the index is not used

getAvailableCounterIndices

public java.lang.Integer[] getAvailableCounterIndices()
Parameters:
pkg -

getCounterNames

public java.lang.String[] getCounterNames()
Returns:

getDefaultPackageIndex

public int getDefaultPackageIndex()
Gets the index of the default Package - the Package that all of the subscribers belong to prior to being associated explicitly to another Package.

Returns:
the default Package index

getIndexOfItem

public int getIndexOfItem(java.lang.String pkgName)
Gets the index of the Package bearing the specific name in this PackageArray.

Parameters:
pkgName - the desired Package name
Returns:
the Package's index if in PackageArray, -1 otherwise

isIndexAllowedFor8k

public boolean isIndexAllowedFor8k()

getNonDecendentPackages

public java.lang.String[] getNonDecendentPackages(Package pkg)
Parameters:
pkg -
Returns:

getNumOfUsedPackages

public int getNumOfUsedPackages()
Returns:

getPackage

public Package getPackage(java.lang.String packageName)
                   throws ItemNotFoundException
Gets the Package from this PackageArray by the Package's name.

Parameters:
packageName - the desired Package's name
Returns:
the Package
Throws:
ItemNotFoundException - if the Package is not found in this PackageArray

getPackagesNames

public java.lang.String[] getPackagesNames()
Gets the names of the Packages in this PackageArray. The returned String array is MAX_PACKAGES long.

Returns:
- a MAX_PACKAGES long string array. The name of the package at index x appears at the position x in the array. If the package in index x is not in use, the String array at index x will have null.

getAppliedPackagesNames

public java.lang.String[] getAppliedPackagesNames()

getSize

public int getSize()
Gets the number of valid Packages in this PackageArray. Invalid Packages are considered ones which are in indices which are not used.

Returns:
the the number of valid Packages in this PackageArray
See Also:
isPackageIndexUsed(int)

getUnknownSubscriberPackageIndex

public int getUnknownSubscriberPackageIndex()
Gets the index of the Unknown Subscriber Package. All network ids (IP, VLAN etc.) which are not associated explicitly to an introduced Subscriber are considered as an unknown subscriber

Returns:
the Unknown Subscriber Package index

getGlobalRulePackageIndex

public int getGlobalRulePackageIndex()

isPackageIndexUsed

public boolean isPackageIndexUsed(int index)
Checks if a certain index is occupied in this PackageArray.

Parameters:
index - the index in this PackageArray
Returns:
true if occupied, false if available

iterator

public java.util.Iterator iterator()
Returns:
an iterator that returns only used packages

iterator

public java.util.Iterator iterator(boolean includeUnknownSubs)

remove

public boolean remove(int index)
               throws ItemNotFoundException
Removes the Package that is in a certain index in this PackageArray.

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

remove

public boolean remove(java.lang.String item)
               throws ItemNotFoundException
Removes the Package bearing a specific name from this PackageArray.

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

removeDefaultPackage

public void removeDefaultPackage()
Removes the default Package. Not to be used whe


removeUnknownSubscriberPackage

public void removeUnknownSubscriberPackage()
Removes the unknown subscriber Package. Not to be used whe


setPackageIndex

public void setPackageIndex(java.lang.String packageName,
                            int newIndex)
                     throws ItemNotFoundException
Sets the index for the Package bearing the specific name in this PackageArray. The limitation is that the Package is in this PackageArray and that the index is not used.

Parameters:
packageName - the Package's name
newIndex - the new Package's index
Throws:
ItemNotFoundException - if a Package bearing such a name does not exist in this PackageArray

toStream

public void toStream(java.io.PrintStream out,
                     Formatter f)
Writing this object to a PrintStream

Specified by:
toStream in interface Formattable
Parameters:
out - the PrintStream
f - the formatter used to write this object

getInternalList

public com.pcube.apps.engage.management.PrimitiveList getInternalList()
Returns:

Cisco Systems, Inc.

Copyright © 2013 Cisco Systems, Inc. Confidential.