Пример #1
0
  /* (non-Javadoc)
   * @see gov.nasa.jpl.statechart.input.identifiers.UML2_0#vertex_getOutgoingTransitions(gov.nasa.jpl.statechart.uml.UMLVertex)
   */
  @Override
  public Collection<Transition> vertex_getOutgoingTransitions(UMLVertex v) {
    Collection<Transition> outgoing = Util.newList();

    /* search all transitions from one level down into the region(s),
     * up through ancestor regions, filtering on source IDs;
     * so the XPath syntax is:
     *   region/transition[@source='<id>'] | ancestor-or-self::transition[@source='<id>']
     *
     * If vertex is a connectionPoint (i.e., entry-/exitPoint), then search
     * needs to begin from the peer-level as vertex, so prepend "..".
     */
    try {
      NodeList transitions =
          (NodeList)
              UMLElement.xpath.evaluate(
                  (isConnectionPoint(v) ? "../" : "")
                      + lit(UMLLabel.TAG_REGION)
                      + "/"
                      + lit(UMLLabel.TAG_TRANSITION)
                      + "[@"
                      + lit(UMLLabel.KEY_SOURCE)
                      + "='"
                      + v.id()
                      + "']"
                      + "/@"
                      + XMIIdentifiers.id()
                      + " | ancestor-or-self::*/"
                      + lit(UMLLabel.TAG_TRANSITION)
                      + "[@"
                      + lit(UMLLabel.KEY_SOURCE)
                      + "='"
                      + v.id()
                      + "']"
                      + "/@"
                      + XMIIdentifiers.id(),
                  v.getNode(),
                  XPathConstants.NODESET);

      if (Util.isDebugLevel()) {
        Util.debug("UML 2.1.2 getOutgoingTrans: [");
      }
      for (int i = 0; i < transitions.getLength(); i++) {
        String tid = transitions.item(i).getNodeValue();
        outgoing.add((Transition) v.xmi2uml(tid));
        if (Util.isDebugLevel()) {
          Util.debug("  " + tid);
        }
      }
      if (Util.isDebugLevel()) {
        Util.debug("]");
      }
    } catch (XPathExpressionException e) {
      Util.reportException(e, "UML2_1_2.vertex_getOutgoingTransitions(): ");
    }

    return outgoing;
  }
Пример #2
0
  /* (non-Javadoc)
   * @see gov.nasa.jpl.statechart.input.identifiers.UML2_0#vertex_getIncomingTransitions(gov.nasa.jpl.statechart.uml.UMLVertex)
   */
  @Override
  public Collection<Transition> vertex_getIncomingTransitions(UMLVertex v) {
    Collection<Transition> incoming = Util.newList();

    /* since transition can come from any leve, need to search all
     * transitions from this point down into inner states, and then
     * up through ancestor regions, filtering on targets;
     * so the XPath syntax is:
     *   descendant::* /transition[@target='<id>'] | ancestor-or-self::* /transition[@target='<id>']
     *
     * If vertex is a connectionPoint (i.e., entry-/exitPoint), then search
     * needs to begin from the peer-level as vertex, so prepend "..".
     */
    try {
      NodeList transitions =
          (NodeList)
              UMLElement.xpath.evaluate(
                  (isConnectionPoint(v) ? "../" : "")
                      + "descendant::*/"
                      + lit(UMLLabel.TAG_TRANSITION)
                      + "[@"
                      + lit(UMLLabel.KEY_TARGET)
                      + "='"
                      + v.id()
                      + "']"
                      + "/@"
                      + XMIIdentifiers.id()
                      + " | ancestor-or-self::*//"
                      + lit(UMLLabel.TAG_TRANSITION)
                      + "[@"
                      + lit(UMLLabel.KEY_TARGET)
                      + "='"
                      + v.id()
                      + "']"
                      + "/@"
                      + XMIIdentifiers.id(),
                  v.getNode(),
                  XPathConstants.NODESET);

      for (int i = 0; i < transitions.getLength(); i++) {
        String tid = transitions.item(i).getNodeValue();
        incoming.add((Transition) v.xmi2uml(tid));
      }
    } catch (XPathExpressionException e) {
      Util.reportException(e, "UML2_1_2.vertex_getIncomingTransitions(): ");
    }

    return incoming;
  }