org.ow2.weblab.core.extended.factory
Class WebLabResourceFactory

java.lang.Object
  extended by org.ow2.weblab.core.extended.factory.WebLabResourceFactory

public final class WebLabResourceFactory
extends Object

A factory to be used to create all the Resources defined in the model. When creating a Resource, this factory will ensure that it contains an URI compliant with WebLabRI.
This class contains two main types of methods.

Segment cannot be created through this class. The class SegmentFactory is dedicated to this task.

Since:
1.2.3
Author:
Cassidian WebLab Team
See Also:
SegmentFactory

Method Summary
static Annotation createAndLinkAnnotation(Resource resource)
          To create Annotations we strongly encourage to use this method.
static LowLevelDescriptor createAndLinkLowLevelDescriptor(Resource res)
          This method provides an easy and strongly recommended way to create LowLevelDescriptors.
static
<T extends MediaUnit>
T
createAndLinkMediaUnit(Document doc, Class<T> muClass)
          To create MediaUnits that are not Document we strongly encourage to use this method.
static PieceOfKnowledge createAndLinkPoK(ResultSet resultSet)
          You may need to create a PieceOfKnowledge in three main cases.
static
<T extends Resource>
T
createResource(String idRef, String idRes, Class<T> resClass)
          We strongly encourage NOT to use this method in order to create non standalone resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createAndLinkAnnotation

public static Annotation createAndLinkAnnotation(Resource resource)
To create Annotations we strongly encourage to use this method. It enables the creation of an Annotation having an URI compliant with the WebLabRI recommendations.
Since an Annotation hasn't any sense without being attached to a Resource, we only provide a method for creating Annotations that takes a Resource in parameter. As a result, the created Annotation is added to the Annotation List of the Resource.

Parameters:
resource - the Resource that will contains the created Annotation
Returns:
a new Annotation with a valid WebLabRI and added to resource

createAndLinkLowLevelDescriptor

public static LowLevelDescriptor createAndLinkLowLevelDescriptor(Resource res)
This method provides an easy and strongly recommended way to create LowLevelDescriptors. It enables the creation of a LowLevelDescriptor having an URI compliant with the WebLabRI recommendations.
Since an LowLevelDescriptor hasn't any sense without being attached to a Resource, we only provide a method for creating LowLevelDescriptors that takes a Resource in parameter. As a result, the created LowLevelDescriptor is added to the LowLevelDescriptor List of the Resource.

Parameters:
res - The Resource to be described by the LowLevelDescriptor.
Returns:
The LowLevelDescriptor describing res.

createAndLinkMediaUnit

public static <T extends MediaUnit> T createAndLinkMediaUnit(Document doc,
                                                             Class<T> muClass)
To create MediaUnits that are not Document we strongly encourage to use this method. It enables the creation of a MediaUnit having an URI compliant with the WebLabRI recommendations.
Since a non-Document MediaUnit hasn't any sense without being attached to a Document, we only provide a method for creating MediaUnits that takes a Document in parameter. As a result, the created MediaUnit (instance of the class given in parameter) is added to the MediaUnit List of the Document.

Type Parameters:
T - The parametrised type of MediaUnit to be created and returned
Parameters:
doc - The document in which to add the created MediaUnit
muClass - The parametrised type of MediaUnit to be created and returned
Returns:
The created MediaUnit

createAndLinkPoK

public static PieceOfKnowledge createAndLinkPoK(ResultSet resultSet)
You may need to create a PieceOfKnowledge in three main cases.
Automatically set a valid WebLabRI to the created PieceOfKnowledge using the ResultSet in parameter to generate an unique id. Created PoK will be added to resultSet.

Parameters:
resultSet - the ResultSet that will contains the created PieceOfKnowledge
Returns:
a new PieceOfKnowledge with a valid WebLabRI and added to resultSet

createResource

public static <T extends Resource> T createResource(String idRef,
                                                    String idRes,
                                                    Class<T> resClass)
We strongly encourage NOT to use this method in order to create non standalone resources. In fact, use this class to create Document, ComposedResource, Query and PieceOfKnowledge, the only standalone Resources. I.e. Resources that have a sense alone, and that are not contained by anything (but a ComposedResource).
For other Resource s, you should use other methods of this class.

Type Parameters:
T - The class of the Resource to be instancied.
Parameters:
idRef - Resource creator unique reference
idRes - Resource unique reference in the creator
resClass - The implementation class of the resource
Returns:
An instance of resourceClass with a valid WebLabRI


Copyright © 2012. All Rights Reserved.