예제 #1
0
  /**
   * Writes the location of the views of the known {@link Note}s.
   *
   * @param element the xml-element to write into, the attributes of <code>element</code> will not
   *     be changed
   */
  public void writeXML(XElement element) throws IOException {
    PropertyTransformer transformer = new PropertyTransformer();

    for (Map.Entry<Note, Tuple<DockStation, DockableProperty>> location : locations.entrySet()) {
      XElement xnote = element.addElement("note");
      xnote.addString("id", location.getKey().getId());
      xnote.addString("station", manager.getName(location.getValue().getA()));
      transformer.writeXML(location.getValue().getB(), xnote);
    }
  }
예제 #2
0
  /**
   * Writes the location of the views of the known {@link Note}s.
   *
   * @param out the stream to write into
   * @throws IOException if this method can't write into <code>out</code>
   */
  public void write(DataOutputStream out) throws IOException {
    PropertyTransformer transformer = new PropertyTransformer();

    out.writeInt(locations.size());
    for (Map.Entry<Note, Tuple<DockStation, DockableProperty>> location : locations.entrySet()) {
      out.writeUTF(location.getKey().getId());
      out.writeUTF(manager.getName(location.getValue().getA()));
      transformer.write(location.getValue().getB(), out);
    }
  }
예제 #3
0
  /**
   * Reads the location of the views of all known <code>Note</code>s.
   *
   * @param element the xml-element to read from
   */
  public void readXML(XElement element) {
    PropertyTransformer transformer = new PropertyTransformer();

    for (XElement xnote : element.getElements("note")) {
      Note note = model.getNote(xnote.getString("id"));
      DockStation station = manager.getStation(xnote.getString("station"));
      DockableProperty property = transformer.readXML(xnote);
      if (note != null) {
        locations.put(note, new Tuple<DockStation, DockableProperty>(station, property));
      }
    }
  }
예제 #4
0
  /**
   * Reads the location of the views of all known <code>Note</code>s.
   *
   * @param in the stream to read from
   * @throws IOException if <code>in</code> can't be read
   */
  public void read(DataInputStream in) throws IOException {
    PropertyTransformer transformer = new PropertyTransformer();

    int count = in.readInt();
    for (int i = 0; i < count; i++) {
      Note note = model.getNote(in.readUTF());
      DockStation station = manager.getStation(in.readUTF());
      DockableProperty property = transformer.read(in);
      if (note != null) {
        locations.put(note, new Tuple<DockStation, DockableProperty>(station, property));
      }
    }
  }