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