org.apache.woden.wsdl20.extensions.http
Class HTTPLocation

java.lang.Object
  extended by org.apache.woden.wsdl20.extensions.http.HTTPLocation

public class HTTPLocation
extends java.lang.Object

This class represents the {http location} extension property of the BindingOperation component and the whttp:location extension attribute of the WSDL binding <operation> element, as defined by the WSDL 2.0 HTTP binding extensions. The HTTP location may be used as a template in which local names of elements from the instance data of the message to be serialized in request IRI are cited by enclosing the element name within curly braces (e.g. "temperature/{town}"). A curly brace-enclosed element name is substituted with the value of that element from the instance data when the request IRI is constructed.

This class has a single constructor which takes a String argument representing the original value of the HTTP location, which may be templated with the curly brace syntax described above. An object of this class represents only that HTTP location string (i.e. the location template cannot be modified). The class does have methods to substitute element values for local names and to return the derived HTTP location after substitution has occurred.

This class performs syntax validation of the original HTTP location template, checking that any single left and right curly braces are used correctly as pairs enclosing a String that is of the correct format to represent an element local name (i.e. of type xs:NCName). It also handles the double curly brace syntax defined by this extension to represent literal single curly braces in the derived location value. For example, "abc{{def" becomes "abc{def" in the derived location and this literal left brace is not used for matching purposes with a right curly brace.

TODO Replace behaviour described below with new EBNF grammar added to spec to fix this ambiguity

The specification of the WSDL 2.0 HTTP Binding extensions does not explicitly state how to interpret extraneous, unmatched curly braces, so this class adopts the following strategy:

If multiple single left braces precede a right brace, pair the right most one with the right brace and treat the others as unmatched left braces.

   e.g. "{..{..{xxxx}" 
 
If multiple single right braces follow a left brace, pair the left most one with the left brace and treat the others as unmatched right braces.
   e.g. "{xxxx}..}..}" 
 
Double left or right braces take precedence over potentially matching pairs of single braces.
   e.g. "{xxxx}}}" is evaluated as {xxxx,}},} not as {xxxx},}} 
 

Author:
John Kaputin (jkaputin@apache.org)

Constructor Summary
HTTPLocation(java.lang.String location)
          This constructor creates an HTTPLocation object from the specified String.
 
Method Summary
 java.lang.String getFormattedLocation()
          Same behaviour as toString()
 java.lang.String getOriginalLocation()
          TODO javadoc.
 HTTPLocationTemplate getTemplate(java.lang.String name)
          Return the first template with the specified name.
 HTTPLocationTemplate getTemplateInPath(java.lang.String name)
          Return the first template from the path with the specified name.
 HTTPLocationTemplate getTemplateInQuery(java.lang.String name)
          Return the first template from the query with the specified name.
 java.lang.String[] getTemplateNames()
          Return names of all templates in this HTTP location in the order they appear.
 java.lang.String[] getTemplateNamesInPath()
          Return names of all templates from the path portion of this HTTP location in the order they appear.
 java.lang.String[] getTemplateNamesInQuery()
          Return names of all templates from the query portion of this HTTP location in the order they appear.
 HTTPLocationTemplate[] getTemplates()
          Return all templates in this HTTP location.
 HTTPLocationTemplate[] getTemplates(java.lang.String name)
          Return an array of templates with the specified name.
 HTTPLocationTemplate[] getTemplatesInPath()
          Return the templates in this HTTP location that appear in the path.
 HTTPLocationTemplate[] getTemplatesInPath(java.lang.String name)
          Return an array of templates from the path with the specified name.
 HTTPLocationTemplate[] getTemplatesInQuery()
          Return the templates in this HTTP location that appear in the query.
 HTTPLocationTemplate[] getTemplatesInQuery(java.lang.String name)
          Return an array of templates from the query with the specified name.
 boolean isLocationValid()
          TODO javadoc.
 java.lang.String toString()
          Returns a String representing the HTTP Location template with any element name/value substitution that has taken place via the substitute methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HTTPLocation

public HTTPLocation(java.lang.String location)
This constructor creates an HTTPLocation object from the specified String. This String is the original value of the {http location} property, prior to any template substitution of element local names enclosed in curly braces with element values. If the property was parsed from a WSDL document, this will be the value of the whttp:location attribute within a binding operation element.

The location template String argument must not be null.

Parameters:
location - the String value of the http location
Method Detail

isLocationValid

public boolean isLocationValid()
TODO javadoc. Method created for WODEN-148

Returns:
true if the format of the original HTTP location string is valid

getOriginalLocation

public java.lang.String getOriginalLocation()
TODO javadoc. Method created for WODEN-148

Returns:
the original String value of the HTTP location, prior to any template substitution

getFormattedLocation

public java.lang.String getFormattedLocation()
Same behaviour as toString()

Returns:
the formatted HTTP location, after any template substitution

toString

public java.lang.String toString()
Returns a String representing the HTTP Location template with any element name/value substitution that has taken place via the substitute methods. If any element local name has not yet been substituted with a value then that local name will appear in the String in its original template form, enclosed in curly braces.

If the HTTP Location does not contain any curly brace template syntax then substitution is not applicable and this method will return the same String value as the getLocationTemplate() method.

Overrides:
toString in class java.lang.Object

getTemplates

public HTTPLocationTemplate[] getTemplates()
Return all templates in this HTTP location.

Returns:
an array of HTTPLocationTemplate objects

getTemplatesInPath

public HTTPLocationTemplate[] getTemplatesInPath()
Return the templates in this HTTP location that appear in the path. That is, before the first occurrence of "?".

Returns:
an array of HTTPLocationTemplate objects

getTemplatesInQuery

public HTTPLocationTemplate[] getTemplatesInQuery()
Return the templates in this HTTP location that appear in the query. That is, after the first occurrence of "?".

Returns:
an array of HTTPLocationTemplate objects

getTemplateNames

public java.lang.String[] getTemplateNames()
Return names of all templates in this HTTP location in the order they appear.


getTemplateNamesInPath

public java.lang.String[] getTemplateNamesInPath()
Return names of all templates from the path portion of this HTTP location in the order they appear.


getTemplateNamesInQuery

public java.lang.String[] getTemplateNamesInQuery()
Return names of all templates from the query portion of this HTTP location in the order they appear.


getTemplate

public HTTPLocationTemplate getTemplate(java.lang.String name)
Return the first template with the specified name.


getTemplates

public HTTPLocationTemplate[] getTemplates(java.lang.String name)
Return an array of templates with the specified name.


getTemplateInPath

public HTTPLocationTemplate getTemplateInPath(java.lang.String name)
Return the first template from the path with the specified name. That is, before the first occurrence of "?".


getTemplatesInPath

public HTTPLocationTemplate[] getTemplatesInPath(java.lang.String name)
Return an array of templates from the path with the specified name. That is, before the first occurrence of "?".


getTemplateInQuery

public HTTPLocationTemplate getTemplateInQuery(java.lang.String name)
Return the first template from the query with the specified name. That is, after the first occurrence of "?".


getTemplatesInQuery

public HTTPLocationTemplate[] getTemplatesInQuery(java.lang.String name)
Return an array of templates from the query with the specified name. That is, after the first occurrence of "?".



Copyright © 2007. All Rights Reserved.