com.tensegrity.graph.element
Class ElementService

java.lang.Object
  extended bycom.tensegrity.graph.element.ElementService

public class ElementService
extends java.lang.Object

This class represents the loader methods for obtaining elements from a resource file.

Version:
$Id: ElementService.java,v 1.34 2005/12/15 12:07:51 MichaelKegel Exp $
Author:
StepanRutz

Nested Class Summary
static class ElementService.Locations
          A simpler wrapper class to encapsulate locations read from a elements.xml file.
 
Method Summary
static boolean checkLocationsTag(java.lang.String elementURL)
          Method checkLocationsTag checks whether the given element file contains the location tag and returns true.
static java.lang.String getElementsName(java.lang.String elementURL)
          Reads the ElementConstants.ELEMENTSNAME attribute from the given element file and returns it as String.
static ElementService.Locations getLocations(java.lang.String elementURL)
          Method getLocations reads all optional locations of the given element file and returns an instance of class Locations or null if no such attributes are found.
static java.lang.String getPath(java.lang.String filename)
          Method getPath strips the filename from the path and returns the path of the filename.
static void loadElementsFromAttributes(AttributeList list)
          This method will load the elements from the given attribute list
static void loadElementsFromResource(java.lang.String filename, java.lang.Class resourceclass)
          This method will load the elements from the given xml file, using the specified classloader.
static void loadElementsFromResource(java.lang.String filename, java.lang.Class resourceclass, java.util.List nameList)
          This method will load the elements from the given xml file, using the specified classloader and will store the names of the resulting elements in the parameter set instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadElementsFromResource

public static final void loadElementsFromResource(java.lang.String filename,
                                                  java.lang.Class resourceclass)
                                           throws ReadException
This method will load the elements from the given xml file, using the specified classloader.

Parameters:
filename - the filename to load elements from.
resourceclass - the resourceclass whose classloader to use.
Throws:
ReadException - thrown if loading fails.

loadElementsFromAttributes

public static final void loadElementsFromAttributes(AttributeList list)
                                             throws BuildException
This method will load the elements from the given attribute list

Parameters:
list - The attribute list containing the data
Throws:
BuildException

loadElementsFromResource

public static final void loadElementsFromResource(java.lang.String filename,
                                                  java.lang.Class resourceclass,
                                                  java.util.List nameList)
                                           throws ReadException
This method will load the elements from the given xml file, using the specified classloader and will store the names of the resulting elements in the parameter set instance.

Parameters:
filename - the filename to load elements from.
resourceclass - the resourceclass whose classloader to use.
nameList - a list that all loaded elements will be put into; the list is not cleared so the newly loaded elements are appended to the list.
Throws:
ReadException - thrown if the loading fails.

checkLocationsTag

public static boolean checkLocationsTag(java.lang.String elementURL)
                                 throws BuildException,
                                        ReadException,
                                        XMLParseException
Method checkLocationsTag checks whether the given element file contains the location tag and returns true. Returns false, if no LOCATIONS tag is found.

Parameters:
elementURL - the filename of the elements file.
Returns:
boolean the boolean indicating whether the given file contains the LOCATIONS tag or not.
Throws:
ReadException - thrown if the file could not be read.
BuildException - thrown if the value could not read from the file.
XMLParseException - thrown if xml parsing failed.

getElementsName

public static java.lang.String getElementsName(java.lang.String elementURL)
                                        throws BuildException,
                                               XMLParseException,
                                               ReadException
Reads the ElementConstants.ELEMENTSNAME attribute from the given element file and returns it as String.

Parameters:
elementURL - url to load elements resource from.
Returns:
given element as String.
Throws:
BuildException - thrown if deserializing failed.
XMLParseException - thrown if xml reading failed.
ReadException - thrown if io failed.

getLocations

public static ElementService.Locations getLocations(java.lang.String elementURL)
                                             throws BuildException,
                                                    ReadException,
                                                    XMLParseException
Method getLocations reads all optional locations of the given element file and returns an instance of class Locations or null if no such attributes are found.

Parameters:
elementURL - the url of the elements file.
Returns:
Locations a ElementService.Locations instance consisting of all locations of the given input url.
Throws:
BuildException - thrown if deserialization failed.
ReadException - thrown if reading failed or if the list of locations is not specified in a way that it points to valid xml files defining the expected input.
XMLParseException - thrown if xml reading failed.

getPath

public static java.lang.String getPath(java.lang.String filename)
Method getPath strips the filename from the path and returns the path of the filename.

Parameters:
filename - the filename string
Returns:
String the path string, stripped from trailing filename.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.