A lightweight embedded no-sql document database, representing documents as XML in flat .XML files.
OTHER License
A lightweight embedded no-sql object DB persisting objects to flat XML files. XFlat is a completely free alternative to db4o for an embedded object DB.
So you've got a Java application, and need to persist some data. Cool. Just write it to a file.
Well, my data's in a bunch of POJOs.
Ok that's easy, just serialize it to XML and drop it into a DOM, then write it to a file.
Alright, that sounds easy enough. But wait a second, I need random access to my saved POJOs.
Well thats a bit harder, but you could write a class to inspect the DOM and pull out the data you need.
But I also need to query my POJOs by arbitrary criteria.
Looks like you need a database. Take a look at db4o or Sql Lite
Well I'd prefer not to have to deal with Sql, and I may need to inspect or transform my data as XML.
Oh, well in that case XFlat is for you!
XFlat is a single lightweight JAR that persists XML DOM Elements to flat files. It presents as a CRUD interface to XML Elements that can be queried by ID or arbitrary XPath expressions. Because it is stored in flat files, XFlat is not relational and is schemaless. XFlat is currently effective for table sizes up to the dozens of KB. Future versions will contain engines that are effective up to the hundreds of MB, using memory-mapped files.
Pure XML data files
POJO mapping to XML
Element
objects using JAXB. The underlying implementation can be swapped if necessary.Queriable by XPath expressions
Element
that is convertible to the value which is being matched, then the matching is performedMultiple swappable Engines (to be implemented)
Indexing on XPath expressions (to be implemented)
Element
that is converted to a Comparable
(such as an Integer), then the engine can map that Comparable
Sharding by ID (implemented) or on arbitrary XPath expressions (to be implemented)
Element
that is converted to a Comparable
, then a RangeProvider
determines which file to storeTransactions
====
Required dependencies:
Java 7
JDOM 2
Hamcrest matchers 1.3
Apache Commons Logging 1.1
Optional dependencies:
Jaxen-1.1.4 - for compiling XPath strings into expressions
JAXB reference implementation 1.0 - for automatic POJO mapping
====
Insert an instance of Foo
into the table "Foo" stored in "myDataDirectory/Foo.xml".
XFlatDatabase db = new XFlatDatabase(new File("myDataDirectory"));
//initialize with default config
db.initialize();
Foo myFoo = new Foo();
Table<Foo> fooTable = db.getTable(Foo.class);
fooTable.insert(myFoo); //inserts with unique automatically-generated ID
System.out.println("Stored foo in table Foo with ID " + myFoo.getId());
Foo myFoo2 = fooTable.find(myFoo.getId());
//myFoo2 is a new instance with the same data as myFoo
See "Examples.md" for more examples