bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnubg] Slightly OT: Java library to read XG/XGP file format


From: Michael Petch
Subject: [Bug-gnubg] Slightly OT: Java library to read XG/XGP file format
Date: Thu, 15 Jan 2015 18:12:48 -0700
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

Howdy All,

About a year ago I produced some code for Python that reads XG file
formats and dumps it out to the console. I never got back to finishing
that Python code to produce a proper module that can be easily used by
other applications. I intend to do that sometime this year and possibly
use that Python code to read XG files into GNUbg. We already use Python
and most builds come with it enabled - rather than rewrite in in C it
might be more convenient to reuse code I have.

I've also moved to a more liberal LGPL license for the Python code (and
new Java library which I will mention below). This would allow people to
integrate it into proprietary software without having to make the source
of the program linking to that library available. Of course if you
modify the the code of the library itself then those changes have to be
made available.

In the middle of last year I was approached by a couple individuals (not
by Frank Berger) with a keen interest in something that reads XG file
formats in Java. I created an initial version a number of months ago but
it wasn't until Christmas where I had someone who did significant
testing (Thanks Victor Kudryashov).

The library is very basic. The initial release only supports reading XG
file format (Both XG and XGP files). It doesn't compute PRs, or generate
XGID's etc. It simply makes available all the information for others to
do more powerful things. If people wish to share code that builds on the
basics I would be more than willing to integrate them.

The git repository can be cloned with:

git clone git://vcs.capp-sysware.com/backgammon/xgdatatoolsjava.git

You can download the latest 0.1.2 packaged version (I use Maven) from here:

http://www.capp-sysware.com/downloads/misc/xgdatatools-0.1.2-SNAPSHOT-jar-with-dependencies.jar
http://www.capp-sysware.com/downloads/misc/xgdatatools-0.1.2-SNAPSHOT.jar

Basic documentation (and class hierarchy) can be found here:
http://docs.capp-sysware.com/projects/java/xgdatatools/0.1.0/

I have a dependency on Apache Common Langs, and this code work Java 1.6+
. The Langs dependency is only to support much better console output
when trying to get a text representation of what is in an XG/XGP file.
This isn't a necessity and some may wish to alter the code to use Java's
own StringBuilder class. This is a trivial change for those who want to
drop the dependency. The two Jar files are the same except one includes
the Java Common Langs classes.

The default main class can be used to dump an XG files contents to the
console with something like:

java -jar xgdatatools-0.1.2-SNAPSHOT-jar-with-dependencies.jar nameoffile.xg

It lacks help for each individual field but the names are pretty similar
to the information published by Xavier here:

http://www.extremegammon.com/xgformat.aspx

There is a sample program in the source tree that shows you how you can
manipulate the objects. See sample1.java .

The code is lacking a proper visitor pattern (which I am working on) so
for the time being you use instanceof to figure out what type of objects
are returned.

I do have a rudimentary version that does write support but it has some
bugs that need to be worked out and it is a low priority so probably
won't be finishing that until later in the year. Similar thing with
improving the basic class documentation.

If someone finds bug or has questions I can be reached at
address@hidden .

-- 
Michael Petch
CApp::Sysware Consulting Ltd.
OpenPGP FingerPrint=D81C 6A0D 987E 7DA5 3219 6715 466A 2ACE 5CAE 3304



reply via email to

[Prev in Thread] Current Thread [Next in Thread]