예제 #1
0
파일: Car.java 프로젝트: JMRI/jmri-test
  /**
   * Construct this Entry from XML. This member has to remain synchronized with the detailed DTD in
   * operations-cars.dtd
   *
   * @param e Car XML element
   */
  public Car(org.jdom2.Element e) {
    super(e);
    loaded = true;
    org.jdom2.Attribute a;
    if ((a = e.getAttribute(Xml.PASSENGER)) != null) {
      _passenger = a.getValue().equals(Xml.TRUE);
    }
    if ((a = e.getAttribute(Xml.HAZARDOUS)) != null) {
      _hazardous = a.getValue().equals(Xml.TRUE);
    }
    if ((a = e.getAttribute(Xml.CABOOSE)) != null) {
      _caboose = a.getValue().equals(Xml.TRUE);
    }
    if ((a = e.getAttribute(Xml.FRED)) != null) {
      _fred = a.getValue().equals(Xml.TRUE);
    }
    if ((a = e.getAttribute(Xml.UTILITY)) != null) {
      _utility = a.getValue().equals(Xml.TRUE);
    }
    if ((a = e.getAttribute(Xml.KERNEL)) != null) {
      Kernel k = CarManager.instance().getKernelByName(a.getValue());
      if (k != null) {
        setKernel(k);
        if ((a = e.getAttribute(Xml.LEAD_KERNEL)) != null && a.getValue().equals(Xml.TRUE)) {
          _kernel.setLead(this);
        }
      } else {
        log.error("Kernel " + a.getValue() + " does not exist");
      }
    }
    if ((a = e.getAttribute(Xml.LOAD)) != null) {
      _loadName = a.getValue();
    }
    if ((a = e.getAttribute(Xml.LOAD_FROM_STAGING)) != null && a.getValue().equals(Xml.TRUE)) {
      setLoadGeneratedFromStaging(true);
    }

    if ((a = e.getAttribute(Xml.WAIT)) != null) {
      try {
        _wait = Integer.parseInt(a.getValue());
      } catch (NumberFormatException nfe) {
        log.error("Wait count ({}) for car ({}) isn't a valid number!", a.getValue(), toString());
      }
    }
    if ((a = e.getAttribute(Xml.PICKUP_SCHEDULE_ID)) != null) {
      _pickupScheduleId = a.getValue();
    }
    if ((a = e.getAttribute(Xml.SCHEDULE_ID)) != null) {
      _scheduleId = a.getValue();
    }
    if ((a = e.getAttribute(Xml.NEXT_LOAD)) != null) {
      _nextLoadName = a.getValue();
    }
    if ((a = e.getAttribute(Xml.NEXT_WAIT)) != null) {
      try {
        _nextWait = Integer.parseInt(a.getValue());
      } catch (NumberFormatException nfe) {
        log.error(
            "Next wait count ({}) for car ({}) isn't a valid number!", a.getValue(), toString());
      }
    }
    if ((a = e.getAttribute(Xml.NEXT_PICKUP_SCHEDULE_ID)) != null) {
      _nextPickupScheduleId = a.getValue();
    }
    if ((a = e.getAttribute(Xml.NEXT_DEST_ID)) != null) {
      setFinalDestination(LocationManager.instance().getLocationById(a.getValue()));
    }
    if (getFinalDestination() != null && (a = e.getAttribute(Xml.NEXT_DEST_TRACK_ID)) != null) {
      setFinalDestinationTrack(getFinalDestination().getTrackById(a.getValue()));
    }
    if ((a = e.getAttribute(Xml.PREVIOUS_NEXT_DEST_ID)) != null) {
      setPreviousFinalDestination(LocationManager.instance().getLocationById(a.getValue()));
    }
    if (getPreviousFinalDestination() != null
        && (a = e.getAttribute(Xml.PREVIOUS_NEXT_DEST_TRACK_ID)) != null) {
      setPreviousFinalDestinationTrack(getPreviousFinalDestination().getTrackById(a.getValue()));
    }
    if ((a = e.getAttribute(Xml.PREVIOUS_SCHEDULE_ID)) != null) {
      setPreviousScheduleId(a.getValue());
    }
    if ((a = e.getAttribute(Xml.RWE_DEST_ID)) != null) {
      _rweDestination = LocationManager.instance().getLocationById(a.getValue());
    }
    if (_rweDestination != null && (a = e.getAttribute(Xml.RWE_DEST_TRACK_ID)) != null) {
      _rweDestTrack = _rweDestination.getTrackById(a.getValue());
    }
    if ((a = e.getAttribute(Xml.RWE_LOAD)) != null) {
      _rweLoadName = a.getValue();
    }
    addPropertyChangeListeners();
  }
예제 #2
0
파일: Car.java 프로젝트: JMRI/jmri-test
 public Car(String road, String number) {
   super(road, number);
   loaded = true;
   log.debug("New car ({} {})", road, number);
   addPropertyChangeListeners();
 }