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

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

public class ResourceFactory
extends java.lang.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.
We strongly encourage NOT to use this class in order to create non standalone resources. In fact, use this class to create Document, ComposedResource, Query and UsageContext, the only standalone Resources. For other Resource s, you should use other factories.

Author:
Cassidian WebLab Team
See Also:
PoKFactory, MediaUnitFactory, SegmentFactory, LowLevelDescriptorFactory
Date:
2008-01-15

Field Summary
protected static java.util.Map<java.lang.String,java.util.Set<java.lang.String>> innerMap
          This data structure is not well adapted to manage WebLab Resource
protected static char SEPARATOR
          The separator
 
Method Summary
protected static void addAnnotation(Annotation annotation, Resource resource, Resource root)
           
protected static void addChild(MediaUnit mu, Document parent)
           
protected static void addChild(MediaUnit mu, Resource parent, Resource root)
          Deprecated. since model 1.2, no need to separates root and parent. replaced by addChild(final MediaUnit mu, final Document parent)
protected static void addDescriptor(LowLevelDescriptor descriptor, Resource parent, Resource root)
           
protected static void addSegment(Segment segment, MediaUnit parent, Resource root)
           
protected static void cleanMapping(java.lang.String uri)
           
static
<T extends Resource>
T
createResource(java.lang.String idRef, java.lang.String idRes, java.lang.Class<T> resClass)
          Use this method to create Resources that have a sense alone, and that are not contained by anything (but a ComposedResource).
It's recommended to only use this class when creating Document, ComposedResource, Ontology, Query, Service and HumanResource instances.
protected static java.lang.String createSegmentURIFor(java.lang.Object segmentContainer)
           
protected static java.lang.String createUniqueURIFrom(Resource resource, boolean isChild, boolean isAnnotation)
          Create a URI checking it does not already exist in the resource.
protected static java.lang.String createUniqueURIin(java.util.Set<java.lang.String> uris, boolean isChild, boolean isAnnotation, java.lang.String parentUri)
           
protected static Resource findParent(MediaUnit mu, Resource resource)
           
protected static java.lang.String getUniqueWebLabRIFrom(Resource res, boolean isChild, boolean isAnnotation)
           
protected static java.util.Set<java.lang.String> getUris(java.lang.String key)
           
protected static java.util.Set<java.lang.String> listUri(Resource resource)
          List uris in the resource
protected static java.util.Set<java.lang.String> listUri(Resource resource, boolean force)
          Lists all URI in a resource and its subresources.
protected static java.util.Set<java.lang.String> listUri(Segment segment)
          Lists all URI in a segment and its subsegments.
protected static void removeChild(MediaUnit mu, Resource parent, Resource root)
           
protected static void setUris(java.lang.String key, java.util.Set<java.lang.String> uris)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR

protected static final char SEPARATOR
The separator

See Also:
Constant Field Values

innerMap

protected static final java.util.Map<java.lang.String,java.util.Set<java.lang.String>> innerMap
This data structure is not well adapted to manage WebLab Resource

Method Detail

createResource

public static <T extends Resource> T createResource(java.lang.String idRef,
                                                    java.lang.String idRes,
                                                    java.lang.Class<T> resClass)
Use this method to create Resources that have a sense alone, and that are not contained by anything (but a ComposedResource).
It's recommended to only use this class when creating Document, ComposedResource, Ontology, Query, Service and HumanResource instances.

Type Parameters:
T - The class of the Resource to be instancied.F
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

cleanMapping

protected static void cleanMapping(java.lang.String uri)

getUris

protected static java.util.Set<java.lang.String> getUris(java.lang.String key)

setUris

protected static void setUris(java.lang.String key,
                              java.util.Set<java.lang.String> uris)

listUri

protected static java.util.Set<java.lang.String> listUri(Resource resource)
List uris in the resource

Parameters:
resource - a resource
Returns:
a set of uri in this resource

listUri

protected static java.util.Set<java.lang.String> listUri(Segment segment)
Lists all URI in a segment and its subsegments.

Parameters:
segment - a segment

listUri

protected static java.util.Set<java.lang.String> listUri(Resource resource,
                                                         boolean force)
Lists all URI in a resource and its subresources.

Parameters:
resource - a resource
force - if false URI in this resource will not be listed if the resource have already been processed, else they will not matter what.
Returns:
a list of all URI in this resource the last time this resource was processed
WARNING:
this function does not support cyclic resources (a resource that contains itself) if force is true

createSegmentURIFor

protected static java.lang.String createSegmentURIFor(java.lang.Object segmentContainer)

createUniqueURIFrom

protected static java.lang.String createUniqueURIFrom(Resource resource,
                                                      boolean isChild,
                                                      boolean isAnnotation)
Create a URI checking it does not already exist in the resource.

Parameters:
resource - a top container resource
isChild - if true, the uri will describe a child or subchild of this resource
isAnnotation - if true, the uri will describe a annotation on this resource
Returns:
an URI unique among all URI in the resource and its sub resources

createUniqueURIin

protected static java.lang.String createUniqueURIin(java.util.Set<java.lang.String> uris,
                                                    boolean isChild,
                                                    boolean isAnnotation,
                                                    java.lang.String parentUri)

removeChild

protected static void removeChild(MediaUnit mu,
                                  Resource parent,
                                  Resource root)

addAnnotation

protected static void addAnnotation(Annotation annotation,
                                    Resource resource,
                                    Resource root)

addSegment

protected static void addSegment(Segment segment,
                                 MediaUnit parent,
                                 Resource root)

addDescriptor

protected static void addDescriptor(LowLevelDescriptor descriptor,
                                    Resource parent,
                                    Resource root)

addChild

@Deprecated
protected static void addChild(MediaUnit mu,
                                          Resource parent,
                                          Resource root)
Deprecated. since model 1.2, no need to separates root and parent. replaced by addChild(final MediaUnit mu, final Document parent)


addChild

protected static void addChild(MediaUnit mu,
                               Document parent)

findParent

protected static Resource findParent(MediaUnit mu,
                                     Resource resource)

getUniqueWebLabRIFrom

protected static final java.lang.String getUniqueWebLabRIFrom(Resource res,
                                                              boolean isChild,
                                                              boolean isAnnotation)
Parameters:
res - The Resource to be used to create WebLabRI
Returns:
The String to be used as URI by the MediaUnit created


Copyright © 2004-2011 WebLab Project. All Rights Reserved.