|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.sillyview.VelocityModel
Creates a WidgetModel backed by a Velocity Template.
Field Summary | |
---|---|
private static Category |
cat
|
protected VelocityContext |
context
The VelocityContext to which tokens are delegated. |
protected java.lang.String |
template
The raw velocity template. |
Fields inherited from interface net.sourceforge.sillyview.WidgetModel |
---|
FALSE, TRUE |
Constructor Summary | |
---|---|
VelocityModel(java.lang.String templateString)
Creates a new VelocityModel instance with the
given String as its template. |
|
VelocityModel(java.net.URL templateURL)
Initializes Velocity, creates a new context, and sets this model's template to the file at the given URL. |
|
VelocityModel(VelocityContext context,
java.net.URL templateURL)
Allows several models to share a context. |
Method Summary | |
---|---|
java.lang.Object |
getCurrentModel()
Returns the current model as a String. |
static VelocityModel |
getModel(java.lang.String url)
Static factory method for creating a VelocityModel with the raw velocity template at the given URL. |
java.lang.Object |
getRawModel()
Returns the template without applying existing token values. |
private java.lang.String |
getTemplate(java.net.URL templateURL)
|
java.lang.Object |
getValue(java.lang.Object key)
Returns the value of the named token, taking it from the VelocityContext. |
private void |
init()
Initializes velocity and creates a new context. |
void |
setRawModel(java.lang.Object newTemplate)
Updates the template without modifying the current tokens. |
void |
setToken(java.lang.Object key,
java.lang.Object value)
Sets the named token, delegating it to the VelocityContext. |
java.lang.String |
toString()
Uses Velocity.evaluate() to merge the current token values with the template string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static Category cat
protected VelocityContext context
protected java.lang.String template
Constructor Detail |
---|
public VelocityModel(java.net.URL templateURL) throws java.io.IOException, java.lang.Exception
templateURL
- an URL
value
java.io.IOException
- if an error occurs
java.lang.Exception
- if an error occurspublic VelocityModel(VelocityContext context, java.net.URL templateURL) throws java.io.IOException, java.lang.Exception
context
- a VelocityContext
valuetemplateURL
- an URL
value
java.io.IOException
- if an error occurs
java.lang.Exception
- if an error occurspublic VelocityModel(java.lang.String templateString) throws java.lang.Exception
VelocityModel
instance with the
given String as its template.
templateString
- a String
value
java.lang.Exception
- if an error occursMethod Detail |
---|
private void init() throws java.lang.Exception
java.lang.Exception
private java.lang.String getTemplate(java.net.URL templateURL) throws java.io.IOException, java.lang.Exception
java.io.IOException
java.lang.Exception
public java.lang.Object getCurrentModel()
getCurrentModel
in interface WidgetModel
Object
valuepublic java.lang.Object getRawModel()
getRawModel
in interface WidgetModel
Object
valuepublic void setRawModel(java.lang.Object newTemplate)
newTemplate
- an Object
valuepublic java.lang.String toString()
toString
in interface WidgetModel
toString
in class java.lang.Object
String
valuepublic void setToken(java.lang.Object key, java.lang.Object value)
setToken
in interface WidgetModel
key
- an Object
valuevalue
- an Object
valuepublic java.lang.Object getValue(java.lang.Object key)
getValue
in interface WidgetModel
key
- an Object
value
Object
valuepublic static VelocityModel getModel(java.lang.String url)
url
- a String
value
VelocityModel
value
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |