org.weblab_project.core.util
Class ResourceUtil

java.lang.Object
  extended by org.weblab_project.core.util.ResourceUtil

public class ResourceUtil
extends java.lang.Object

A class that contain a useful method when wanting to visualise the content and the structure of a Resource

Author:
EADS WebLab Team

Method Summary
static
<T extends org.weblab_project.core.model.Resource>
java.util.List<T>
getSelectedSubResources(org.weblab_project.core.model.Resource res, java.lang.Class<T> resClass)
          The same as ResourceUtil.getSubResources(Resource), but with a filter on the Resource class to be retrieved by the List.
static java.util.List<org.weblab_project.core.model.Resource> getSubResources(org.weblab_project.core.model.Resource res)
           
static org.weblab_project.core.model.Resource loadFromXMLString(java.lang.String xml)
          Simply transform the XML String into a Resource.
static void printTree(org.weblab_project.core.model.Resource res, java.io.OutputStream stream)
          Simple visualisation method that enable to print a user friendly (non-xml) description of res.
static java.lang.String saveToXMLString(org.weblab_project.core.model.Resource resource)
          Simply transforms resource into an XML String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

printTree

public static void printTree(org.weblab_project.core.model.Resource res,
                             java.io.OutputStream stream)
Simple visualisation method that enable to print a user friendly (non-xml) description of res. Uses a tree representation. For each type of Resource that might me contained by the given Resource and it's contained Resources print their URI and their class simple name. For any Resource, it's contained Resources might be:

Parameters:
res - The Resource to be printed
stream - The OutputStream to write into

saveToXMLString

public static java.lang.String saveToXMLString(org.weblab_project.core.model.Resource resource)
                                        throws WebLabCheckedException
Simply transforms resource into an XML String. Use the WebLabMarshaler for more configuration, and usage with files or streams.

Parameters:
resource - The Resource to be transformed into an XML String.
Returns:
A String containing the XML view of the Resource
Throws:
WebLabCheckedException
See Also:
WebLabMarshaler

loadFromXMLString

public static org.weblab_project.core.model.Resource loadFromXMLString(java.lang.String xml)
                                                                throws WebLabCheckedException
Simply transform the XML String into a Resource. Use the WebLabMarshaler for more configuration, and usage with files or streams.

Parameters:
xml - The XML String representing the Resource
Returns:
The Resource defined in the XML String.
Throws:
WebLabCheckedException

getSubResources

public static java.util.List<org.weblab_project.core.model.Resource> getSubResources(org.weblab_project.core.model.Resource res)
Parameters:
res - The Resource to retrieve children.
Returns:
The subResource List without res it self.

getSelectedSubResources

public static <T extends org.weblab_project.core.model.Resource> java.util.List<T> getSelectedSubResources(org.weblab_project.core.model.Resource res,
                                                                                                           java.lang.Class<T> resClass)
The same as ResourceUtil.getSubResources(Resource), but with a filter on the Resource class to be retrieved by the List. I.e. the only retrieved Resources are those that are instances of resClass.

Type Parameters:
T - Subclass of Resource to be retrieved
Parameters:
res - The Resource to retrieve children.
resClass - The Class of the only children you need in result List.
Returns:
The subResource List.
See Also:
getSubResources(Resource)


Copyright © 2004-2009. All Rights Reserved.