Package org.eclipse.text.templates
Class TemplateReaderWriter
java.lang.Object
org.eclipse.text.templates.TemplateReaderWriter
- Direct Known Subclasses:
TemplateReaderWriter
Serializes templates as character or byte stream and reads the same format
back.
Clients may instantiate this class, it is not intended to be subclassed.
- Since:
- 3.7
- Restriction:
- This class is not intended to be subclassed by clients.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionread
(InputStream stream, ResourceBundle bundle) Reads templates from a stream and adds them to the templates.Reads templates from a reader and returns them.read
(Reader reader, ResourceBundle bundle) Reads templates from a stream and adds them to the templates.readSingle
(Reader reader, String id) Reads the template with identifierid
from a reader and returns it.void
save
(TemplatePersistenceData[] templates, OutputStream stream) Saves the templates as XML, encoded as UTF-8 onto the given byte stream.void
save
(TemplatePersistenceData[] templates, Writer writer) Saves the templates as XML.
-
Constructor Details
-
TemplateReaderWriter
public TemplateReaderWriter()Create a new instance.
-
-
Method Details
-
read
Reads templates from a reader and returns them. The reader must present a serialized form as produced by thesave
method.- Parameters:
reader
- the reader to read templates from- Returns:
- the read templates, encapsulated in instances of
TemplatePersistenceData
- Throws:
IOException
- if reading from the stream fails
-
readSingle
Reads the template with identifierid
from a reader and returns it. The reader must present a serialized form as produced by thesave
method.- Parameters:
reader
- the reader to read templates fromid
- the id of the template to return- Returns:
- the read template, encapsulated in an instances of
TemplatePersistenceData
- Throws:
IOException
- if reading from the stream fails- Since:
- 3.1
-
read
Reads templates from a stream and adds them to the templates.- Parameters:
reader
- the reader to read templates frombundle
- a resource bundle to use for translating the read templates, ornull
if no translation should occur- Returns:
- the read templates, encapsulated in instances of
TemplatePersistenceData
- Throws:
IOException
- if reading from the stream fails
-
read
Reads templates from a stream and adds them to the templates.- Parameters:
stream
- the byte stream to read templates frombundle
- a resource bundle to use for translating the read templates, ornull
if no translation should occur- Returns:
- the read templates, encapsulated in instances of
TemplatePersistenceData
- Throws:
IOException
- if reading from the stream fails
-
save
Saves the templates as XML, encoded as UTF-8 onto the given byte stream.- Parameters:
templates
- the templates to savestream
- the byte output to write the templates to in XML- Throws:
IOException
- if writing the templates fails
-
save
Saves the templates as XML.- Parameters:
templates
- the templates to savewriter
- the writer to write the templates to in XML- Throws:
IOException
- if writing the templates fails
-