ilog.views.sdm.model
Class IlvRDFSDMModel

java.lang.Object
  extended by ilog.views.sdm.model.IlvBasicSDMModel
      extended by ilog.views.sdm.model.IlvFilterSDMModel
          extended by ilog.views.sdm.model.IlvRDFSDMModel
All Implemented Interfaces:
SDMModelListener, SDMPropertyChangeListener, IlvSDMModel, Serializable, EventListener

public class IlvRDFSDMModel
extends IlvFilterSDMModel

A metadata filter model that manages the metadata as RDF. It filters property accessors (get/set), keeps metadata invocations, and delegates regular property invocations to the underlying model.

Metadata consists of properties concerning the SDM model. They are used internally by SDM to add graphic properties, like x, y, layout options, and so on. Metadata is loaded and saved through XML, using RDF.

An RDF metadata item is a triple (subject, property, value) of type (IlvMResource, IlvMResource, Object). The subject and property must be recognized as metadata (that is, isMetadata(java.lang.Object, java.lang.String) must return true. The subject either belongs to the underlying model, or is a IlvMResource.

Namespaces: Best efforts are made to keep the namespaces inside the metadata. When a new object property is set and the prefix of the property name refers to a known namespace, the property is assumed to belong to this namespace. To simplify the processing, namespaces are assumed to be global.

Instances of this class can also be customized through metadata.

Since:
JViews 5.5
See Also:
ilog.views.sdm.metadata, Serialized Form

Nested Class Summary
static class IlvRDFSDMModel.Subject
          This subclass of IlvMresource encapsulates an SDM model object.
 
Field Summary
 boolean _cleanObjectsWhenRemoved
          If true, a call to removeObject(obj) will erase all metadata associated with "obj" as well.
 
Constructor Summary
IlvRDFSDMModel()
          Empty constructor.
IlvRDFSDMModel(IlvSDMModel filteredModel)
          Creates a new IlvRDFSDMModel for a specified filtered model.
 
Method Summary
 void addNamespace(Collection ns)
          Merges current namespaces with the given collection.
 void clear()
          This method clears current metadata and calls the clear method of the filtered model.
 String getAcceptedNamespacePrefixes()
          Returns the currently accepted namespace prefixes.
 Enumeration getChildren(Object parent)
          Returns the objects of a submodel.
 String getDefaultNamespace()
          Returns the current default namespace.
 String getID(Object obj)
          Returns the identifier of the object.
 IlvMModel getMetadata()
          Gets current metadata.
 Object getMetadataValue(Object object, String property)
          Returns a metadata value.
 Object getObject(String id)
          Returns the object of the model whose identifier is id.
 Object getObjectProperty(Object obj, String property)
          Returns the metadata value if the property is metadata, otherwise this method calls the getObjectProperty method of the filtered model.
 String[] getObjectPropertyNames(Object obj)
          This method calls the getObjectPropertyNames method of the filtered model and adds also the metadata associated with the object.
 Enumeration getObjects()
          Returns all the data objects added to this SDM model.
 Object getParent(Object obj)
          Returns the parent of an object, if that object belongs to a submodel.
static IlvRDFSDMModel getRDFSDMModel(IlvSDMEngine engine)
          Convenient function to find out the RDF model, if it exists.
 String getTag(Object obj)
          Returns the symbolic type (the "tag") of an object.
 boolean isEditable()
          Metadata is editable.
 boolean isEnabled()
          Returns true if this instance is enabled.
 boolean isLink(Object obj)
          Returns true if the specified data object is a link between two nodes.
 boolean isMetadata(Object object, String property)
          Returns whether the property is identified as metatada.
 boolean isMetadataInterned()
          Returns true if metadata is interned, see setMetadataInterned(boolean).
 void mergeMetadata(IlvMModel metadata)
          Merges with new metadata.
 void removeObject(Object object)
          see IlvSDMModel.removeObject(Object)
 void setAcceptedNamespacePrefixes(String prefixes)
          Sets accepted namespace prefixes.
 void setDefaultNamespace(String ns)
          Sets the default namespace.
 void setEnabled(boolean val)
          Controls whether this instance is enabled.
 void setID(Object obj, String id)
          Sets the identifier of an object.
 void setMetadata(IlvMModel metadata)
          Sets new metadata.
 void setMetadataInterned(boolean newVal)
          Controls whether metadata should be in the model or not.
 void setMetadataValue(Object object, String property, Object value)
          Records a metadata.
 void setObjectProperty(Object object, String property, Object value)
          This method calls the setObjectProperty method of the filtered model, unless the property is identified as metadata.
 
Methods inherited from class ilog.views.sdm.model.IlvFilterSDMModel
addObject, addObjectImpl, adjustmentFinished, createLink, createNode, dataChanged, getFilteredModel, getFrom, getIDImpl, getTo, isAdjusting, linkDestinationChanged, linkSourceChanged, objectAdded, objectRemoved, propertyChanged, setAdjusting, setFilteredModel, setFrom, setIDImpl, setTo
 
Methods inherited from class ilog.views.sdm.model.IlvBasicSDMModel
addSDMModelListener, addSDMPropertyChangeListener, allocID, contains, fireAdjustmentFinished, fireDataChanged, fireIDChanged, fireLinkDestinationChanged, fireLinkSourceChanged, fireObjectAdded, fireObjectRemoved, firePropertyChanged, removeSDMModelListener, removeSDMPropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_cleanObjectsWhenRemoved

public boolean _cleanObjectsWhenRemoved
If true, a call to removeObject(obj) will erase all metadata associated with "obj" as well. The default value is false to keep the metadata when an object's parent changes (the object is removed and added elsewhere in the hierarchy) or when Undo needs to keep removed values.

Constructor Detail

IlvRDFSDMModel

public IlvRDFSDMModel()
Empty constructor.


IlvRDFSDMModel

public IlvRDFSDMModel(IlvSDMModel filteredModel)
Creates a new IlvRDFSDMModel for a specified filtered model.

Parameters:
filteredModel - The model that this filtering model encapsulates.
Method Detail

getObjects

public Enumeration getObjects()
Returns all the data objects added to this SDM model. If isMetadataInterned() returns true, the metadata subjects are also returned.

Specified by:
getObjects in interface IlvSDMModel
Overrides:
getObjects in class IlvFilterSDMModel
Returns:
An enumeration of IlvSDMNodes.

setObjectProperty

public void setObjectProperty(Object object,
                              String property,
                              Object value)
This method calls the setObjectProperty method of the filtered model, unless the property is identified as metadata. In this case, setMetadataValue(java.lang.Object, java.lang.String, java.lang.Object) is invoked.

Specified by:
setObjectProperty in interface IlvSDMModel
Overrides:
setObjectProperty in class IlvFilterSDMModel
Parameters:
object - The object whose property must be set (model object or IlvMResource).
property - The name of the property to set.
value - The new value of the property.

getObjectProperty

public Object getObjectProperty(Object obj,
                                String property)
Returns the metadata value if the property is metadata, otherwise this method calls the getObjectProperty method of the filtered model.

Specified by:
getObjectProperty in interface IlvSDMModel
Overrides:
getObjectProperty in class IlvFilterSDMModel
Parameters:
obj - The object whose property is queried.
property - The name of the property.
Returns:
An Object representing the value of the specified property, or null if the object does not have or support the specified property.

getObjectPropertyNames

public String[] getObjectPropertyNames(Object obj)
This method calls the getObjectPropertyNames method of the filtered model and adds also the metadata associated with the object.

Specified by:
getObjectPropertyNames in interface IlvSDMModel
Overrides:
getObjectPropertyNames in class IlvFilterSDMModel
Parameters:
obj - The object whose property names are queried.

isEditable

public boolean isEditable()
Metadata is editable. If the underlying model is not editable, setObjectProperty(java.lang.Object, java.lang.String, java.lang.Object) will ignore the settings of regular data.

Specified by:
isEditable in interface IlvSDMModel
Overrides:
isEditable in class IlvFilterSDMModel

removeObject

public void removeObject(Object object)
see IlvSDMModel.removeObject(Object)

Specified by:
removeObject in interface IlvSDMModel
Overrides:
removeObject in class IlvFilterSDMModel
Parameters:
object - The object to remove.

clear

public void clear()
This method clears current metadata and calls the clear method of the filtered model.

Specified by:
clear in interface IlvSDMModel
Overrides:
clear in class IlvFilterSDMModel

getChildren

public Enumeration getChildren(Object parent)
Returns the objects of a submodel.

Specified by:
getChildren in interface IlvSDMModel
Overrides:
getChildren in class IlvFilterSDMModel
Parameters:
parent - The parent object.
Returns:
null.

getParent

public Object getParent(Object obj)
Returns the parent of an object, if that object belongs to a submodel. If the object is a top-level object, this method must return null.

Specified by:
getParent in interface IlvSDMModel
Overrides:
getParent in class IlvFilterSDMModel
Parameters:
obj - The object whose parent is queried.
Returns:
null.

isLink

public boolean isLink(Object obj)
Returns true if the specified data object is a link between two nodes.

Specified by:
isLink in interface IlvSDMModel
Overrides:
isLink in class IlvFilterSDMModel
Parameters:
obj - The object whose type is queried.
Returns:
false.

getID

public String getID(Object obj)
Returns the identifier of the object. The identifier of a local metadata item is the URI of its subject.

Specified by:
getID in interface IlvSDMModel
Overrides:
getID in class IlvFilterSDMModel
Parameters:
obj - The object whose identifier is requested.
Returns:
A String that identifies the object in a unique way.

setID

public void setID(Object obj,
                  String id)
Sets the identifier of an object. This method calls real model setID() methods, and then changes the metadata subject and value if they are meant to be updated.

Specified by:
setID in interface IlvSDMModel
Overrides:
setID in class IlvFilterSDMModel
Parameters:
obj - The object whose identifier is to be changed.
id - The new identifier.

getObject

public Object getObject(String id)
Returns the object of the model whose identifier is id.

Specified by:
getObject in interface IlvSDMModel
Overrides:
getObject in class IlvFilterSDMModel
Parameters:
id - The identifier of the requested object.
Returns:
The object whose identifier is id.

getTag

public String getTag(Object obj)
Returns the symbolic type (the "tag") of an object. Local metadata has type "metadata".

Specified by:
getTag in interface IlvSDMModel
Overrides:
getTag in class IlvFilterSDMModel
Parameters:
obj - The object whose tag is requested.
Returns:
A String that identifies the symbolic type of the object.

setEnabled

public void setEnabled(boolean val)
Controls whether this instance is enabled. When disabled, it does not intercept metadata requests, so it acts exactly as an IlvFilterSDMModel. Other specific methods of this class work normally, though. When enabled, the instance processes metadata.


isEnabled

public boolean isEnabled()
Returns true if this instance is enabled.

Returns:
true if this instance is enabled.

setMetadataInterned

public void setMetadataInterned(boolean newVal)
Controls whether metadata should be in the model or not. If true, the standalone metadata, that is, metadata with subjects that are not in the underlying model, is returned with the getObjects() method. The default value is false.


isMetadataInterned

public boolean isMetadataInterned()
Returns true if metadata is interned, see setMetadataInterned(boolean).


setDefaultNamespace

public void setDefaultNamespace(String ns)
Sets the default namespace. The default namespace substitutes for the empty namespace. For example, if the default namespace is "mySpace", then the property name ":prop" is expanded to "mySpace:prop".

See Also:
getDefaultNamespace()

getDefaultNamespace

public String getDefaultNamespace()
Returns the current default namespace. The default value is null.


getRDFSDMModel

public static IlvRDFSDMModel getRDFSDMModel(IlvSDMEngine engine)
Convenient function to find out the RDF model, if it exists.

Parameters:
engine - The SDM engine to explore.
Returns:
The instance of IlvRDFSDMModel which is in the model pipeline of the given engine, or null if no such instance exists.

setAcceptedNamespacePrefixes

public void setAcceptedNamespacePrefixes(String prefixes)
Sets accepted namespace prefixes. The accepted prefix filters the namespace properties. If the namespace of the property name given in getObjectProperty or setObjectProperty is accepted, it is then intercepted by this instance, otherwise the request is forwarded to the filtered model.

Parameters:
prefixes - The namespace prefixes, as a comma-separated list. If the argument is null, all namespaces are accepted.

getAcceptedNamespacePrefixes

public String getAcceptedNamespacePrefixes()
Returns the currently accepted namespace prefixes.

Returns:
A comma-separated list of accepted namespace prefixes or null if all namespaces are accepted.

isMetadata

public boolean isMetadata(Object object,
                          String property)
Returns whether the property is identified as metatada. The default implementation checks whether object is an IlvMResource or there is a colon ':' inside the property name. If ':' is found, then the namespace must be in the list defined by getAcceptedNamespacePrefixes().

Parameters:
object - The object to which the property belongs.
property - The name of the property.

setMetadataValue

public void setMetadataValue(Object object,
                             String property,
                             Object value)
Records a metadata. Note that the object argument does not need to belong to an SDM model.

Parameters:
object - The object whose property must be set.
property - The name of the property to set.
value - The new value of the property. Use null to erase the metadata.

getMetadataValue

public Object getMetadataValue(Object object,
                               String property)
Returns a metadata value. Note that the object argument does not need to belong to an SDM model.

Parameters:
object - The object whose property is searched for.
property - The name of the property.
Returns:
The value of the object property, or null if no property is found.

setMetadata

public void setMetadata(IlvMModel metadata)
Sets new metadata. Metadata consists of properties about model objects. These properties are used internally by SDM to add graphic properties, like x, y, layout options, and so on. Metadata is loaded and saved through XML, using RDF.

Parameters:
metadata - The new metadata structure (based on RDF statements). A null argument means clear the metadata.
See Also:
getMetadata()

mergeMetadata

public void mergeMetadata(IlvMModel metadata)
Merges with new metadata.

Parameters:
metadata - The new metadata structure (based on RDF statements). A null argument means that it is ignored.
See Also:
setMetadata(ilog.views.sdm.metadata.IlvMModel)

getMetadata

public IlvMModel getMetadata()
Gets current metadata.

Returns:
The current metadata. This method never returns null.
See Also:
setMetadata(ilog.views.sdm.metadata.IlvMModel)

addNamespace

public void addNamespace(Collection ns)
Merges current namespaces with the given collection.

Parameters:
ns - A collection of {#link ilog.views.sdm.metadata.Namespace}.


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.