Cisco Systems, Inc.

com.pcube.apps.engage.policy
Class AddOnGroupArray

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

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

An array of addongroups. this AddOnGroupArray belongs to a Policy. It holds MAX_ADD_ON_GROUPS Packages, but not all of them are used. An unused Package in the array is considered as non existing.

See Also:
Serialized Form

Constructor Summary
AddOnGroupArray(Policy policy)
          AddOnGroupArray Constructor.
 
Method Summary
 boolean add(AddOnGroup item)
          Adds the AddOnGroup to this AddOnGroupArray.
 java.lang.Object clone()
          Producing an identical object to this object.
 boolean contains(AddOnGroup item)
          Checks if the AddOnGroup is in this AddOnGroupArray.
 boolean contains(java.lang.String item)
          Checks if a AddOnGroup bearing the specific name is in this AddOnGroupArray.
 void fromStream(java.io.BufferedReader in, Formatter f)
          Reading this object from a BufferedReader
 AddOnGroup getAddOnGroup(java.lang.String addonGroupName)
          Gets the AddOnGroup from this AddOnGroupArray by the AddOnGroup's name.
 java.lang.String[] getAddOnNames()
          Gets the names of the addongroups in this AddOnGroupArray.
 AddOnGroup getAt(int index)
          Gets the AddOnGroup in this AddOnGroupArray in the specific index.
 int getIndexOfItem(java.lang.String addonGroupName)
          Gets the index of the AddOnGroup bearing the specific name in this PackageArray.
 int getSize()
          Gets the number of valid addongroups in this AddOnGroupArray.
 boolean isAddOnGroupIndexUsed(int index)
          Checks if a certain index is occupied in this AddOnGroupArray.
 java.util.Iterator iterator()
           
 java.util.Iterator iterator(boolean includeUnknownSubs)
           
 boolean remove(int index)
          Removes the AddOnGroup that is in a certain index in this AddOnGroupArray.
 boolean remove(java.lang.String item)
          Removes the AddOnGroup bearing a specific name from this AddOnGroupArray.
 void setAddOnGroupIndex(java.lang.String addOnGroupName, int newIndex)
          Sets the index for the AddOnGroup bearing the specific name in this AddOnGroupArray.
 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

AddOnGroupArray

public AddOnGroupArray(Policy policy)
AddOnGroupArray Constructor.

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

add

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

Parameters:
item - the AddOnGroup to add
Returns:
true if addition succeeded, false otherwise
Throws:
DuplicateItemException - if a AddOnGroup with duplicate parameters is already in this AddOnGroupArray
java.lang.IndexOutOfBoundsException - if this AddOnGroupArray is full with MAX_ADD_ON_GROUPS addongroups

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(AddOnGroup item)
Checks if the AddOnGroup is in this AddOnGroupArray.

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

contains

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

Parameters:
item - the desired AddOnGroup 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 AddOnGroup getAt(int index)
                 throws ItemNotFoundException
Gets the AddOnGroup in this AddOnGroupArray in the specific index.

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

getIndexOfItem

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

Parameters:
addonGroupName - the desired AddOnGroup name
Returns:
the AddOnGroup's index if in AddOnGroupArray, -1 otherwise

getAddOnGroup

public AddOnGroup getAddOnGroup(java.lang.String addonGroupName)
                         throws ItemNotFoundException
Gets the AddOnGroup from this AddOnGroupArray by the AddOnGroup's name.

Parameters:
addonGroupName - the desired AddOnGroup's name
Returns:
the AddOnGroup
Throws:
ItemNotFoundException - if the AddOnGroup is not found in this AddOnGroupArray

getAddOnNames

public java.lang.String[] getAddOnNames()
Gets the names of the addongroups in this AddOnGroupArray. The returned String array is MAX_ADD_ON_GROUPS long.

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

getSize

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

Returns:
the the number of valid addongroups in this AddOnGroupArray
See Also:
isAddOnGroupIndexUsed(int)

isAddOnGroupIndexUsed

public boolean isAddOnGroupIndexUsed(int index)
Checks if a certain index is occupied in this AddOnGroupArray.

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

iterator

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

iterator

public java.util.Iterator iterator(boolean includeUnknownSubs)

remove

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

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

remove

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

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

setAddOnGroupIndex

public void setAddOnGroupIndex(java.lang.String addOnGroupName,
                               int newIndex)
                        throws ItemNotFoundException
Sets the index for the AddOnGroup bearing the specific name in this AddOnGroupArray. The limitation is that the AddOnGroup is in this AddOnGroupArray and that the index is not used.

Parameters:
addOnGroupName - the AddOnGroup's name
newIndex - the new AddOnGroup's index
Throws:
ItemNotFoundException - if a AddOnGroup bearing such a name does not exist in this AddOnGroupArray

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

Cisco Systems, Inc.

Copyright © 2013 Cisco Systems, Inc. Confidential.