Package org.apache.openjpa.lib.util
Class ParameterTemplate
- java.lang.Object
-
- org.apache.openjpa.lib.util.ParameterTemplate
-
public class ParameterTemplate extends java.lang.Object
A template that allows parameter substitutions. Parameters should be placed in the template in the form ${param-name}. Use thesetParameter(java.lang.String, java.lang.Object)
method to set the parameter values, which will be substituted into the template on calls towrite(java.io.OutputStream)
andtoString()
. If a parameter is encountered that hasn't been set, then the parameter key is used to lookup the corresponding System property.- Author:
- Abe White
-
-
Constructor Summary
Constructors Constructor Description ParameterTemplate()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ParameterTemplate
append(boolean value)
Add the given value to the internal template.ParameterTemplate
append(char value)
Add the given value to the internal template.ParameterTemplate
append(double value)
Add the given value to the internal template.ParameterTemplate
append(float value)
Add the given value to the internal template.ParameterTemplate
append(int value)
Add the given value to the internal template.ParameterTemplate
append(long value)
Add the given value to the internal template.ParameterTemplate
append(short value)
Add the given value to the internal template.ParameterTemplate
append(java.io.File file)
Add the given value to the internal template.ParameterTemplate
append(java.io.InputStream in)
Add the given value to the internal template.ParameterTemplate
append(java.io.Reader reader)
Add the given value to the internal template.ParameterTemplate
append(java.lang.Object value)
Add the given value to the internal template.ParameterTemplate
append(java.lang.String value)
Add the given value to the internal template.void
clearParameters()
Clear the recorded parameter values.java.lang.Object
getParameter(java.lang.String name)
Return the value set for the given parameter.boolean
hasParameter(java.lang.String name)
Return true if the given parameter has been given a value.java.lang.Object
setParameter(java.lang.String name, java.lang.Object val)
Set the value for the given parameter.void
setParameters(java.util.Map params)
Set the values for all the parameters in the given map.java.lang.String
toString()
Return a copy of the internal value template with all parameters substituted with their current values.void
write(java.io.File file)
Write the internal value template with all parameters substituted with their current values.void
write(java.io.OutputStream out)
Write the internal value template with all parameters substituted with their current values.void
write(java.io.Writer writer)
Write the internal value template with all parameters substituted with their current values.
-
-
-
Method Detail
-
append
public ParameterTemplate append(java.lang.String value)
Add the given value to the internal template.
-
append
public ParameterTemplate append(boolean value)
Add the given value to the internal template.
-
append
public ParameterTemplate append(char value)
Add the given value to the internal template.
-
append
public ParameterTemplate append(double value)
Add the given value to the internal template.
-
append
public ParameterTemplate append(float value)
Add the given value to the internal template.
-
append
public ParameterTemplate append(int value)
Add the given value to the internal template.
-
append
public ParameterTemplate append(long value)
Add the given value to the internal template.
-
append
public ParameterTemplate append(short value)
Add the given value to the internal template.
-
append
public ParameterTemplate append(java.lang.Object value)
Add the given value to the internal template.
-
append
public ParameterTemplate append(java.io.InputStream in) throws java.io.IOException
Add the given value to the internal template.- Throws:
java.io.IOException
-
append
public ParameterTemplate append(java.io.Reader reader) throws java.io.IOException
Add the given value to the internal template.- Throws:
java.io.IOException
-
append
public ParameterTemplate append(java.io.File file) throws java.io.IOException
Add the given value to the internal template.- Throws:
java.io.IOException
-
hasParameter
public boolean hasParameter(java.lang.String name)
Return true if the given parameter has been given a value.
-
getParameter
public java.lang.Object getParameter(java.lang.String name)
Return the value set for the given parameter.
-
setParameter
public java.lang.Object setParameter(java.lang.String name, java.lang.Object val)
Set the value for the given parameter.
-
setParameters
public void setParameters(java.util.Map params)
Set the values for all the parameters in the given map.
-
clearParameters
public void clearParameters()
Clear the recorded parameter values.
-
toString
public java.lang.String toString()
Return a copy of the internal value template with all parameters substituted with their current values.- Overrides:
toString
in classjava.lang.Object
-
write
public void write(java.io.OutputStream out) throws java.io.IOException
Write the internal value template with all parameters substituted with their current values.- Throws:
java.io.IOException
-
write
public void write(java.io.Writer writer) throws java.io.IOException
Write the internal value template with all parameters substituted with their current values.- Throws:
java.io.IOException
-
write
public void write(java.io.File file) throws java.io.IOException
Write the internal value template with all parameters substituted with their current values.- Throws:
java.io.IOException
-
-