properties-reader
JavaCC grammar and kit to generate SAX events describing a java properties file, and an XSL transform to regenerate the original file.
Java 1.5+
Following, and extending, on the decomposition of Java properties text specified by Apache PropertiesConfiguration, this kit attempts to provide 100% round trip fidelity between Java properties text and a simple XML form (extending the Java properties XML specification) via a simple object model (PxrProperties).
The XML form is further extended to support insert, update and delete actions on all parts of a properties text.
Summary operations are provided in:
JavaCC grammar
A JavaCC grammar generates the PxrParser which parses PxrProperties objects from properties text:
PxrReader
A PxrReader emits SAX events from a PxrProperties object.
For example, given the following properties text:
#sample header
color=red
#the size is large
size=large
#sample footer
when the properties text is parsed the SAX events will be:
<properties>
<comment key="_header">
<![CDATA[#sample header]]>
</comment>
<comment key="color"/>
<entry key="color" index="1">red</entry>
<comment key="size" lines-before="1">
<![CDATA[#the size is large]]>
</comment>
<entry key="size" index="2">large</entry>
<comment key="_footer" lines-before="1" eol="0">
<![CDATA[#sample footer]]>
</comment>
</properties>
PxrWriter
A PxrWriter handles SAX events to create or update a PxrProperties object.
For example, given the properties text:
color=red
size=large
when the following SAX events are handled:
<update>
<entry key='color'>
<text>blue, </text>
<text prefix=' ' >red</text>
</entry>
</update>
Then the properties text will be:
color=blue, \
red
size=large
XSL Transform
An XSL transform re-constitutes properties text from SAX events: