nu.staldal.lsp
Class LSPPageBase

java.lang.Object
  extended by nu.staldal.lsp.LSPPageBase
All Implemented Interfaces:
LSPPage

public abstract class LSPPageBase
extends java.lang.Object
implements LSPPage

Base class for compiled LSP pages.

This class is not part of the public API, it should only be used by compiled LSP pages. It is declared public since compiled LSP pages needs to access it.

Author:
Mikael Ståldal

Field Summary
protected  java.lang.String[] compileDependentFiles
           
protected  java.lang.String compiledVersionName
           
protected  int compiledVersionNum
           
protected  boolean compileDynamic
           
protected  java.lang.String[] extLibsClassNames
           
protected  java.lang.String[] extLibsURLs
           
protected  java.util.Properties outputProperties
           
protected  java.lang.String pageName
           
protected  long timeCompiled
           
 
Fields inherited from interface nu.staldal.lsp.LSPPage
LSP_VERSION_NAME, LSP_VERSION_NUM
 
Constructor Summary
protected LSPPageBase(java.lang.String[] extLibsURLs, java.lang.String[] extLibsClassNames, java.lang.String[] compileDependentFiles, boolean compileDynamic, long timeCompiled, java.lang.String pageName, java.lang.String versionName, int versionNum)
           
 
Method Summary
protected abstract  void _execute(org.xml.sax.ContentHandler sax, nu.staldal.util.Environment<java.lang.String,java.lang.Object> env, java.util.Map<java.lang.String,LSPExtLib> extLibs, org.xml.sax.ContentHandler _sax, org.xml.sax.helpers.AttributesImpl attrs)
           
protected static boolean compareEqual(java.lang.Object left, java.lang.Object right)
           
protected static java.lang.Object convertObjectToLSP(java.lang.Object value)
           
protected static boolean convertToBoolean(java.lang.Object _value)
           
protected static boolean convertToBooleanAcceptNull(java.lang.Object _value)
           
protected static java.util.Collection<?> convertToList(java.lang.Object _value)
           
protected static double convertToNumber(java.lang.Object _value)
           
protected static java.lang.String convertToString(java.lang.Object _value)
           
protected static java.util.Map<?,?> convertToTuple(java.lang.Object _value)
           
protected static java.lang.Double doubleValueOf(double d)
           
 void execute(org.xml.sax.ContentHandler sax, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.Object extContext)
          Execute this LSP page and sends the output as SAX2 events to the supplied ContentHandler.
protected static boolean fnContains(java.lang.String a, java.lang.String b)
           
protected static java.lang.String fnNormalizeSpace(java.lang.String a)
           
protected static double fnRound(double a)
           
protected static java.util.Collection<java.lang.Double> fnSeq(double start, double end, double step)
           
protected static java.lang.String fnSubstring(java.lang.String a, double bd)
           
protected static java.lang.String fnSubstring(java.lang.String a, double bd, double cd)
           
protected static java.lang.String fnSubstringAfter(java.lang.String a, java.lang.String b)
           
protected static java.lang.String fnSubstringBefore(java.lang.String a, java.lang.String b)
           
protected static java.lang.String fnTranslate(java.lang.String a, java.lang.String b, java.lang.String c)
           
 java.lang.String[] getCompileDependentFiles()
          Get a list of files which was imported with this page was compiled.
protected static java.lang.Object getElementFromTuple(java.util.Map<?,?> tuple, java.lang.String key)
           
protected static java.lang.Object getElementFromTupleAcceptNull(java.util.Map<?,?> tuple, java.lang.String key)
           
 java.util.Properties getOutputProperties()
          Output properties to use then this page is serialized.
 java.lang.String getPageName()
          Get the name of this page.
 long getTimeCompiled()
          When this page was compiled.
protected static java.lang.Object getVariableValue(nu.staldal.util.Environment<java.lang.String,java.lang.Object> env, java.lang.String varName)
           
protected static java.lang.Object getVariableValueAcceptNull(nu.staldal.util.Environment<java.lang.String,java.lang.Object> env, java.lang.String varName)
           
 boolean isCompileDynamic()
          Currently not used.
protected static LSPExtLib lookupExtensionHandler(java.util.Map<java.lang.String,LSPExtLib> extLibs, java.lang.String nsURI, java.lang.String className)
           
protected static void outputStringWithoutCR(org.xml.sax.ContentHandler sax, java.lang.String s, boolean disableOutputEscaping)
           
protected  void setOutputProperty(java.lang.String key, java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extLibsURLs

protected final java.lang.String[] extLibsURLs

extLibsClassNames

protected final java.lang.String[] extLibsClassNames

compileDependentFiles

protected final java.lang.String[] compileDependentFiles

compileDynamic

protected final boolean compileDynamic

timeCompiled

protected final long timeCompiled

pageName

protected final java.lang.String pageName

compiledVersionName

protected final java.lang.String compiledVersionName

compiledVersionNum

protected final int compiledVersionNum

outputProperties

protected final java.util.Properties outputProperties
Constructor Detail

LSPPageBase

protected LSPPageBase(java.lang.String[] extLibsURLs,
                      java.lang.String[] extLibsClassNames,
                      java.lang.String[] compileDependentFiles,
                      boolean compileDynamic,
                      long timeCompiled,
                      java.lang.String pageName,
                      java.lang.String versionName,
                      int versionNum)
Method Detail

setOutputProperty

protected final void setOutputProperty(java.lang.String key,
                                       java.lang.String value)

getCompileDependentFiles

public final java.lang.String[] getCompileDependentFiles()
Description copied from interface: LSPPage
Get a list of files which was imported with this page was compiled.

Specified by:
getCompileDependentFiles in interface LSPPage
Returns:
list of files which was imported with this page was compiled

isCompileDynamic

public final boolean isCompileDynamic()
Description copied from interface: LSPPage
Currently not used.

Specified by:
isCompileDynamic in interface LSPPage
Returns:
true if the page is compile dynamic

getTimeCompiled

public final long getTimeCompiled()
Description copied from interface: LSPPage
When this page was compiled.

Specified by:
getTimeCompiled in interface LSPPage
Returns:
when the page was compiled, in the same format as System.currentTimeMillis()

getPageName

public final java.lang.String getPageName()
Description copied from interface: LSPPage
Get the name of this page.

Specified by:
getPageName in interface LSPPage
Returns:
the name of this page.

getOutputProperties

public final java.util.Properties getOutputProperties()
Description copied from interface: LSPPage
Output properties to use then this page is serialized. From <lsp:output>.

Specified by:
getOutputProperties in interface LSPPage
Returns:
output properties to use then this page is serialized

execute

public final void execute(org.xml.sax.ContentHandler sax,
                          java.util.Map<java.lang.String,java.lang.Object> params,
                          java.lang.Object extContext)
                   throws org.xml.sax.SAXException
Description copied from interface: LSPPage
Execute this LSP page and sends the output as SAX2 events to the supplied ContentHandler. Does not output startDocument()/endDocument() events.

Specified by:
execute in interface LSPPage
Parameters:
sax - SAX2 ContentHandler to send output to
params - Parameters to the LSP page
extContext - external context which will be passed to ExtLibs
Throws:
org.xml.sax.SAXException - may throw SAXException

lookupExtensionHandler

protected static final LSPExtLib lookupExtensionHandler(java.util.Map<java.lang.String,LSPExtLib> extLibs,
                                                        java.lang.String nsURI,
                                                        java.lang.String className)
                                                 throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

convertObjectToLSP

protected static java.lang.Object convertObjectToLSP(java.lang.Object value)

convertToString

protected static java.lang.String convertToString(java.lang.Object _value)
                                           throws LSPException
Throws:
LSPException

convertToNumber

protected static double convertToNumber(java.lang.Object _value)
                                 throws LSPException
Throws:
LSPException

convertToBoolean

protected static boolean convertToBoolean(java.lang.Object _value)
                                   throws LSPException
Throws:
LSPException

convertToBooleanAcceptNull

protected static boolean convertToBooleanAcceptNull(java.lang.Object _value)
                                             throws LSPException
Throws:
LSPException

convertToList

protected static java.util.Collection<?> convertToList(java.lang.Object _value)
                                                throws LSPException
Throws:
LSPException

convertToTuple

protected static java.util.Map<?,?> convertToTuple(java.lang.Object _value)
                                            throws LSPException
Throws:
LSPException

outputStringWithoutCR

protected static void outputStringWithoutCR(org.xml.sax.ContentHandler sax,
                                            java.lang.String s,
                                            boolean disableOutputEscaping)
                                     throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

doubleValueOf

protected static java.lang.Double doubleValueOf(double d)

getElementFromTuple

protected static java.lang.Object getElementFromTuple(java.util.Map<?,?> tuple,
                                                      java.lang.String key)
                                               throws LSPException
Throws:
LSPException

getElementFromTupleAcceptNull

protected static java.lang.Object getElementFromTupleAcceptNull(java.util.Map<?,?> tuple,
                                                                java.lang.String key)

getVariableValue

protected static java.lang.Object getVariableValue(nu.staldal.util.Environment<java.lang.String,java.lang.Object> env,
                                                   java.lang.String varName)
                                            throws LSPException
Throws:
LSPException

getVariableValueAcceptNull

protected static java.lang.Object getVariableValueAcceptNull(nu.staldal.util.Environment<java.lang.String,java.lang.Object> env,
                                                             java.lang.String varName)

compareEqual

protected static boolean compareEqual(java.lang.Object left,
                                      java.lang.Object right)
                               throws LSPException
Throws:
LSPException

fnContains

protected static boolean fnContains(java.lang.String a,
                                    java.lang.String b)

fnSubstringBefore

protected static java.lang.String fnSubstringBefore(java.lang.String a,
                                                    java.lang.String b)

fnSubstringAfter

protected static java.lang.String fnSubstringAfter(java.lang.String a,
                                                   java.lang.String b)

fnSubstring

protected static java.lang.String fnSubstring(java.lang.String a,
                                              double bd)

fnSubstring

protected static java.lang.String fnSubstring(java.lang.String a,
                                              double bd,
                                              double cd)

fnNormalizeSpace

protected static java.lang.String fnNormalizeSpace(java.lang.String a)

fnTranslate

protected static java.lang.String fnTranslate(java.lang.String a,
                                              java.lang.String b,
                                              java.lang.String c)

fnRound

protected static double fnRound(double a)

fnSeq

protected static java.util.Collection<java.lang.Double> fnSeq(double start,
                                                              double end,
                                                              double step)

_execute

protected abstract void _execute(org.xml.sax.ContentHandler sax,
                                 nu.staldal.util.Environment<java.lang.String,java.lang.Object> env,
                                 java.util.Map<java.lang.String,LSPExtLib> extLibs,
                                 org.xml.sax.ContentHandler _sax,
                                 org.xml.sax.helpers.AttributesImpl attrs)
                          throws org.xml.sax.SAXException,
                                 java.lang.IllegalArgumentException
Throws:
org.xml.sax.SAXException
java.lang.IllegalArgumentException