|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface GeneratedCode
Describes the evaluation output of a text template. The output of a text template has the following properties :
null most of time).A generated code is created when a text template is evaluated,
and its contents can be persistent using the write() method.
This interface is not intended to be implemented by clients.
EvaluationContext.generate(String, List)| Method Summary | |
|---|---|
void |
addEndProtectedSection(String endTag)
Ends a protected section. |
void |
addProtectedSection(String startTag,
String endTag)
Adds a protected section. |
void |
addProtectedSections(Collection<ProtectedSection> sections)
Adds each protected section of the collection. |
void |
addStartProtectedSection(String startTag)
Starts a protected section. |
void |
discard()
Notifies this generated code it must be discarded. |
String |
getContents()
Returns the contents generated by the text template. |
InputSource |
getContentSource()
Returns the contents generated by the text template. |
String |
getEncoding()
Returns the encoding to use when writing the generated contents. |
File |
getFile()
Returns the file path specified in the text template. |
List<ProtectedSection> |
getProtectedSections()
Returns the list of protected sections, which define regions in a file that can contain end-user manual code and that the generator must never overwrite. |
boolean |
isDiscarded()
Returns true if this generated code is discarded and must not be written. |
void |
setContents(InputSourceProvider contentsProvider)
Sets the generated contents. |
void |
setContents(String contents)
Sets the generated contents. |
void |
setEncoding(String encoding)
Sets the encoding to use when writing the generated contents. |
void |
setFile(File file)
Sets the file, which may be relative, where the generated contents should be written out. |
void |
write()
Writes this generated contents into the underlying file on disk. |
| Method Detail |
|---|
File getFile()
null if no the text template has no file property.
null).void setFile(File file)
file - the file where to write the generated contents.String getEncoding()
null, which is the general case,
the platform default encoding is used. The encoding can be used for example
when generating XML files, since it must match the declaration of the XML header (UTF-8 for example).
null if no encoding specified.void setEncoding(String encoding)
null, which is the general case,
the platform default encoding is used. The encoding can be used for example
when generating XML files, since it must match the declaration of the XML header (UTF-8 for example).
encoding - the encoding to use, null to use the platform default encoding.String getContents()
null if not specified.void setContents(String contents)
contents - the contents generated by the text template.
InputSource getContentSource()
throws IOException
null if not specified.
IOExceptionvoid setContents(InputSourceProvider contentsProvider)
contentsProvider - the contents generated by the text template.
void addProtectedSection(String startTag,
String endTag)
startTag - the start delimiter.endTag - the end delimiter.void addStartProtectedSection(String startTag)
startTag - the start delimiter.addEndProtectedSection(String)void addEndProtectedSection(String endTag)
endTag - the start delimiter.addStartProtectedSection(String)void addProtectedSections(Collection<ProtectedSection> sections)
sections - a collection of ProtectedSection elements.List<ProtectedSection> getProtectedSections()
ProtectedSection elements, ordered the way they were added.
void write()
throws EvaluationException
Writing a generated code consists of the following steps :
Note : template and script designers should generally not have to consider this method.
The EvaluationContext.generate(String, List) method evaluates the template and write it automaticaly on disk.
This method is only to be used if the template has been evaluated with the EvaluationContext.createGeneratedCode(String, List) method.
EvaluationException - if the generated contents could not be written on disk. Reasons include :
EvaluationContext.generate(String, List),
EvaluationConfiguration.getEvaluationDirectory(),
EvaluationConfiguration.isFileOverwriteForced()boolean isDiscarded()
true if this generated code is discarded and must not be written.
A generated code is discarded when the related text template guard failed.
Any attempt to write a discarded generated code would fail.
true if the generated code is discarded, false otherwise.void discard()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||