org.ceryle.tm
Class FacetImpl

java.lang.Object
  extended by org.ceryle.tm.FacetImpl
All Implemented Interfaces:
Facet

public class FacetImpl
extends Object
implements Facet

Implements Facet as a structure for containing a Topic Map facet, including its type, value, default value, and constraining facets. This class includes constructors, set/get and utility methods for creating and manipulating facets. Note that this class is dynamic, i.e., it generates its components: the necessary Topics, Associations, Occurrences, etc. are created as needed. Note that if the facet name is supplied, the created BaseName is scoped by the faceted Topic to avoid unwanted merging.

Also see the notes found in the interface itself.

Since:
JDK1.4
Version:
$Id: FacetImpl.java,v 3.5 2007-06-15 12:09:32 altheim Exp $
Author:
Murray Altheim
See Also:
Facet

Field Summary
static String fsfx
          The facet ID suffix (used to prefix auto-generated IDs).
protected  Topic m_facet
          The facet Topic.
protected  Occurrence m_facetDefault
          The Occurrence containing the facet default value.
protected  Topic m_faceted
          The Topic being faceted.
protected  Occurrence m_facetMaxExcl
          The Occurrence containing the facet maximum exclusive constraint value.
protected  Occurrence m_facetMaxIncl
          The Occurrence containing the facet maximum inclusive constraint value.
protected  Occurrence m_facetMinExcl
          The Occurrence containing the facet minimum exclusive constraint value.
protected  Occurrence m_facetMinIncl
          The Occurrence containing the facet minimum inclusive constraint value.
protected  Topic m_facetType
          The facet typing Topic.
protected  Occurrence m_facetValue
          The Occurrence containing the facet value.
protected  Association m_hasFacet
          The hasFacet Association.
protected  TopicMap m_tm
          The TopicMap in which the facet occurs.
 
Constructor Summary
FacetImpl(Association hasFacet)
          Constructor for a Facet provided with the hasFaceted Association.
FacetImpl(Topic faceted)
          Constructor for a Facet with the faceted Topic.
FacetImpl(Topic faceted, Topic facet)
          Constructor for a Facet with the facet and faceted Topics.
FacetImpl(Topic faceted, Topic facet, Topic facetType)
          Constructor for a Facet with the facet, faceted, and facet type Topics.
FacetImpl(Topic faceted, Topic facet, Topic facetType, Object facetValue)
          Constructor for a Facet with the facet, faceted, and facet type Topics, and the facet value.
FacetImpl(Topic faceted, Topic facet, Topic facetType, Object facetValue, String facetName, Object facetDefault, Object facetMinIncl, Object facetMaxIncl, Object facetMinExcl, Object facetMaxExcl)
          Constructor for the "everything" bagel/facet.
 
Method Summary
 Topic getFacet()
          Return the facet Topic.
 Occurrence getFacetDefault()
          Return the facet Default as a Topic Occurrence.
 Topic getFaceted()
          Return the faceted Topic.
 Association getFacetLink()
          Return the facet Association.
 Occurrence getFacetMaxExcl()
          Return the facet maximum exclusive constraint as a Topic Occurrence.
 Occurrence getFacetMaxIncl()
          Return the facet maximum inclusive constraint as a Topic Occurrence.
 Occurrence getFacetMinExcl()
          Return the facet minimum exclusive constraint as a Topic Occurrence.
 Occurrence getFacetMinIncl()
          Return the facet minimum inclusive constraint as a Topic Occurrence.
 BaseName getFacetName()
          Return the facet Name as a String.
 Collection getFacetTypes(boolean includeMergedTopics)
          Return the types of this Facet, and optionally, of all merged Topics.
 Occurrence getFacetValue()
          Return the facet value as an Occurrence.
protected  void setFacet(Topic facet)
          Set the facet Topic and generate the 'hasFacet' Association.
 void setFacetDefault(Object facetDefault)
          Set the facet default value to the object facetDefault, which must be either a String or a Locator.
protected  void setFaceted(Topic faceted)
          Set the faceted Topic.
 void setFacetMaxExcl(Object facetMaxExcl)
          Set the facet maximum exclusive constraint to the Object facetMaxExcl, which must be either a String or a Locator.
 void setFacetMaxIncl(Object facetMaxIncl)
          Set the facet maximum inclusive constraint to the Object facetMaxIncl, which must be either a String or a Locator.
 void setFacetMinExcl(Object facetMinExcl)
          Set the facet minimum exclusive constraint to the Object facetMinExcl, which must be either a String or a Locator.
 void setFacetMinIncl(Object facetMinIncl)
          Set the facet minimum inclusive constraint to the Object facetMinIncl, which must be either a String or a Locator.
 void setFacetName(String name)
          Set the facet Name to the String name.
 void setFacetType(Topic facetType, boolean replace)
          Add the Topic facetType as a type of this Facet.
 void setFacetValue(Object facetValue)
          Set the facet Value to the Object facetValue, which must be either a String or a Locator.
 String toString()
          Return a String representation of this Facet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fsfx

public static String fsfx
The facet ID suffix (used to prefix auto-generated IDs). Default is "f-".


m_tm

protected TopicMap m_tm
The TopicMap in which the facet occurs.


m_facet

protected Topic m_facet
The facet Topic.


m_faceted

protected Topic m_faceted
The Topic being faceted.


m_facetType

protected Topic m_facetType
The facet typing Topic.


m_hasFacet

protected Association m_hasFacet
The hasFacet Association.


m_facetValue

protected Occurrence m_facetValue
The Occurrence containing the facet value.


m_facetDefault

protected Occurrence m_facetDefault
The Occurrence containing the facet default value.


m_facetMinIncl

protected Occurrence m_facetMinIncl
The Occurrence containing the facet minimum inclusive constraint value.


m_facetMaxIncl

protected Occurrence m_facetMaxIncl
The Occurrence containing the facet maximum inclusive constraint value.


m_facetMinExcl

protected Occurrence m_facetMinExcl
The Occurrence containing the facet minimum exclusive constraint value.


m_facetMaxExcl

protected Occurrence m_facetMaxExcl
The Occurrence containing the facet maximum exclusive constraint value.

Constructor Detail

FacetImpl

public FacetImpl(Topic faceted)
          throws TopicMapException
Constructor for a Facet with the faceted Topic. The facet Topic and the Association between them will be created, and is returned with getFacet() and getFacetLink(), respectively.

Parameters:
faceted - the faceted Topic
Throws:
TopicMapException - if the faceted Topic is null or an error occurs during construction

FacetImpl

public FacetImpl(Topic faceted,
                 Topic facet)
          throws TopicMapException
Constructor for a Facet with the facet and faceted Topics. The Association between them will be created, and is returned with getFacetLink().

Parameters:
faceted - the faceted Topic (i.e., the Topic receiving the facet)
facet - the facet Topic (i.e., the Topic acting as a facet)
Throws:
TopicMapException - if the faceted Topic is null or an error occurs during construction

FacetImpl

public FacetImpl(Topic faceted,
                 Topic facet,
                 Topic facetType)
          throws TopicMapException
Constructor for a Facet with the facet, faceted, and facet type Topics. The Association between them will be created, and is returned with getFacetLink(). In order to differentiate the constructor signature, if the faceted Topic and facet type Topic are provided, but the facet Topic is null, the latter will be created (and is returned via getFacet().

Parameters:
faceted - the faceted Topic
facet - the optional Topic used as a facet
facetType - the facet typing Topic
Throws:
TopicMapException - if the faceted Topic is null or an error occurs during construction

FacetImpl

public FacetImpl(Topic faceted,
                 Topic facet,
                 Topic facetType,
                 Object facetValue)
          throws TopicMapException
Constructor for a Facet with the facet, faceted, and facet type Topics, and the facet value. The Association between them will be created, and is returned with getFacetLink(). The supplied Object for the facet value may be either a String (in XTM, represented as a <resourceData> element) or a a Locator (in XTM, represented as a <resourceRef>).

Parameters:
faceted - the faceted Topic
facet - the Topic used as a facet
facetType - the facet typing Topic
facetValue - the facet value, either a String or a Locator
Throws:
TopicMapException - if the faceted Topic is null or an error occurs during construction

FacetImpl

public FacetImpl(Topic faceted,
                 Topic facet,
                 Topic facetType,
                 Object facetValue,
                 String facetName,
                 Object facetDefault,
                 Object facetMinIncl,
                 Object facetMaxIncl,
                 Object facetMinExcl,
                 Object facetMaxExcl)
          throws TopicMapException
Constructor for the "everything" bagel/facet. All parameters are optional except the faceted Topic. The TopicMap used will be obtained from the faceted Topic.

Parameters:
faceted - the faceted Topic (i.e., the Topic being faceted)
facet - the Topic used as a facet
facetType - the facet typing Topic
facetValue - the facet value, either a String or a Locator
facetName - the facet name, as a String
facetDefault - the facet default value, as a String or a Locator
facetMinIncl - the facet minimum inclusive value, as a String or a Locator
facetMaxIncl - the facet maximum inclusive value, as a String or a Locator
facetMinExcl - the facet minimum exclusive value, as a String or a Locator
facetMaxExcl - the facet maximum exclusive value, as a String or a Locator
Throws:
TopicMapException - if the faceted Topic is null or an error occurs during construction

FacetImpl

public FacetImpl(Association hasFacet)
          throws TopicMapException
Constructor for a Facet provided with the hasFaceted Association. While other Facet constructors are generally designed to create a Facet for the first time, this is used for reconstructing a Facet from an existing Topic Map, provided its facet link.

Parameters:
hasFacet - the faceting Association
Throws:
TopicMapException - if the Facet cannot be reconstructed for any reason, or the found structure is invalid.
Method Detail

setFaceted

protected void setFaceted(Topic faceted)
                   throws TopicMapException
Set the faceted Topic. This also sets the TopicMap used.

Throws:
TopicMapException

getFaceted

public Topic getFaceted()
Return the faceted Topic.

Specified by:
getFaceted in interface Facet

setFacet

protected void setFacet(Topic facet)
                 throws TopicMapException
Set the facet Topic and generate the 'hasFacet' Association. If the facet Topic has already been created, this throws a TopicMapException. If it has not been created and the value of the parameter is null, a new Topic will be created.

Throws:
TopicMapException

getFacet

public Topic getFacet()
Return the facet Topic.

Specified by:
getFacet in interface Facet

getFacetLink

public Association getFacetLink()
Return the facet Association.

Specified by:
getFacetLink in interface Facet

setFacetType

public void setFacetType(Topic facetType,
                         boolean replace)
                  throws TopicMapException
Add the Topic facetType as a type of this Facet. If the boolean replace is true, any existing types are removed.

Specified by:
setFacetType in interface Facet
Throws:
TopicMapException

getFacetTypes

public Collection getFacetTypes(boolean includeMergedTopics)
Return the types of this Facet, and optionally, of all merged Topics.

Specified by:
getFacetTypes in interface Facet

setFacetValue

public void setFacetValue(Object facetValue)
                   throws TopicMapException
Set the facet Value to the Object facetValue, which must be either a String or a Locator. This will overwrite any existing value.

Specified by:
setFacetValue in interface Facet
Throws:
TopicMapException

getFacetValue

public Occurrence getFacetValue()
Return the facet value as an Occurrence.

Specified by:
getFacetValue in interface Facet

setFacetName

public void setFacetName(String name)
                  throws TopicMapException
Set the facet Name to the String name. If the provided argument is null, the name will be created from either the facet type (if available) or the facet ID (as a last resort).

Specified by:
setFacetName in interface Facet
Throws:
TopicMapException

getFacetName

public BaseName getFacetName()
Return the facet Name as a String.

Specified by:
getFacetName in interface Facet

setFacetDefault

public void setFacetDefault(Object facetDefault)
                     throws TopicMapException
Set the facet default value to the object facetDefault, which must be either a String or a Locator.

Specified by:
setFacetDefault in interface Facet
Throws:
TopicMapException

getFacetDefault

public Occurrence getFacetDefault()
Return the facet Default as a Topic Occurrence.

Specified by:
getFacetDefault in interface Facet

setFacetMinIncl

public void setFacetMinIncl(Object facetMinIncl)
                     throws TopicMapException
Set the facet minimum inclusive constraint to the Object facetMinIncl, which must be either a String or a Locator.

Specified by:
setFacetMinIncl in interface Facet
Throws:
TopicMapException

getFacetMinIncl

public Occurrence getFacetMinIncl()
Return the facet minimum inclusive constraint as a Topic Occurrence.

Specified by:
getFacetMinIncl in interface Facet

setFacetMaxIncl

public void setFacetMaxIncl(Object facetMaxIncl)
                     throws TopicMapException
Set the facet maximum inclusive constraint to the Object facetMaxIncl, which must be either a String or a Locator.

Specified by:
setFacetMaxIncl in interface Facet
Throws:
TopicMapException

getFacetMaxIncl

public Occurrence getFacetMaxIncl()
Return the facet maximum inclusive constraint as a Topic Occurrence.

Specified by:
getFacetMaxIncl in interface Facet

setFacetMinExcl

public void setFacetMinExcl(Object facetMinExcl)
                     throws TopicMapException
Set the facet minimum exclusive constraint to the Object facetMinExcl, which must be either a String or a Locator.

Specified by:
setFacetMinExcl in interface Facet
Throws:
TopicMapException

getFacetMinExcl

public Occurrence getFacetMinExcl()
Return the facet minimum exclusive constraint as a Topic Occurrence.

Specified by:
getFacetMinExcl in interface Facet

setFacetMaxExcl

public void setFacetMaxExcl(Object facetMaxExcl)
                     throws TopicMapException
Set the facet maximum exclusive constraint to the Object facetMaxExcl, which must be either a String or a Locator.

Specified by:
setFacetMaxExcl in interface Facet
Throws:
TopicMapException

getFacetMaxExcl

public Occurrence getFacetMaxExcl()
Return the facet maximum exclusive constraint as a Topic Occurrence.

Specified by:
getFacetMaxExcl in interface Facet

toString

public String toString()
Return a String representation of this Facet. (Maybe in LTM?)

Overrides:
toString in class Object


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.