src/main/java/org/thegalactic/context/io/ContextSerializerBurmeister.java
@Override
    public void write(final Context context, final BufferedWriter file) throws IOException {
        // Magic header
        file.write(HEADER);
        file.newLine();

        // Empty name
        file.newLine();

        final TreeSet<Comparable> attributes = context.getAttributes();
        final TreeSet<Comparable> observations = context.getObservations();

        // Observation and attributes size
        file.write(String.valueOf(observations.size()));
        file.newLine();
        file.write(String.valueOf(attributes.size()));
        file.newLine();

        // Observations
        for (final Comparable observation : observations) {
            file.write(observation.toString());
            file.newLine();
        }

        // Attributes
        for (final Comparable attribute : attributes) {
            file.write(attribute.toString());
            file.newLine();
        }

        // Extent/Intent
        final StringBuilder builder = new StringBuilder();
        for (final Comparable observation : observations) {
            builder.setLength(0);
            for (final Comparable attribute : attributes) {
                if (context.getIntent(observation).contains(attribute)) {
                    builder.append('X');
                } else {
                    builder.append('.');
                }
            }
            file.write(builder.toString());
            file.newLine();
        }
    }
/**
     * Write a context to a file.
     *
     * The Burmeister cxt format file is respected :
     *
     * The file format is structured as follows:
     *
     * The first line consists of a single "B"
     * The second line contains the name of the context (note that this is
     * ignored)
     * The third and fourth line consist of the object and attribute count,
     * respectively.
     * The fifth line is empty.
     * After that, all objects and all attributes are listed, each on a separate
     * line
     * finally, the context is given as a combination of . and X, each row on a
     * separate line.
     *
     * ~~~
     * B
     * Example
     * 2
     * 2
     *
     * a
     * b
     * 1
     * 2
     * .X
     * XX
     * ~~~
     *
     * @param context a context to write
     * @param file    a file
     *
     * @throws IOException When an IOException occurs
     */
Write a context to a file.
The Burmeister cxt format file is respected .

The file format is structured as follows.

The first line consists of a single "B"
The second line contains the name of the context (note that this is
ignored)
The third and fourth line consist of the object and attribute count,
respectively.
The fifth line is empty.
After that, all objects and all attributes are listed, each on a separate
line
finally, the context is given as a combination of . and X, each row on a
separate line.





@param context a context to write
@param file    a file


Write a context to a file . The Burmeister cxt format file is respected . The file format is structured as follows . The first line consists of a single " B " The second line contains the name of the context ( note that this is ignored ) The third and fourth line consist of the object and attribute count respectively . The fifth line is empty . After that all objects and all attributes are listed each on a separate line finally the context is given as a combination of . and X each row on a separate line . @param context a context to write @param file a file
@Override
    public void write(final Context context, final BufferedWriter file) throws IOException {
        file.write(HEADER);
        file.newLine();
        file.newLine();
        final TreeSet<Comparable> attributes = context.getAttributes();
        final TreeSet<Comparable> observations = context.getObservations();
        file.write(String.valueOf(observations.size()));
        file.newLine();
        file.write(String.valueOf(attributes.size()));
        file.newLine();
        for (final Comparable observation : observations) {
            file.write(observation.toString());
            file.newLine();
        }
        for (final Comparable attribute : attributes) {
            file.write(attribute.toString());
            file.newLine();
        }
        final StringBuilder builder = new StringBuilder();
        for (final Comparable observation : observations) {
            builder.setLength(0);
            for (final Comparable attribute : attributes) {
                if (context.getIntent(observation).contains(attribute)) {
                    builder.append('X');
                } else {
                    builder.append('.');
                }
            }
            file.write(builder.toString());
            file.newLine();
        }
    }
@ Override public void write ( final Context context , final BufferedWriter file ) throws IOException { file . write ( HEADER ) ; file . newLine ( ) ; file . newLine ( ) ; final TreeSet < Comparable > attributes = context . getAttributes ( ) ; final TreeSet < Comparable > observations = context . getObservations ( ) ; file . write ( String . valueOf ( observations . size ( ) ) ) ; file . newLine ( ) ; file . write ( String . valueOf ( attributes . size ( ) ) ) ; file . newLine ( ) ; for ( final Comparable observation : observations ) { file . write ( observation . toString ( ) ) ; file . newLine ( ) ; } for ( final Comparable attribute : attributes ) { file . write ( attribute . toString ( ) ) ; file . newLine ( ) ; } final StringBuilder builder = new StringBuilder ( ) ; for ( final Comparable observation : observations ) { builder . setLength ( 0 ) ; for ( final Comparable attribute : attributes ) { if ( context . getIntent ( observation ) . contains ( attribute ) ) { builder . append ( 'X' ) ; } else { builder . append ( '.' ) ; } } file . write ( builder . toString ( ) ) ; file . newLine ( ) ; } }
Write a context to a file.
Write a context to a file .
// Magic header // Empty name // Observation and attributes size // Observations // Attributes // Extent/Intent