public final class OctaveIO extends Object
octaveExec.
The basic operations are to
set(Map) (no setting of a single value),
get(String),
existsVar(String).
readerReadLine(BufferedReader) reads a line
read(BufferedReader) reads an object
readWithName(BufferedReader) yields a singleton map name-->object,
where name is the name of a variable
readWithName(String) yields a singleton map name-->object,
as above but reading from a string.
write(Writer, OctaveObject)
write(Writer, String, OctaveObject)
toText(String, OctaveObject)
toText(OctaveObject)
| Modifier and Type | Field and Description |
|---|---|
private static String |
GLOBAL |
private static String |
NAME |
private OctaveExec |
octaveExec |
private static String |
TYPE |
| Constructor and Description |
|---|
OctaveIO(OctaveExec octaveExec) |
| Modifier and Type | Method and Description |
|---|---|
private boolean |
existsVar(String name)
Returns whether the variable
name exists. |
OctaveObject |
get(String name)
Gets the value of the variable
name
or null if this variable does not exist
according to existsVar(String). |
static OctaveObject |
read(BufferedReader reader)
Read a single object from Reader.
|
static String |
readerReadLine(BufferedReader reader)
Reads a line from
reader into a string if possible. |
static Map<String,OctaveObject> |
readWithName(BufferedReader reader)
Read a single variable - object pair from Reader.
|
static Map<String,OctaveObject> |
readWithName(String input)
Read a single object from String,
it is an error if there is data left after the object.
|
void |
set(Map<String,OctaveObject> values)
Sets the map
values
mapping variable names to according values. |
static String |
toText(OctaveObject octValue)
Returns as a string how the
OctaveObject octaveType
(****bad name) is written without variable,
i.e. with variable "ans". |
static String |
toText(String name,
OctaveObject octValue)
Returns as a string how the variable
name
and the OctaveObject octaveType (****bad name)
are written. |
static void |
write(Writer writer,
String name,
OctaveObject octValue)
ER:
Writes the name
name
and the OctaveObject octValue
to the writer writer
using write(Writer, OctaveObject). |
static <T extends OctaveObject> |
write(Writer writer,
T octValue)
|
static void |
writerWriteLine(Writer writer,
String strWithNl)
Writes a line given by
strWithNl to writer
if possible. |
private static final String GLOBAL
private static final String TYPE
private static final String NAME
private final OctaveExec octaveExec
public OctaveIO(OctaveExec octaveExec)
octaveExec - public void set(Map<String,OctaveObject> values)
values
mapping variable names to according values.values - public OctaveObject get(String name)
name
or null if this variable does not exist
according to existsVar(String).name - the name of a variablename from octave
or null if the variable does not exist.OctaveClassCastException - if the value can not be cast to Tprivate boolean existsVar(String name)
name exists.name - the name of a variablename exists.public static String readerReadLine(BufferedReader reader)
reader into a string if possible.
Returns null at the end of the stream and throws an exception
in case of io problems.reader - the reader to read a line from.reader, null at end of streamOctaveIOException - in case of IOException reading from reader.public static OctaveObject read(BufferedReader reader)
OctaveDataReader.getOctaveDataReader(String).reader - a reader starting with first line
TYPE[global ]type,
i.e. global is optional
and type is the type of the object to be read.OctaveParseException - **** appropriate type?
if the type read before is not registered
and so there is no appropriate reader.public static Map<String,OctaveObject> readWithName(BufferedReader reader)
reader - a reader starting with first line NAMEname,
where name is the name of the variable.
the following lines represent the object stored in that variable.public static Map<String,OctaveObject> readWithName(String input)
input - OctaveParseException - if there is data left after the object is readpublic static void writerWriteLine(Writer writer, String strWithNl)
strWithNl to writer
if possible.writer - strWithNl - OctaveIOException - in case of IOException writing to writer.public static <T extends OctaveObject> void write(Writer writer, T octValue) throws IOException
OctaveObject octaveType (****bad name)
to the writer writer.
To that end, fetch an OctaveDataWriter
of the appropriate type given by octaveType
and use this writer to write octaveType
onto writer.T - the type of OctaveObject to be written.writer - the writer to write the object octValue onto.octValue - the object to write to writer.OctaveParseException - **** appropriate type?
if the type of octValue is not registered
and so there is no appropriate writer.IOException - if the process of writing fails.public static void write(Writer writer, String name, OctaveObject octValue) throws IOException
name
and the OctaveObject octValue
to the writer writer
using write(Writer, OctaveObject).writer - the writer to write the object octaveType onto.name - the name, **** of a variableoctValue - the object to write to writer.OctaveParseException - **** appropriate type?
if the type of octaveType is not registered
and so there is no appropriate writer.IOException - if the process of writing fails.public static String toText(String name, OctaveObject octValue)
name
and the OctaveObject octaveType (****bad name)
are written.name - the name, **** of a variableoctValue - the object to write to writer.public static String toText(OctaveObject octValue)
OctaveObject octaveType
(****bad name) is written without variable,
i.e. with variable "ans".octValue - Copyright © 2006–2018 Simuline Organization (l2r). All rights reserved.