Skip to content

old_ _JUMBOReader

Oliver Stueker edited this page May 11, 2015 · 3 revisions
    • WARNING**: I believe this to be old now. It should be modified or maybe eliminated.

A set of Java routines to parse flat ASCII into rawCML

see also Examples_of_CML

The code is currently in:

Table of Contents

dictionaries

JumboReader manages the markukp of a block of text in the context of a dictionary and its prefix. The most common constructor is therefore: This reads the lines into the reader , and associates a dictionary and the prefix. When, for example, you create a JumboReader will use the prefix and associate it with the dictionary. JumboReader will also check to see if the entry is in the given dictionary and issue a warning if not.

lines

JumboReader keeps all the lines in memory and maintains a (CLN) (lines start at 0 - sorry FORTRAN folks, but this is Java). So if we have a list: then JR knowns that there are three lines and by default the CLN = 0; When a line(s) is/are read the CLN advances. So will set the CLN to 2 "line3". Attempts to read beyond the end of the lines throws an error. This is a valuable strategy and we are working on the Exception design for this. Currently it throwa a RuntimeException - it would be better to have a JumboReaderException.

whitespace

Note that all LEADING white space is significant. All trailing WS is ignored. JumboReader will honour FORTRAN formats that go beyond the end of the information. Thus will read the lines but will truncate after 9 (or possibly fail on)

In many cases the only sign that information is finished is a blank line and JumboReader can fail gracefully on this: Here the program author has decided only to output values greater than 1. The reader can only assume that a blank line is the end of input. When a blank line is NOT present it can be very difficult for machines or even humans to know what is happening.

formats

JumboReader has two types of format, Fortran and Pattern (regular expression). Although it's possible to represent FOTRAN as RE's it can be quite hairy and a FORMAT gets closets to the mind of the program author. Many routines can take either. As an example Can be described either as or

In some cases the FORTRAN may be easier (e.g. if there is a minus directly after the =) and in some cases the regex.

Data types and Data Structures

CML and JUMBO currently recognizes the following dataTypes. They are supported by XSD Schema DataTypes ||<tableborder="1"></tableborder="1">//type//||//description//||//XSD//||//CMLConstants//||//Java//|| ||string|| any set of Unicode characters||xsd:string||XSD_STRING||String|| ||integer||any positive/negative/zerointeger||xsd:integer||XSD_INTEGER||Integer|| ||double||any real number or integer||xsd:double||XSD_DOUBLE||Double|| ||boolean||"true" "false" case-insensitive||XSD_BOOLEAN||Boolean|| ||date||ISO8601 dateTime||XSD_DATE||org.joda.time.DateTime||

Note that is so awful that people use JODA.

Data structures are:

 *  available for all dataTypes. The value is held as the string representation (the number of decimals is either determined by the author or java.lang.Double).
 *  available for strings, doubles and integers. Arrays are held as concatenated scalarValues separated by a delimiter. the default delimiter is whitespace.
 *  primarily supports n*m and n*n matrices but can also support various shapes such as triangular. Irregular matrices should use a CMLArrayList of CMLArrays.
 *  mirrors aspects of HTML tables. The commonest is an ordered array of columns held as CMLArrays or identical length.

Note that numeric quantities can have error estimates, error ranges, etc,

Dictionaries

    • All quantities must have resolvable references to a dictionary.** This maps well onto the URI approach where all URIs should point to something useful. A typical usage is:
This requires a "foo" dictionary known to a validating program which contains an entry with id="bar", like: The simplest way of associating the dictionary during development is in the tree. In production this will also be on the web.
Clone this wiki locally