    001    package calhoun.analysis.crf.io;
    002
    003    import java.io.BufferedReader;
    004    import java.io.IOException;
    005    import java.io.Writer;
    006    import java.util.Map;
    007
    008    /** an input component that reads in a name for each sequence.  Creates an {@link NameInputSequence}.
    009     * Can be used as a regular input component or as part of an interleaved input.
    010     */
    011    public class NameInput extends InterleavedInputComponentBase {
    012            private static final long serialVersionUID = -2944973705715162476L;
    013
    014            public boolean read(BufferedReader r, Map<String, InputSequence<?>> output) throws IOException {
    015                    String data = r.readLine();
    016                    if(data == null)
    017                            return false;
    018                    output.put(name, new NameInputSequence(data));
    019                    return true;
    020            }
    021
    022            public void write(Writer w, Map<String, ? extends InputSequence<?>> data) throws IOException {
    023                    w.write(((NameInputSequence) data.get(name)).getX(0));
    024                    w.write('\n');
    025            }
    026    }