Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


org.eclipse.jet
Class JET2Context

java.lang.Object
  extended by 
org.eclipse.jet.JET2Context

public final class JET2Context
extends java.lang.Object

Define the execution context for a JET2 transform or template.


Nested Class Summary
static interface JET2Context.LogListener
          Protocol for a listener to the JET2Context log.
 
Constructor Summary
JET2Context (java.lang.Object source)
          Create a JET2 context with the specified source argument and no variables.
JET2Context (java.lang.Object source, java.util.Map variables)
          Create a JET2 context with the specified source argument and the specified variables.
 
Method Summary
 void addLogListener ( JET2Context.LogListener listener)
          Add a listener to context logging entries.
 void addPrivateData (java.lang.String key, java.lang.Object value)
          Add private data to the context.
 java.lang.String embeddedExpressionAsString (java.lang.String expression, int line, int col)
          Evaluate the embedded expression found at the given line and column and return the expression result as a string.
 java.util.Map extractVariables (java.lang.String variableNames)
          Extract a list of variables from the context
  EmbeddedExpressionFactory getExpressionFactory ()
          Return the expression factory for parsing embedded expressions withing strings.
 java.lang.String getJETBundleId ()
          Return the id of the JET Bundle defining the current template.
  ContextLogEntry getLogEntries ()
           
 java.lang.Object getPrivateData (java.lang.String key)
          Return private data associated with the key.
 java.lang.Object getSource ()
          Return the source object for the transformation.
  TagFactory getTagFactory ()
           
 java.lang.String getTemplatePath ()
          Return the path for the executing template.
 java.lang.Object getVariable (java.lang.String var)
          Return the value of a context variable
 java.util.Map getVariables ()
          Return a map of all variables currently defined in the context.
 boolean hasContextExtender (java.lang.Class extenderClass)
          Test whether the context has an extender of the pass class.
 boolean hasVariable (java.lang.String var)
          Test whether a variable is defined
 void logError (java.lang.String message)
          Log an error message
 void logError (java.lang.String templatePath, TagInfo tagInfo, java.lang.String message, java.lang.Throwable e)
          Log an error on the pass template
 void logError (java.lang.String message, java.lang.Throwable e)
          Deprecated. Please don't use, will be removed...
 void logError ( TagInfo tagInfo, java.lang.String message, java.lang.Throwable exception)
          Log an error from the specified tag.
 void logError (java.lang.Throwable e)
          Log an exeception that occurred during execution
 void logInfo (java.lang.String message)
          Log an informational message
 void logWarning (java.lang.String message)
          Log a warning message
 void removeLogListener ( JET2Context.LogListener listener)
          Remove a previously registerd listener from the context log.
 void removePrivateData (java.lang.String key)
          Remove private data associated with the key.
 void removeVariable (java.lang.String var)
          Remove a variable
 void restoreVariables (java.util.Map savedVariableValues)
          Restore variables in the passed map to the context.
 void setJETBundleId (java.lang.String jetBundleId)
          Set the id of the JET Bundle defining the current template.
 void setSource (java.lang.Object source)
          Set the source object for the transformation
 void setTagFactory ( TagFactory tagFactory)
           
 void setTemplatePath (java.lang.String templatePath)
          Set the templatePath.
 void setVariable (java.lang.String var, java.lang.Object value)
          Assigne or create a variable, and set its value.
 void setVariables (java.util.Map variablesToPass)
          Set the context variables to only the variables in variablesToPass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JET2Context

public JET2Context(java.lang.Object source,
                   java.util.Map variables)
Create a JET2 context with the specified source argument and the specified variables.

Parameters:
source - the source object
variables - A map of variable names to the object values.

JET2Context

public JET2Context(java.lang.Object source)
Create a JET2 context with the specified source argument and no variables.

This is exactly equivalent to:

 JET2Context(source, Collections.EMPTY_MAP)
 

Parameters:
source - the source object
Method Detail

setSource

public void setSource(java.lang.Object source)
Set the source object for the transformation

Parameters:
source -

getSource

public java.lang.Object getSource()
Return the source object for the transformation.

Returns:
the source object

addLogListener

public void addLogListener(
JET2Context.LogListener listener)
Add a listener to context logging entries. Adding the same listener more than once has no effect.

Parameters:
listener - a log listener

removeLogListener

public void removeLogListener(
JET2Context.LogListener listener)
Remove a previously registerd listener from the context log. Attempting to remove an listener not previously registered with addLogListener(org.eclipse.jet.JET2Context.LogListener) has no effect.

Parameters:
listener - a log listener

getJETBundleId

public java.lang.String getJETBundleId()
Return the id of the JET Bundle defining the current template. Used in generating error messages.

Returns:
the JET Bundle id, or null if not defined.
See Also:
setJETBundleId(String)

setJETBundleId

public void setJETBundleId(java.lang.String jetBundleId)
Set the id of the JET Bundle defining the current template. Used in generating error messages. If not set, then the ID of the JET plugin is used.

Parameters:
jetBundleId - the JET Bundle ide.

logInfo

public void logInfo(java.lang.String message)
Log an informational message

Parameters:
message -

getTemplatePath

public java.lang.String getTemplatePath()
Return the path for the executing template. This is used in creating error messages.

Returns:
the template path or null if no templatePath is defined.
See Also:
setTemplatePath(String)

setTemplatePath

public void setTemplatePath(java.lang.String templatePath)
Set the templatePath. The templatePath is used in generating error messages.

Parameters:
templatePath - the template path or null to indicate no executing template.

logWarning

public void logWarning(java.lang.String message)
Log a warning message

Parameters:
message -

logError

public void logError(java.lang.String message)
Log an error message

Parameters:
message -

logError

public void logError(java.lang.Throwable e)
Log an exeception that occurred during execution

Parameters:
e -

logError

public void logError(java.lang.String message,
                     java.lang.Throwable e)
Deprecated. Please don't use, will be removed...

Log an exception that occured during execution, along with a message.

Parameters:
message -
e -

getLogEntries

public 
ContextLogEntry getLogEntries()

logError

public void logError(
TagInfo tagInfo,
                     java.lang.String message,
                     java.lang.Throwable exception)
Log an error from the specified tag.

Parameters:
tagInfo -
message - the error message to display, or null
exception -

hasContextExtender

public boolean hasContextExtender(java.lang.Class extenderClass)
Test whether the context has an extender of the pass class.

Parameters:
extenderClass - the extender class
Returns:
true if the context has a registered extender of the passed class.

getPrivateData

public java.lang.Object getPrivateData(java.lang.String key)
Return private data associated with the key.

Parameters:
key - a private data key.
Returns:
the private data or null if not data is associate with the key.
Since:
0.9.0

addPrivateData

public void addPrivateData(java.lang.String key,
                           java.lang.Object value)
Add private data to the context.

Parameters:
key - the key for the private data
value - the data value
Throws:
java.lang.IllegalStateException - if key has already been used to add private data.
java.lang.NullPointerException - if value or key is null.
See Also:
getPrivateData(String)

removePrivateData

public void removePrivateData(java.lang.String key)
Remove private data associated with the key. Quietly succeeds there is no private data for the key.

Parameters:
key - the key for the private data

logError

public void logError(java.lang.String templatePath,
                     
TagInfo tagInfo,
                     java.lang.String message,
                     java.lang.Throwable e)
Log an error on the pass template

Parameters:
templatePath -
tagInfo -
message -
e -

setVariable

public void setVariable(java.lang.String var,
                        java.lang.Object value)
                 throws 
JET2TagException
Assigne or create a variable, and set its value.

Parameters:
var - the variable name. Cannot be null.
value - the variable value.
Throws:
JET2TagException

getVariable

public java.lang.Object getVariable(java.lang.String var)
                             throws 
JET2TagException
Return the value of a context variable

Parameters:
var - the variable name
Returns:
the value of the variable
Throws:
JET2TagException - if the variable does not exist.

getVariables

public java.util.Map getVariables()
Return a map of all variables currently defined in the context. The map is a copy of the variables maintained by the context; changes to the map have no affect on the context.

Returns:
a Map of variables, where the key is a variable name, and the value is the variable value.

removeVariable

public void removeVariable(java.lang.String var)
                    throws 
JET2TagException
Remove a variable

Parameters:
var - the variable name
Throws:
JET2TagException

hasVariable

public boolean hasVariable(java.lang.String var)
Test whether a variable is defined

Parameters:
var - the variable name
Returns:
true if defined, false otherwise.

getTagFactory

public final 
TagFactory getTagFactory()
Returns:
the tagFactory

setTagFactory

public final void setTagFactory(
TagFactory tagFactory)
Parameters:
tagFactory - the tagFactory to set

extractVariables

public java.util.Map extractVariables(java.lang.String variableNames)
                               throws 
JET2TagException
Extract a list of variables from the context

Parameters:
variableNames - a comma separated list of variables. May be null.
Returns:
a Map keyed by variable name. Will be null if variableNames is null.
Throws:
JET2TagException - if variableNames contains an invalid variable name.

restoreVariables

public void restoreVariables(java.util.Map savedVariableValues)
                      throws 
JET2TagException
Restore variables in the passed map to the context.

Parameters:
savedVariableValues - a Map keyed by variable name. If null the method does nothing.
Throws:
JET2TagException - if a variable name is invalid

setVariables

public void setVariables(java.util.Map variablesToPass)
                  throws 
JET2TagException
Set the context variables to only the variables in variablesToPass

Parameters:
variablesToPass - a non-null map keyed by variable name.
Throws:
JET2TagException - if a variable name is invalid

embeddedExpressionAsString

public java.lang.String embeddedExpressionAsString(java.lang.String expression,
                                                   int line,
                                                   int col)
Evaluate the embedded expression found at the given line and column and return the expression result as a string. Should an error occur during evaluation, an appropriate error is logged in the context's log.

Parameters:
expression - the embedded expression, including the initial ${ and } characters
line - the template line at which the expression starts
col - the template column at which the expresison starts
Returns:
the expression result

getExpressionFactory

public final 
EmbeddedExpressionFactory getExpressionFactory()
Return the expression factory for parsing embedded expressions withing strings.

Returns:
the expressionFactory

Copyright 2006 IBM Corporation and others.
All Rights Reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire