Class Referrals

  • All Implemented Interfaces:
    Cloneable

    public class Referrals
    extends Object
    implements Cloneable
    The class Referrals provides methods to maintain a collection of Referral objects that can be applied to a policy. This class provides methods to add, replace and remove Referral objects from this referrals collection. The Policy object provides methods to set Referrals, which identifies referrals to whom the the policy applies.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Referrals()
      Constructor used by the Policy object to get a default instance of the Referrals
      protected Referrals​(PolicyManager pm, Node referralsNode)
      Constructor used by Policy to obtain an instance of Referrals from the XML document
        Referrals​(String name, String description)
      Constructor to obtain an instance of Referrals to hold collection of referrals represented as Referral
    • Constructor Detail

      • Referrals

        protected Referrals()
        Constructor used by the Policy object to get a default instance of the Referrals
      • Referrals

        public Referrals​(String name,
                         String description)
        Constructor to obtain an instance of Referrals to hold collection of referrals represented as Referral
        Parameters:
        name - name for the collection of Referral
        description - user friendly description for the collection of Referral
    • Method Detail

      • getName

        public String getName()
        Returns the name for the collection of referrals represented as Referral
        Returns:
        name of the collection of referrals
      • getDescription

        public String getDescription()
        Returns the description for the collection of referrals represented as Referral
        Returns:
        description for the collection of referrals
      • setName

        public void setName​(String name)
        Sets the name for this instance of the Referrals which contains a collection of referrals respresented as Referral.
        Parameters:
        name - for the collection of referrals
      • setDescription

        public void setDescription​(String description)
        Sets the description for this instance of the Referrals which contains a collection of referrals respresented as Referral.
        Parameters:
        description - description for the collection referrals
      • getReferralNames

        public Set getReferralNames()
        Returns the names of Referral objects contained in this object.
        Returns:
        names of Referral contained in this object
      • getReferral

        public Referral getReferral​(String referralName)
                             throws NameNotFoundException
        Returns the Referral object associated with the given referral name.
        Parameters:
        referralName - name of the referral object
        Returns:
        Referral object corresponding to referral name
        Throws:
        NameNotFoundException - if a referral with the given name is not present
      • addReferral

        public void addReferral​(Referral referral)
                         throws NameAlreadyExistsException
        Adds a Referral object to the this instance of user collection. Since the name is not provided it will be dynamically assigned such that it is unique within this instance of the user collection. However if a referral entry with the same name already exists in the user collection NameAlreadyExistsException will be thrown.
        Parameters:
        referral - instance of the referral object added to this collection
        Throws:
        NameAlreadyExistsException - if a referral object is present with the same name
      • addReferral

        public void addReferral​(String referralName,
                                Referral referral)
                         throws NameAlreadyExistsException
        Adds a Referral object to the this instance of user collection. If another referral with the same name already exists in the user collection NameAlreadyExistsException will be thrown.
        Parameters:
        referralName - name for the referral instance
        referral - instance of the referral object added to this collection
        Throws:
        NameAlreadyExistsException - if a referral object is present with the same name
      • replaceReferral

        public void replaceReferral​(String referralName,
                                    Referral referral)
                             throws NameNotFoundException
        Replaces an existing referral object having the same name with the new one. If a Referral with the given name does not exist, NameNotFoundException will be thrown.
        Parameters:
        referralName - name for the referral instance
        referral - instance of the referral object that will replace another referral object having the given name
        Throws:
        NameNotFoundException - if a referral instance with the given name is not present
      • removeReferral

        public Referral removeReferral​(String referralName)
        Removes the Referral object identified by the referral name. If a referral instance with the given name does not exist, the method will return silently.
        Parameters:
        referralName - name of the referral instance that will be removed from the user collection
        Returns:
        the referral that was just removed
      • removeReferral

        public Referral removeReferral​(Referral referral)
        Removes the Referral object identified by object's equals method. If a referral instance does not exist, the method will return silently.
        Parameters:
        referral - referral object that will be removed from the user collection
        Returns:
        the referral that was just removed
      • getReferralName

        public String getReferralName​(Referral referral)
        Returns the name associated with the given referral object. It uses the equals method on the referral to determine equality. If a referral instance that matches the given referral object is not present, the method returns null.
        Parameters:
        referral - referral object for which this method will return its associated name
        Returns:
        user friendly name given to the referral object; null if not present
      • equals

        public boolean equals​(Object o)
        Checks if two Referrals are identical. Two referrals (or user collections) are identical only if both have the same set of Referral objects.
        Overrides:
        equals in class Object
        Parameters:
        o - object againt which this referrals object will be checked for equality
        Returns:
        true if all the referrals match; false otherwise
      • clone

        public Object clone()
        Returns a new copy of this object with the identical set of user collections (referrals).
        Overrides:
        clone in class Object
        Returns:
        a copy of this object with identical values
      • toString

        public String toString()
        Returns XML string representation of the referral (user collection) object.
        Overrides:
        toString in class Object
        Returns:
        xml string representation of this object
      • toXML

        protected String toXML()
        Returns an XML representaion of this Referrals object