Exemple #1
0
  /**
   * Default implementation for storing the contents of a DefaultSignalMastManager
   *
   * @param o Object to store, of type TripleDccSignalHead
   * @return Element containing the complete info
   */
  public Element store(Object o) {
    DccSignalMast p = (DccSignalMast) o;
    Element e = new Element("dccsignalmast");
    e.setAttribute("class", this.getClass().getName());
    e.addContent(new Element("systemName").addContent(p.getSystemName()));

    storeCommon(p, e);
    Element unlit = new Element("unlit");
    if (p.allowUnLit()) {
      unlit.setAttribute("allowed", "yes");
      unlit.addContent(new Element("aspect").addContent(Integer.toString(p.getUnlitId())));
    } else {
      unlit.setAttribute("allowed", "no");
    }
    e.addContent(unlit);
    SignalAppearanceMap appMap = p.getAppearanceMap();
    if (appMap != null) {
      java.util.Enumeration<String> aspects = appMap.getAspects();
      while (aspects.hasMoreElements()) {
        String key = aspects.nextElement();
        Element el = new Element("aspect");
        el.setAttribute("defines", key);
        el.addContent(
            new Element("number").addContent(Integer.toString(p.getOutputForAppearance(key))));
        e.addContent(el);
      }
    }
    List<String> disabledAspects = p.getDisabledAspects();
    if (disabledAspects != null) {
      Element el = new Element("disabledAspects");
      for (String aspect : disabledAspects) {
        Element ele = new Element("disabledAspect");
        ele.addContent(aspect);
        el.addContent(ele);
      }
      if (disabledAspects.size() != 0) {
        e.addContent(el);
      }
    }
    return e;
  }