home -> developer -> Message

specification javadoc

Cross-host messaging

Data transferred between hosts often must be represented in a platform independent format, such as XML. However, once arrived at a host, data is often most conveniently manipulated when represented in a programming language's native format. The org.waterken.stream library provides an extensible mechanism for bidirectional translation between platform independent formats, like XML, and Java objects. This object serialization is used to implement web-calculus messaging to a Java application.

This software is distributed as part of the WaterkenTM Server, under the Open Source MIT License.

Example

The Java class

package com.example.geometry;

public final class
Point {
    private int x;
    private int y;

    private
    Point() {}

    public
    Point(final int x, final int y) {
        this.x = x;
        this.y = y;
    }

    public int
    getX() { return x; }

    public int
    getY() { return y; }
}

An XML representation

<list>
<doc schema="http://example.com/geometry/Point">
    <x>3</x>
    <y>4</y>
</doc>
</list>

Code

Encoding

Object value = ...
File file = ...
OutputStream out = new FileOutputStream(file);
Document serialized = org.waterken.stream.output.Maker.make().
    publish(Any.make()).serialize("", new Object[] { value }, null);
org.waterken.doc.sax.Generator.generate(serialized, "").copy(out);
out.flush();
out.close();

Decoding

File file = ...
Document serialized = org.waterken.doc.sax.Lexer.make().
    lex("", org.waterken.io.file.Content.make(file));
Collect out = new Collect(1);
org.waterken.stream.input.Maker.make().allow(Any.make()).
    deserialize(new String[] {}, serialized, null, out);
Object value = out.list()[0];
top

Copyright 2002 - 2005 Waterken Inc. All rights reserved.

Valid XHTML 1.0! Valid CSS!