net.sf.fikin.xml.xpath.functions
Class UrlExtractQueryParam

java.lang.Object
  extended by net.sf.fikin.xml.xpath.functions.UrlExtractQueryParam
All Implemented Interfaces:
javax.xml.xpath.XPathFunction

public class UrlExtractQueryParam
extends java.lang.Object
implements javax.xml.xpath.XPathFunction

Extracts a parameter value out the query part of one url

If the url does not have a query part, the given url is assumed to be a query

The url is assumed to be HTTP decoded i.e. parameter separator is '&' instead of '&' created on Jan 5, 2007

Since:
Version:
$Revision: 1.2 $
Author:
fiykov

Constructor Summary
UrlExtractQueryParam()
           
 
Method Summary
 java.lang.Object evaluate(java.util.List args)
          returns the parameter value
protected  java.lang.String getParam(java.lang.String query, java.lang.String paramName)
          extracts parameter value from an url-query string
protected  java.lang.String getQuery(java.lang.String url)
          extract the query part from an url
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlExtractQueryParam

public UrlExtractQueryParam()
Method Detail

evaluate

public java.lang.Object evaluate(java.util.List args)
                          throws javax.xml.xpath.XPathFunctionException
returns the parameter value

Specified by:
evaluate in interface javax.xml.xpath.XPathFunction
Returns:
parameter value or null in case url did not have or it was malformed
Throws:
javax.xml.xpath.XPathFunctionException

getQuery

protected java.lang.String getQuery(java.lang.String url)
extract the query part from an url

Parameters:
url - in the format "<path>?<query>
Returns:
query part or null

getParam

protected java.lang.String getParam(java.lang.String query,
                                    java.lang.String paramName)
extracts parameter value from an url-query string

Parameters:
query - in the format "<param>=<vallue>&amp;..."
paramName -
Returns:
parameter value, empty string for parameter without value (i.e. param=) or null when parameter not found


Copyright © 2003-2007 Nikolay Fiykov. All Rights Reserved.