Exemplo n.º 1
0
  @Override
  public void startTag(String name, Attributes atts, Stack<String> context) {
    if (name.equalsIgnoreCase(Constants.PERSONS_TAG)) {
      persons = new HashSet<>();

    } else if (name.equalsIgnoreCase(Constants.PERSON_TAG)) {
      person = factory.newPerson(getAttribute(Constants.ID_KEY, atts));

      for (int i = 0; i < atts.getLength(); i++) {
        String type = atts.getLocalName(i);
        if (!type.equalsIgnoreCase(Constants.ID_KEY)) {
          if (!blacklist.contains(type)) {
            person.setAttribute(type, getAttribute(type, atts));
          }
        }
      }

    } else if (name.equalsIgnoreCase(Constants.PLAN_TAG)) {
      plan = factory.newEpisode();

      for (int i = 0; i < atts.getLength(); i++) {
        String type = atts.getLocalName(i);

        if (!blacklist.contains(type)) {
          plan.setAttribute(type, getAttribute(type, atts));
        }
      }

    } else if (name.equalsIgnoreCase(Constants.ACTIVITY_TAG)) {
      Segment act = factory.newSegment();

      for (int i = 0; i < atts.getLength(); i++) {
        String type = atts.getLocalName(i);
        if (!blacklist.contains(type)) {
          act.setAttribute(type, getAttribute(type, atts));
        }
      }
      plan.addActivity(act);

    } else if (name.equalsIgnoreCase(Constants.LEG_TAG)) {
      Segment leg = factory.newSegment();

      for (int i = 0; i < atts.getLength(); i++) {
        String type = atts.getLocalName(i);
        if (!blacklist.contains(type)) {
          leg.setAttribute(type, getAttribute(type, atts));
        }
      }
      plan.addLeg(leg);
    }
  }
Exemplo n.º 2
0
  public static Episode deepCopy(Episode episode, Factory factory) {
    Episode clone = factory.newEpisode();
    for (String key : episode.keys()) {
      clone.setAttribute(key, episode.getAttribute(key));
    }

    for (Segment act : episode.getActivities()) {
      Segment actClone = shallowCopy(act, factory);
      clone.addActivity(actClone);
    }

    for (Segment leg : episode.getLegs()) {
      Segment legClone = shallowCopy(leg, factory);
      clone.addLeg(legClone);
    }

    return clone;
  }