The DLESE Expression Language (EL) function library implements functions
for use in JSP pages.
DLESE EL Function Library
1.0
f
http://www.dlese.org/dpc/dds/tags/dleseELFunctions
Convert XML to JSON.
xml2json
org.dlese.dpc.xml.XMLUtils
java.lang.String xml2json(java.lang.String)
${f:xml2json('<root><text>My text</text></root>'}
Convert dom4j Node that contains JavaBean XML to a JavaBean Object.
dom4j2JavaBean
org.dlese.dpc.xml.Dom4jUtils
java.lang.Object dom4j2JavaBean(org.dom4j.Node)
<xtags:variable id="javaObjectDom" type="node" select="$record/metadata/java"/>
<c:set var="myBean" value="${f:dom4j2JavaBean(javaObjectDom)}"/>
Imports the content from a URL as a String, timing out
if the server does not respond in the given number of milliseconds.
An exception is thrown if the time out period is reached.
timedImport
org.dlese.dpc.util.TimedURLConnection
java.lang.String importURL(java.lang.String, int)
${f:timedImport("http://example.org/remoteResource.xml", 2000)}
Imports the content from a URL as a String using the given character encoding,
timing out if the server does not respond in the given number of milliseconds.
An exception is thrown if the time out period is reached.
timedImportUsingEncoding
org.dlese.dpc.util.TimedURLConnection
java.lang.String importURL(java.lang.String, java.lang.String, int)
${f:timedImportUsingEncoding("ftp://example.org/remoteResource.xml", "UTF-8", 2000)}
Puts items in a Map, creating a new TreeMap if null is passed in for the myMap argument, otherwise updating the Map with the
key/value pair. Keys remain sorted sorted lexagraphically.
map
org.dlese.dpc.util.Utils
java.util.Map map(java.util.Map,java.lang.String,java.lang.String)
<c:set var="myMap" value="${f:map(myMap,'my key','my value')}" />
Puts items in a Map, creating a new Map if null is passed in for the myMap argument, otherwise updating the Map with the
key/value pair. Keys remain sorted by the *values* in the Map. Last argument must be one of 'ascending'or 'descending'.
mapSortByValue
org.dlese.dpc.util.Utils
java.util.Map mapSortByValue(java.util.Map,java.lang.String,java.lang.String,java.lang.String)
<c:set var="myMap" value="${f:mapSortByValue(myMap,'my key','my value',true)}" />
Create a Map from a Java properties String of the form: property=value (one per line)
propertiesMap
org.dlese.dpc.util.Utils
java.util.Map getPropertiesMap(java.lang.String)
${cfn:propertiesMap("shortTitle=my title\nlongTitle=my long title")}
Gets a global system unique ID. This algorithm is reasonably guaranteed to be correct within a single running JVM.
uniqueId
org.dlese.dpc.util.Utils
long getUniqueID()
My unique ID for this JVM run time is: ${f:uniqueId()}
Encodes a string for use in a URL using UTF-8.
URLEncoder
org.dlese.dpc.util.Utils
java.lang.String URLEncoder(java.lang.String)
http://someplace.org?code=${f:URLEncoder("code needs url encoding!")}
Encodes a string used in the URL sent to the redirect server
and ensures it does not contain problematic characters
for the Apache 1 mod_redirect rules (the character sequence %2F
is replaced with /).
RedirectEncoder
org.dlese.dpc.util.Utils
java.lang.String RedirectEncoder(java.lang.String)
Gets a geospatial Lucene query that will limit search to a given
bounding box and predicate. Predicate values must be one of ['contains','overlaps','within'].
Latitude and longitude values must be doubles.
geospatialQuery
edu.ucsb.adl.LuceneGeospatialQueryConverter
org.apache.lucene.search.Query convertQuery(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
The geospatial Query is : ${f:geospatialQuery(predicate,northCoord,southCoord,eastCoord,westCoord)}
Encodes a latitude value to a Lucene searchable String token.
encodeLatitude
edu.ucsb.adl.LuceneGeospatialQueryConverter
java.lang.String encodeLatitude(java.lang.String)
The latitude encoded is : ${f:encodeLatitude(latitudeValue)}
Encodes a longitude value to a Lucene searchable String token.
encodeLongitude
edu.ucsb.adl.LuceneGeospatialQueryConverter
java.lang.String encodeLongitude(java.lang.String)
The longitude encoded is : ${f:encodeLongitude(longitudeValue)}
Stems each of the words or tokens in a given String, returning a String of stemmed
tokens with all other characters removed. Token characters include letters and
numbers [a-zA-Z0-9], representing the class of tokens that are searchable by Lucene.
Note: the tokens "AND" and "OR" (upper case) are left unchanged.
stem
org.dlese.dpc.index.Stemmer
java.lang.String stemWordsInString(java.lang.String)
The stems for 'oceanic seas watering' are: ${f:stem("oceanic seas watering")}
Stems each of the words in a given Lucene query String, returning the same String with the word
parts in stemmed form. All other characters are left in tact,
and words that may be found in a Lucene query are unchanged such as 'AND', 'OR' and field specificers such
as 'titles:'.
stemClause
org.dlese.dpc.index.Stemmer
java.lang.String stemWordsInLuceneClause(java.lang.String)
The stemmed query for 'titles:(oceanic seas watering)' is: ${f:stemClause("titles:(oceanic seas watering)")}
Returns true if the given word is an english stop word.
isStopWord
org.dlese.dpc.index.LuceneStopWords
boolean isStopWord(java.lang.String)
and is a stop word!
]]>
Tells whether or not the first String matches the regular expression
supplied in the second String.
matches
org.dlese.dpc.util.Utils
boolean matches(java.lang.String, java.lang.String)
param.q contains a lucene query!
]]>
Replaces each substring of the first String that matches the regular expression
supplied in the second String with the replacement supplied in the third string.
replaceAll
org.dlese.dpc.util.Utils
java.lang.String replaceAll(java.lang.String, java.lang.String, java.lang.String)
${f:replaceAll("The cat ran to the cat store", "cat", "dog")}
Replaces the first substring of the first String that matches the regular expression
supplied in the second String with the replacement supplied in the third string.
replaceFirst
org.dlese.dpc.util.Utils
java.lang.String replaceFirst(java.lang.String, java.lang.String, java.lang.String)
${f:replaceFirst("The cat ran to the cat store", "cat", "dog")}
Splits the first string around matches of the regular expression supplied in the second String.
splitRegEx
org.dlese.dpc.util.Utils
java.lang.String[] split(java.lang.String, java.lang.String)
]]>
Returns true if the object in the first parameter contains the Object in the second parameter according
to the Objects equals method. The first parameter can be an Array, Collection (List, Set, etc.), Map or
String. If the Object in the first parameter is a String, returns true if the Object in the second
parameter is a subString of the first. If the Object in the first parameter is a Map, returns true if one
of it's keys is equal to the Object in the second parameter.
This is a more versitile version of the regular JSTL contains function.
contains
org.dlese.dpc.util.Utils
boolean contains(java.lang.Object, java.lang.Object)
One or more 'relation' parameters contains the value 'isAnnotatedBy'!
]]>
Encodes a String such that it is guaranteed to be valid inside JavaScript quotes.
jsEncode
org.dlese.dpc.util.HTMLTools
java.lang.String javaScriptEncodeToStr(java.lang.String)
JavaScript:alert('${f:jsEncode(param.q)}');
Gets the DPC error message associated with a given error code (Integer).
DPCErrorMsg
org.dlese.dpc.util.DpcErrors
java.lang.String getMessage(int)
The error message was: ${f:DPCErrorMsg('410010')}.
Gets the DPC error code associated with a given error message String.
DPCErrorCode
org.dlese.dpc.util.DpcErrors
int getType(java.lang.String)
The error code was: ${f:DPCErrorMsg('Duplicate ID')}.
Encodes a String to an appropriate format as a single Lucene term for searching,
including whate space.
encodeToTerm
org.dlese.dpc.index.SimpleLuceneIndex
String encodeToTerm(java.lang.String)
The search query term is: ${f:encodeToTerm('this is all one term!')}.
Escapes all Lucene QueryParser reserved characters with a preceeding \. The resulting
String will be interpereted by the QueryParser as a single term.
escape
org.dlese.dpc.index.SimpleLuceneIndex
String escape(java.lang.String)
The search query term is: ${f:escapeTerm('http://www.dlese.org/')}.
Escapes all Lucene QueryParser reserved characters with a preceeding \
except the ones indicated in the second parameter
escapeAllExcept
org.dlese.dpc.index.SimpleLuceneIndex
String escape(java.lang.String, java.lang.String)
The search query term is: ${f:escapeAllExcept('http://www.dlese.org*','*')}.
Converts a date String of the form YYYY-mm-dd, YYYY-mm, YYYY or yyyy-MM-ddTHH:mm:ssZ
to a searchable Lucene (v2.x) lexical date String of the form 'yyyyMMddHHmmss', or null if unable
to parse the date String.
lexicalDate
org.dlese.dpc.util.Utils
java.lang.String getLexicalDateString(java.lang.String)
The search query is: wndate:[${f:lexicalDate('2004-09-15')} TO ${f:lexicalDate('2004-12-15')}]
Converts a lexical Lucene date String of the form '0cq0gyn40' into a Java Date Object. If the String
can not be converted, returns null.
luceneDate
org.dlese.dpc.util.Utils
java.util.Date luceneStringToDate(java.lang.String)
The item was new on: ${f:luceneDate(result.docMap['wndate'])}.
Converts a long that contains milliseconds to a Date.
convertLongToDate
org.dlese.dpc.util.Utils
java.util.Date convertLongToDate(long)
The date was: ${f:convertLongToDate( myDateInMilliSeconds )}.
Converts a Date Object to a ISO8601 UTC datestamp String of the form yyyy-MM-ddTHH:mm:ssZ in the UTC timezone.
dateToUtcDatestamp
org.dlese.dpc.oai.OAIUtils
java.lang.String getDatestampFromDate(java.util.Date)
The OAI UTC datestampe is: ${f:dateToUtcDatestamp( myDate )}.
Converts a ISO8601 UTC datestamp String of the form yyyy-MM-ddTHH:mm:ssZ or yyyy-MM-dd in the UTC timezone
to a Date Object.
utcDatestampToDate
org.dlese.dpc.oai.OAIUtils
java.util.Date getDateFromDatestamp(java.lang.String)
]]>
Generates an XML String representation of a dom4j Node, Element, Document, Branch, etc.
dom4jToXml
org.dlese.dpc.xml.Dom4jUtils
java.lang.String prettyPrint(org.dom4j.Node)
]]>
Localizes a Dom4j Document by removing all namespaces from it, for
use with the xtags library.
With namespaces removed, the XPath syntax necessary to work with the
document is greatly simplified.
localizeDom4j
org.dlese.dpc.xml.Dom4jUtils
org.dom4j.Document localizeXml(org.dom4j.Document)
]]>
Gets an XSL style sheet that removes all namespaces from an XML document.
With namespaces removed, the XPath syntax necessary to work with the
document is greatly simplified.
removeNamespacesXsl
org.dlese.dpc.xml.XSLUtils
java.lang.String getRemoveNamespacesXSL()
]]>
Reconstructs the URL the client used to make the request, even if the page has been forwarded for example via struts (action.do).
The returned URL contains a protocol, server name, port number,
and server path, but it does not include query string parameters.
requestURL
org.dlese.dpc.webapps.tools.GeneralServletTools
java.lang.StringBuffer getRequestURL(javax.servlet.http.HttpServletRequest)
The requested URL for this page is: ${f:requestURL(pageContext.request)}.
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
Works properly, even if the page has been forwarded for example via struts (action.do).
requestURI
org.dlese.dpc.webapps.tools.GeneralServletTools
java.lang.String getRequestURI(javax.servlet.http.HttpServletRequest)
The requested URI for this page is: ${f:requestURI(pageContext.request)}.
Gets the absolute URL to the current server, for example
'http://www.dlese.org' or 'http://tremor.dpc.ucar.edu:9187'
serverUrl
org.dlese.dpc.webapps.tools.GeneralServletTools
java.lang.String getServerUrl(javax.servlet.http.HttpServletRequest)
The URL to the page is: ${f:serverUrl(pageContext.request)}/context/pages/index.jsp.
Gets the absolute URL to the current servlet context, for example
'http://www.dlese.org/dds' or 'http://tremor.dpc.ucar.edu:9187/news_opps'
contextUrl
org.dlese.dpc.webapps.tools.GeneralServletTools
java.lang.String getContextUrl(javax.servlet.http.HttpServletRequest)
The URL to the page is: ${f:contextUrl(pageContext.request)}/pages/index.jsp.
Writes a file to the local file system using UTF-8 encoding.
The first argument contains the content
to be written, the second argument is the full file path.
For security, file paths should be hard-coded into JSP
pages. If user input is needed, carefully
validate and scrub the input prior to writing to the given path.
writeFile
org.dlese.dpc.util.Files
void writeFile(java.lang.String,java.lang.String)
${f:writeFile('Here is some content','/home/my_user_home/files/my_document.txt')}
Ouputs text to the System.out print stream.
systemOut
org.dlese.dpc.util.Utils
void printToSystemOut(java.lang.String)
${f:systemOut( 'The debug param is:' )} ${f:systemOut( param.debug )}
Ouputs text to the System.err print stream.
systemErr
org.dlese.dpc.util.Utils
void printToSystemErr(java.lang.String)
${f:systemErr( 'The debug param is:' )} ${f:systemOut( param.debug )}
Ouputs the name of the object's class to standard out and returns as a String.
objectInspector
org.dlese.dpc.util.Utils
java.lang.String ObjectInspector(java.lang.Object)
The object is of type: ${f:objectInspector( myObject )}