Class XMLTemplate
java.lang.Object
net.sf.basedb.clients.web.plugins.XMLTemplate
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ExportTemplate
A XML template that exports data in a simple one-level XML format.
- Version:
- 2.2
- Author:
- nicklas
- Last modified
- $Date: 2019-03-12 10:56:19 +0100 (tis, 12 mars 2019) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Writer
private Element
private final String
private final Item
private static final Pattern
private final List<ExportedProperty>
private final XMLOutputter
-
Constructor Summary
ConstructorDescriptionXMLTemplate
(Writer exportStream, List<ExportedProperty> properties, Item itemType) Create a new template. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Write XML start (<?void
beginItem
(int id) Begin a new item element.void
close()
Do nothing.void
endDocument
(ProgressReporter progress) Close the document tags.void
endItem()
Write the current item element to the export stream.private String
Get the default file extension to give to files generated by this template.Get the MIME type to assign to files generated by this template.void
writeAnnotations
(ExportedProperty ep, List<?> values, String unit) Add annotation values to the current item element.void
writeCollection
(ExportedProperty ep, Collection<?> values) Add collection values to the current item element.void
Write property and annotation definitions.void
writeProperty
(ExportedProperty ep, Object data) Add the property value to the current item element.
-
Field Details
-
xmlOut
-
exportStream
-
properties
-
itemType
-
itemIdPrefix
-
itemElement
-
NEWLINE
-
-
Constructor Details
-
XMLTemplate
Create a new template.- Parameters:
exportStream
- The stream to write toproperties
- All exported propertiesitemType
- The type of items we are exporting
-
-
Method Details
-
getMimeType
Description copied from interface:ExportTemplate
Get the MIME type to assign to files generated by this template.- Specified by:
getMimeType
in interfaceExportTemplate
- Returns:
- application/xml
-
getDefaultFileExtension
Description copied from interface:ExportTemplate
Get the default file extension to give to files generated by this template.- Specified by:
getDefaultFileExtension
in interfaceExportTemplate
- Returns:
- Always "xml"
- Since:
- 3.0
-
beginDocument
Write XML start (<?xml ...>) tag and DOCTYPE.- Specified by:
beginDocument
in interfaceExportTemplate
- Throws:
IOException
- If there is an error
-
writeHeaders
Write property and annotation definitions.- Specified by:
writeHeaders
in interfaceExportTemplate
- Throws:
IOException
- If there is an error
-
beginItem
Begin a new item element.- Specified by:
beginItem
in interfaceExportTemplate
- Parameters:
id
- Id of the new item.- Throws:
IOException
- If there is an error
-
writeAnnotations
Add annotation values to the current item element.- Specified by:
writeAnnotations
in interfaceExportTemplate
- Parameters:
ep
- Exported property the annotations belongs tovalues
- Annotation values to be written.unit
- The unit of the annotation values, or null to not display write a unit- Throws:
IOException
- If there is an error
-
writeProperty
Add the property value to the current item element.- Specified by:
writeProperty
in interfaceExportTemplate
- Parameters:
ep
- The exported property thedata
belongs to.data
- Data to be written.- Since:
- 2.12
-
writeCollection
Add collection values to the current item element.- Specified by:
writeCollection
in interfaceExportTemplate
- Parameters:
ep
- Exported property the values belong tovalues
- The values to be written- Throws:
IOException
-
endItem
Write the current item element to the export stream.- Specified by:
endItem
in interfaceExportTemplate
- Throws:
IOException
- If there is an error
-
endDocument
Close the document tags.- Specified by:
endDocument
in interfaceExportTemplate
- Throws:
IOException
- If there is an error
-
close
Do nothing.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
escape
-