UNICORE Resource Broker NJS Plugin
1.5α1

org.eurogrid.broker.server.gt3
Class Translator

java.lang.Object
  |
  +--org.eurogrid.broker.server.gt3.Translator
All Implemented Interfaces:
NamedPlugin, Serializable

public class Translator
extends Object
implements NamedPlugin, Serializable

UNICORE Resource to GLUE XPath search term translation service.

Version:
$Revision: 1.8 $, $Date: 2004/02/17 11:32:40 $
Author:
Donal K. Fellows
See Also:
Serialized Form

Nested Class Summary
static class Translator.Translation
          What a term is actually translated into.
static class Translator.TranslatorException
          Exception generated when setting up the translator engine.
 
Field Summary
static String DEFAULT_MAPPING_NAME
          The name of the default mapping to load from the ontology specification file.
static String DEFAULT_SEARCH_ROOT
           
 
Constructor Summary
Translator()
           
Translator(File model)
          Testing constructor.
Translator(URL model)
          Testing constructor.
 
Method Summary
 String getFormalName()
          Get the formal name of the plugin.
 Logger getLogger()
           
 String getName()
          Get the name of the plugin.
 void initialise(Logger logger, Element configRoot)
          Initialise the translator given a logger and a DOM element that is the root of our section of the master configuration file.
static void main(String[] args)
          Demo code.
protected  String translate(CapabilityResource r, List log)
          Translate a capability resource into a disjuction of XPath search terms.
protected  String translate(CapacityResource r, List log)
          Translate a capacity resource.
protected  String translate(InformationResource r, List log)
          Translate an information resource into XPath search terms.
 String translate(Resource r, List log)
          Translate a single UNICORE resource into an XPath search restriction.
 String translate(ResourceSet resources, List untranslatable, List log)
          Translate a set of resources into an XPath search term.
 List translate(String unicoreNative)
          Convert a "native UNICORE resource name" into a list of candidate translations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAPPING_NAME

public static final String DEFAULT_MAPPING_NAME
The name of the default mapping to load from the ontology specification file.

See Also:
Constant Field Values

DEFAULT_SEARCH_ROOT

public static final String DEFAULT_SEARCH_ROOT
See Also:
Constant Field Values
Constructor Detail

Translator

public Translator()

Translator

public Translator(File model)
           throws IOException,
                  Translator.TranslatorException
Testing constructor. Creates a translator from the given XML file, loading the translation mapping with the default name.

See Also:
DEFAULT_MAPPING_NAME

Translator

public Translator(URL model)
           throws IOException,
                  Translator.TranslatorException
Testing constructor. Creates a translator from the XML file at the given URL, loading the translation mapping with the default name.

See Also:
DEFAULT_MAPPING_NAME
Method Detail

getFormalName

public String getFormalName()
Description copied from interface: NamedPlugin
Get the formal name of the plugin. This should be long enough to allow people who are not experts with the code to understand it, and will be written to the log to associate itself with the shorter name.

Specified by:
getFormalName in interface NamedPlugin

getLogger

public Logger getLogger()

getName

public String getName()
Description copied from interface: NamedPlugin
Get the name of the plugin. This should be fairly short so that the logging messages aren't too massive.

Specified by:
getName in interface NamedPlugin

initialise

public void initialise(Logger logger,
                       Element configRoot)
                throws Translator.TranslatorException
Initialise the translator given a logger and a DOM element that is the root of our section of the master configuration file.

Parameters:
logger - NJS log to write our log messages to.
configRoot - Root of our bit of the configuration DOM tree. Currently require a ref attribute (where to load the compacted ontology from) and allow a name attribute (selects which translation in the ontology to use, defaulting to the value of DEFAULT_MAPPING_NAME.)
Throws:
Translator.TranslatorException - If something goes significantly wrong during initialisation.

main

public static void main(String[] args)
                 throws Exception
Demo code.

Parameters:
args - Takes a single argument, which is the name of the ontology file.
Throws:
Exception - Default handling is good enough for us.

translate

protected String translate(CapabilityResource r,
                           List log)
Translate a capability resource into a disjuction of XPath search terms.


translate

protected String translate(CapacityResource r,
                           List log)
Translate a capacity resource. This converts into an XPath search term consisting of a restriction (based on what can actually be translated) on attributes that models the way that UNICORE does its CapacityResource checking normally.


translate

protected String translate(InformationResource r,
                           List log)
Translate an information resource into XPath search terms. By default, this is actually a translation to the empty string because information resources are defined to always be satisfied.


translate

public String translate(Resource r,
                        List log)
Translate a single UNICORE resource into an XPath search restriction. This generates a bracketed term or a sequence of bracketed terms.

Returns:
XPath search fragment, or null to indicate that there is no mapping and a fallback approach must be used.

translate

public String translate(ResourceSet resources,
                        List untranslatable,
                        List log)
Translate a set of resources into an XPath search term.

Parameters:
resources - The set of resources to translate.
untranslatable - A list that will have the resources that it was impossible to translate added to it.
Returns:
XPath search string, or null if not one resource in the set was translatable (i.e. when there is nothing worth translating at all.)

translate

public List translate(String unicoreNative)
Convert a "native UNICORE resource name" into a list of candidate translations.

Returns:
List of Translator.Translation instances.

UNICORE Resource Broker NJS Plugin
1.5α1

Submit a bug or feature
Copyright © 2002-2004 University of Manchester, U.K. See license.terms for details.