I'm currently writing a client-server application to allow the client to request data from the server. I'm looking at writing this entirely in native java, and i'm using text and property files to do the bulk of my storage.
However, I've hit a brick wall trying to find a good way to store the following:
ID Language from Language to Cost/100w Comment
7101 English Mandarin $5.00 Outsource
Now you may be thinking, why doesn't he just use an arraylist, or just store the data in another text file? I've considered these options and I see downfalls with each.
With an arraylist to my knowledge I cannot store integers, and I'd like to query the data with the following command:
What is the cost of <ID> translation of <integer> words?
As you can see i'll require the cost to be stored as an integer so I can use it for sums.
With text files I only know how to store the data on a single line, for example:
7101 English Mandarin $5.00 Outsource
7102 Greek Russian $12.00 -
etc. etc. etc. etc. etc
So I don't know how I could query the data.
Once again, I do not want to end up storing this with MySQL and having to use the JDBC driver, I want the entire application to run in native java.
You can also use XML files to structure your data properly. When it comes to querying your data, you can make use of XPath.
XML will give you the chance to allow for multiple data formats, including numbers and all.
For example:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<row id="7101">
<language-from>English</language-from>
<language-to>Mandarin</language-to>
<cost>5.00</cost>
<comment><![CDATA[Some comment]]></comment>
</row>
</data>
To query the data using XPath: What is the cost of translation of words?
/data/row[@id=7101]/cost/number()
Then use the result to divide by 100 for the price of a word.
Manipulating XML should be a walk in the park with a library such as JDOM2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With