|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdanbikel.parser.SymbolicCollectionWriter
public class SymbolicCollectionWriter
Provides static methods to write out the contents of a Map
or a Set
in an S-expression format.
Method Summary | |
---|---|
static String |
valueOf(Object obj)
If the specified object is not an instance of a Sexp object
but is an instance of a SexpConvertible object,
then the value returned is the string representation of
((SexpConvertible)obj).toSexp() ; otherwise, the value
returned is that returned by String.valueOf(obj) . |
static void |
writeMap(Map map,
Symbol name,
Writer writer)
Writes out the contents of map in an S-expression format. |
static void |
writeMap(Map map,
Writer writer)
An alias for writeMap(map, null, writer) . |
static void |
writeSet(Set set,
Symbol name,
Writer writer)
Writes out the contents of the specified set in an S-expression format. |
static void |
writeSet(Set set,
Symbol name,
Writer writer,
String sep)
Writes out the contents of the specified set in an S-expression format. |
static void |
writeSet(Set set,
Writer writer)
Writes the specified set to the specified writer (with no header). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void writeSet(Set set, Symbol name, Writer writer) throws IOException
(name (element1 element2 elementN))or
(element1 element2 ... elementN)if the specified name is null, where elementi is the result of
valueOf(Object)
for an object found in the
specified set, and where a single space character separates set elements.
set
- the set to write out to the specified character writername
- the name of the set, or null if the set is to be
unnamedwriter
- the character writer to which to output the specified set
as an S-expression
IOException
public static void writeSet(Set set, Symbol name, Writer writer, String sep) throws IOException
(name (element1 element2 elementN))or
(element1 element2 ... elementN)if the specified name is null, where elementi is the result of
valueOf(Object)
for an object found in the
specified set.
set
- the set to write out to the specified character writername
- the name of the set, or null if the set is to be
unnamedwriter
- the character writer to which to output the specified set
as an S-expressionsep
- the string to separate set elements
IOException
- if the specified writer throws an
IOException
during writing
IllegalArgumentException
- if the specified separator string
does not consist entirely of whitespace characterspublic static void writeSet(Set set, Writer writer) throws IOException
writeSet(set, null, writer)
.
set
- the set whose elements are to be written to the specified
writerwriter
- the writer to which to write the specified set
IOException
- if there is a problem writing the elements
of the specified set to the specified writerpublic static void writeMap(Map map, Symbol name, Writer writer) throws IOException
map
in an S-expression format.
Each key-value
pair is written on its own line as
(name key value)where
key
is the result of calling
valueOf(key)
and value
is the result of
calling valueOf(value)
.
If name
is null
, then the format will be
(key value)If the
value
in a key-value
pair is an
instance of Set
then each of that set's members is
output in a space-separated list within parentheses; otherwise,
the normal string representation of value
is
written.
map
- the map to write outname
- the name to prepend to each key-value pair, or
null
if the key-value pairs are to be unnamedwriter
- the output stream to write to
IOException
valueOf(Object)
public static void writeMap(Map map, Writer writer) throws IOException
writeMap(map, null, writer)
.
map
- the map to write outwriter
- the output stream to write to
IOException
public static final String valueOf(Object obj)
Sexp
object
but is an instance of a SexpConvertible
object,
then the value returned is the string representation of
((SexpConvertible)obj).toSexp()
; otherwise, the value
returned is that returned by String.valueOf(obj)
.
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |