Search code examples
javaparsinglegacy

Library for parsing proprietary settings files


Is there any free library that I may leverage for parsing a unique settings file described like so (taken from actual file). Perhaps something like ini4j (perhaps ini4j is customizeable enough that I could use it maybe?). Just checking before I start slogging away at writing my own :(

/*** This file specifies settings used by the __. Each
/*** line is delimited by colons. This file contains global as well as
/*** program specific settings.  First part is always the variable name.
/*** Second part can be a single or a wildcarded program id, in which
/*** case the setting will be program specific. In the case of global
/*** variables, the second part will be the actual setting. The third
/*** and subsequent parts will only appear for program specific variables
/*** and will be the settings for those variables.  Any comments at the
/*** end of the line have to be preceded by a colon, in order to separate
/*** it from the rest of the line.

The body of my files look like this (just an example):

DELIMITER=;
FROM_DIR;msc*;/usr/foo/bar
FROM_DIR;msd*;/usr/foo/bar
LOG_DIR;ms*;/usr/foo/logs
DUMP_FLAG;N
MAX_JOBS;8

Solution

  • This property file format looks sufficiently custom that any parsing library you go with will add more complexity that it is worth. My recommendation is the only external library you need here is JUnit :) However if you really want to do a learning exercise checkout http://www.antlr.org/