org.tm4j.topicmap
Interface VariantContainer

All Known Subinterfaces:
BaseName, Variant
All Known Implementing Classes:
UnifiedBaseName, UnifiedVariant

public interface VariantContainer

The base interface for an object which may contain a list of child Variants.

Rather than only allowing for variants being defined as children of base names, XTM also provides the possibility of nesting variants, thus establishing a context hierarchy in which variants at lower levels inherit the parameter contexts of their ancestors. TM4J deals with this provision by providing this interface being the parent interface for both BaseName and Variant.

Since:
0.6.0
Author:
Kal Ahmed
See Also:
BaseName, Variant

Method Summary
 void addVariant(Variant variant)
          Adds a new child variant to this object.
 Variant createVariant(java.lang.String id)
          Creates a new child variant of this object.
 java.util.Collection getVariants()
          Returns the child Variants as an unmodifiable collection of Variant objects.
 void setVariants(Variant[] variants)
          Sets the child variants of this object.
 

Method Detail

getVariants

public java.util.Collection getVariants()
Returns the child Variants as an unmodifiable collection of Variant objects. Note that this method will not descend any nesting of variants inside variants, but will instead only return the immediate child variants of this VariantContainer.

Returns:
The collection of direct child Variants. If no child variants are currently defined on this object, the returned collection is empty; it is never null.

setVariants

public void setVariants(Variant[] variants)
                 throws java.beans.PropertyVetoException
Sets the child variants of this object. All existing child variants are previously removed.

Parameters:
variants - the new set of child variants this object contains. If this is null, all the existing variants contained in this object are removed.
Throws:
java.beans.PropertyVetoException

addVariant

public void addVariant(Variant variant)
                throws java.beans.PropertyVetoException
Adds a new child variant to this object.

Parameters:
variant - the new child Variant.
Throws:
java.beans.PropertyVetoException

createVariant

public Variant createVariant(java.lang.String id)
                      throws DuplicateObjectIDException,
                             java.beans.PropertyVetoException
Creates a new child variant of this object.

Parameters:
id - the unique identifier to be assigned to the newly created Variant. If null is passed in, then the backend will generate a unique identifier for the new Variant.
Returns:
the newly created Variant. The new Variant has no data or dataLocator set and no parameters specified.
Throws:
DuplicateObjectIDException - if id specifies and identifier value already used in the containing TopicMap.
java.beans.PropertyVetoException - if to create a new Variant for this object would violate a constraint imposed by a VetoableChangeListener assigned to the containing TopicMap.