org.fudgemsg.taxon
Class RESTfulTaxonomyResolver

java.lang.Object
  extended by org.fudgemsg.taxon.URLTaxonomyResolver
      extended by org.fudgemsg.taxon.RESTfulTaxonomyResolver
All Implemented Interfaces:
TaxonomyResolver

public class RESTfulTaxonomyResolver
extends URLTaxonomyResolver

A taxonomy resolver implementation that obtains taxonomies over the network.

This creates URLs by substituting the taxonomy ID into a given string.


Constructor Summary
RESTfulTaxonomyResolver()
          Creates a new taxonomy resolver.
RESTfulTaxonomyResolver(String specPrefix)
          Creates a new taxonomy resolver.
RESTfulTaxonomyResolver(String specPrefix, String specSuffix)
          Creates a new taxonomy resolver.
RESTfulTaxonomyResolver(URL context, String specPrefix, String specSuffix)
          Creates a new taxonomy resolver, using a string relative to an existing URL.
 
Method Summary
protected  URL createTaxonomyURL(short taxonomyId)
          Returns the URL that the taxonomy corresponding to the ID should be loaded from.
 URL getContext()
          Returns the context URL.
 String getSpecPrefix()
          Returns the string prefix to precede the taxonomy ID.
 String getSpecSuffix()
          Returns the string suffix to follow the taxonomy ID.
 void setContext(String context)
          Sets or clears the context URL.
 void setContext(URL contextURL)
          Sets or clears the context URL.
 void setSpecPrefix(String specPrefix)
          Sets or clears the string prefix to precede the taxonomy ID.
 void setSpecSuffix(String specSuffix)
          Sets or clears the string suffix to follow the taxonomy ID.
 
Methods inherited from class org.fudgemsg.taxon.URLTaxonomyResolver
reset, resolveTaxonomy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RESTfulTaxonomyResolver

public RESTfulTaxonomyResolver()
Creates a new taxonomy resolver. This constructor is provided for Bean style construction for use in parameter injection frameworks.


RESTfulTaxonomyResolver

public RESTfulTaxonomyResolver(String specPrefix)
Creates a new taxonomy resolver. The URL is constructed as specPrefix + taxonomyId.

Parameters:
specPrefix - String fragment to precede the taxonomy ID

RESTfulTaxonomyResolver

public RESTfulTaxonomyResolver(String specPrefix,
                               String specSuffix)
Creates a new taxonomy resolver. The URL is constructed as specPrefix + taxonomyId + specSuffix. For example, creating the resolver as RESTfulTaxonomyResolver("http://fudgemsg.org/taxonomies/", ".xml") would resolve taxonomy ID 42 to the document at http://fudgemsg.org/taxonomies/42.xml.

Parameters:
specPrefix - String fragment to precede the taxonomy ID, or null
specSuffix - String fragment to follow the taxonomy ID, or null

RESTfulTaxonomyResolver

public RESTfulTaxonomyResolver(URL context,
                               String specPrefix,
                               String specSuffix)
Creates a new taxonomy resolver, using a string relative to an existing URL. See URL.URL(URL,String) for more details.

Parameters:
context - the URL context if the substitution string is relative, or null
specPrefix - the fragment to precede the taxonomy ID, null if none
specSuffix - the fragment to follow the taxonomy ID, null if none
Method Detail

getContext

public URL getContext()
Returns the context URL.

Returns:
the context URL, null if none

setContext

public void setContext(URL contextURL)
Sets or clears the context URL.

Parameters:
contextURL - the new URL, may be null

setContext

public void setContext(String context)
Sets or clears the context URL.

Parameters:
context - the new URL, may be null

getSpecPrefix

public String getSpecPrefix()
Returns the string prefix to precede the taxonomy ID.

Returns:
the string prefix, may be null

setSpecPrefix

public void setSpecPrefix(String specPrefix)
Sets or clears the string prefix to precede the taxonomy ID.

Parameters:
specPrefix - the new prefix, null for none

getSpecSuffix

public String getSpecSuffix()
Returns the string suffix to follow the taxonomy ID.

Returns:
the string suffix, may be null

setSpecSuffix

public void setSpecSuffix(String specSuffix)
Sets or clears the string suffix to follow the taxonomy ID.

Parameters:
specSuffix - the new suffix, null for none

createTaxonomyURL

protected URL createTaxonomyURL(short taxonomyId)
                         throws MalformedURLException
Description copied from class: URLTaxonomyResolver
Returns the URL that the taxonomy corresponding to the ID should be loaded from.

Specified by:
createTaxonomyURL in class URLTaxonomyResolver
Parameters:
taxonomyId - the taxonomy ID to locate
Returns:
the URL where the taxonomy is found, not null
Throws:
MalformedURLException - if there is a problem creating the URL, this will be wrapped into a runtime exception


Copyright 2009-Present by OpenGamma Inc. and individual contributors
Released under the Apache License, Version 2.0