org.tm4j.topicmap
Interface Variant

All Superinterfaces:
TopicMapObject, VariantContainer
All Known Implementing Classes:
UnifiedVariant

public interface Variant
extends TopicMapObject, VariantContainer

This interface is used to define an alternate naming scheme for a topic. In XTM, a variant comprises a set of parameters (a context in which the variant is to be interpreted), and the actual variant name, which can be defined either as a character string or a reference to an external resource.

Author:
Kal Ahmed
See Also:
VariantContainer

Method Summary
 void addParameter(Topic parameter)
          Adds a parameter to the variant.
 VariantName createVariantName(java.lang.String id)
          Creates a new VariantName as a child of this Variant.
 java.util.Collection getParameters()
          Returns the parameters of this variant as an unmodifiable Collection of Topic objects.
 java.util.Collection getParameters(boolean getAll)
          Returns the parameters of this variant and, if so specified, all ancestor variants, as an unmodifiable Collection of Topic objects.
 VariantContainer getParent()
          Returns the object containing this variant.
 VariantName getVariantName()
          Returns the name for this Variant.
 void setParameters(Topic[] parameters)
          Sets the parameters of this variant, overwriting any existing parameters.
 void setVariantName(VariantName name)
          Sets the VariantName contained by this Variant.
 
Methods inherited from interface org.tm4j.topicmap.TopicMapObject
addMultiValuePropertyChangeListener, addMultiValuePropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addSourceLocator, addVetoableChangeListener, destroy, fireMultiValuePropertyChange, fireMultiValuePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getID, getResourceLocator, getSourceLocators, getTopicMap, removeMultiValuePropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener, removeSourceLocator, removeVetoableChangeListener, setID, setResourceLocator
 
Methods inherited from interface org.tm4j.topicmap.VariantContainer
addVariant, createVariant, getVariants, setVariants
 

Method Detail

getVariantName

public VariantName getVariantName()
Returns the name for this Variant.

Since:
0.6.0

setVariantName

public void setVariantName(VariantName name)
                    throws java.beans.PropertyVetoException
Sets the VariantName contained by this Variant. If the Variant already has a child VariantName, it will be replaced by the one passed to this method. If the value passed to this method is null, the existing VariantName child will be removed from this object.

Parameters:
name - The VariantName child to be added to this object, or null to remove any existing child from this object.
Throws:
java.beans.PropertyVetoException - If a VetoableChangeListener vetos the replacement of the name.
Since:
0.6.0

createVariantName

public VariantName createVariantName(java.lang.String id)
                              throws java.beans.PropertyVetoException,
                                     DuplicateObjectIDException
Creates a new VariantName as a child of this Variant. Thw new VariantName will replace any existing VariantName as the only child of this Variant.

Parameters:
id - the unique object id to be assigned to the new VariantName object. If this parameter is null, the back-end will assign an ID to the newly created object.
Returns:
the newly created VariantName object.
Throws:
DuplicateObjectIDException - if id specifies and identifier value already used in the containing TopicMap.
java.beans.PropertyVetoException - if to create a new VariantName for this Variant would violate a constraint imposed by a VetoableChangeListener assigned to this TopicMap.

addParameter

public void addParameter(Topic parameter)
                  throws java.beans.PropertyVetoException
Adds a parameter to the variant.

Parameters:
parameter - The topic reference to be used as a variant parameter.
Throws:
java.beans.PropertyVetoException - If a VetoableChangeListener vetos the addition of parameter

getParameters

public java.util.Collection getParameters()
Returns the parameters of this variant as an unmodifiable Collection of Topic objects. Note that this method only provides the parameters specifically defined on this Variant itself. In order to retrieve a collection of all parameters defined on this variant and its ancestors, use getParameters(boolean).

Returns:
The collection of Topics defining this variant's parameters. If no parameters are currently defined on this variant, the returned collection is empty; it is never null.

getParameters

public java.util.Collection getParameters(boolean getAll)
Returns the parameters of this variant and, if so specified, all ancestor variants, as an unmodifiable Collection of Topic objects.

Parameters:
getAll - If true, then parameters from all ancestor containers are returned. If false, just the parameters of this Variant itself are returned.
Returns:
The collection of Topics defining this variant's parameters. If no parameters are currently defined on this variant (or ancestors), the returned collection is empty; it is never null.

setParameters

public void setParameters(Topic[] parameters)
                   throws java.beans.PropertyVetoException
Sets the parameters of this variant, overwriting any existing parameters.

Parameters:
parameters - the new set of parameters to be used with this variant. If this is null, all the existing parameters of this variant are removed.
Throws:
java.beans.PropertyVetoException - If the update of the parameters was vetoed.

getParent

public VariantContainer getParent()
Returns the object containing this variant. This may either be a BaseName, or, in case of variant nesting, another Variant.

Returns:
The containing object.