Back to index

moin  1.9.0~rc2
Public Member Functions | Private Member Functions | Private Attributes
CH.ifa.draw.util.StorableOutput Class Reference

An output stream that can be used to flatten Storable objects. More...

Collaboration diagram for CH.ifa.draw.util.StorableOutput:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 StorableOutput (OutputStream stream)
 Initializes the StorableOutput with the given output stream.
void writeStorable (Storable storable)
 Writes a storable object to the output stream.
void writeInt (int i)
 Writes an int to the output stream.
void writeColor (Color c)
void writeDouble (double d)
 Writes an int to the output stream.
void writeBoolean (boolean b)
 Writes an int to the output stream.
void writeString (String s)
 Writes a string to the output stream.
void close ()
 Closes a storable output stream.

Private Member Functions

boolean mapped (Storable storable)
void map (Storable storable)
void writeRef (Storable storable)
void incrementIndent ()
void decrementIndent ()
void startNewLine ()
void space ()

Private Attributes

PrintWriter fStream
Vector fMap
int fIndent

Detailed Description

An output stream that can be used to flatten Storable objects.

StorableOutput preserves the object identity of the stored objects.

See also:
Storable
StorableInput

Definition at line 21 of file StorableOutput.java.


Constructor & Destructor Documentation

CH.ifa.draw.util.StorableOutput.StorableOutput ( OutputStream  stream) [inline]

Initializes the StorableOutput with the given output stream.

Definition at line 30 of file StorableOutput.java.

                                               {
        fStream = new PrintWriter(stream);
        fMap = new Vector();
        fIndent = 0;
    }

Member Function Documentation

Closes a storable output stream.

Definition at line 118 of file StorableOutput.java.

                        {
        fStream.close();
    }

Here is the caller graph for this function:

Definition at line 144 of file StorableOutput.java.

                                   {
        fIndent -= 4;
        if (fIndent < 0) fIndent = 0;
    }

Here is the caller graph for this function:

Definition at line 140 of file StorableOutput.java.

                                   {
        fIndent += 4;
    }

Here is the caller graph for this function:

void CH.ifa.draw.util.StorableOutput.map ( Storable  storable) [inline, private]

Definition at line 126 of file StorableOutput.java.

                                        {
        if (!fMap.contains(storable))
            fMap.addElement(storable);
    }

Here is the caller graph for this function:

boolean CH.ifa.draw.util.StorableOutput.mapped ( Storable  storable) [inline, private]

Definition at line 122 of file StorableOutput.java.

                                              {
        return fMap.contains(storable);
    }

Here is the caller graph for this function:

void CH.ifa.draw.util.StorableOutput.space ( ) [inline, private]

Definition at line 155 of file StorableOutput.java.

                         {
        fStream.print(' ');
    }

Here is the caller graph for this function:

Definition at line 149 of file StorableOutput.java.

                                {
        fStream.println();
        for (int i=0; i<fIndent; i++)
            space();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.util.StorableOutput.writeBoolean ( boolean  b) [inline]

Writes an int to the output stream.

Definition at line 86 of file StorableOutput.java.

                                        {
        if (b)
            fStream.print(1);
        else
            fStream.print(0);
        space();
    }

Here is the call graph for this function:

void CH.ifa.draw.util.StorableOutput.writeColor ( Color  c) [inline]

Definition at line 69 of file StorableOutput.java.

                                    {
        writeInt(c.getRed());
        writeInt(c.getGreen());
        writeInt(c.getBlue());
    }

Here is the call graph for this function:

void CH.ifa.draw.util.StorableOutput.writeDouble ( double  d) [inline]

Writes an int to the output stream.

Definition at line 78 of file StorableOutput.java.

                                      {
        fStream.print(d);
        space();
    }

Here is the call graph for this function:

void CH.ifa.draw.util.StorableOutput.writeInt ( int  i) [inline]

Writes an int to the output stream.

Definition at line 64 of file StorableOutput.java.

                                {
        fStream.print(i);
        space();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.util.StorableOutput.writeRef ( Storable  storable) [inline, private]

Definition at line 131 of file StorableOutput.java.

                                             {
        int ref = fMap.indexOf(storable);

        fStream.print("REF");
        space();
        fStream.print(ref);
        space();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Writes a storable object to the output stream.

Definition at line 39 of file StorableOutput.java.

                                                 {
        if (storable == null) {
            fStream.print("NULL");
            space();
            return;
        }

        if (mapped(storable)) {
            writeRef(storable);
            return;
        }

        incrementIndent();
        startNewLine();
        map(storable);
        fStream.print(storable.getClass().getName());
        space();
        storable.write(this);
        space();
        decrementIndent();
    }

Here is the call graph for this function:

void CH.ifa.draw.util.StorableOutput.writeString ( String  s) [inline]

Writes a string to the output stream.

Special characters are quoted.

Definition at line 98 of file StorableOutput.java.

                                      {
        fStream.print('"');
        for(int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            switch(c) {
                case '\n': fStream.print('\\'); fStream.print('n'); break;
                case '"' : fStream.print('\\'); fStream.print('"'); break;
                case '\\': fStream.print('\\'); fStream.print('\\'); break;
                case '\t': fStream.print('\\'); fStream.print('\t'); break;
                default: fStream.print(c);
            }

        }
        fStream.print('"');
        space();
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 25 of file StorableOutput.java.

Definition at line 24 of file StorableOutput.java.

Definition at line 23 of file StorableOutput.java.


The documentation for this class was generated from the following file: