Пример #1
0
  @Override
  public void loadMarking(M newMarking) {
    if (newMarking.getPetriNet() != this) return;

    if (this.marking.equals(newMarking)) return;

    this.marking.clear();
    for (Map.Entry<P, Integer> entry : newMarking.entrySet()) {
      this.marking.put(entry.getKey(), entry.getValue());
    }
  }
Пример #2
0
 public int lastIndexOfFourth(M m, int index) {
   try {
     for (int i = index; i >= 0; i--) {
       if ((m == null ? get(i).fourth == null : m.equals(get(i).fourth))) return i;
     }
   } catch (final Exception e) {
   }
   return -1;
 }
Пример #3
0
  public static <T extends ProcessNode<T, M>, M extends ProcessModelBase<T, M>> M deserialize(
      final DeserializationFactory<T, M> factory, final M processModel, final XmlReader in)
      throws XmlException {

    XmlReaderUtil.skipPreamble(in);
    final QName elementName = ELEMENTNAME;
    assert XmlReaderUtil.isElement(in, elementName)
        : "Expected " + elementName + " but found " + in.getLocalName();
    for (int i = in.getAttributeCount() - 1; i >= 0; --i) {
      processModel.deserializeAttribute(
          in.getAttributeNamespace(i), in.getAttributeLocalName(i), in.getAttributeValue(i));
    }

    EventType event = null;
    loop:
    while (in.hasNext() && event != XmlStreaming.END_ELEMENT) {
      switch ((event = in.next())) {
        case START_ELEMENT:
          if (processModel.deserializeChild(factory, in)) {
            continue loop;
          }
          XmlReaderUtil.unhandledEvent(in);
          break;
        case TEXT:
        case CDSECT:
          if (false) {
            continue loop;
          }
        default:
          XmlReaderUtil.unhandledEvent(in);
      }
    }

    for (final T node : processModel.getModelNodes()) {
      for (final Identifiable pred : node.getPredecessors()) {
        final T predNode = processModel.getNode(pred);
        if (predNode != null) {
          predNode.addSuccessor(node);
        }
      }
    }
    return processModel;
  }
Пример #4
0
 public synchronized boolean removeFifth(M m) {
   Quint<T, K, L, M, N> pair;
   for (final Iterator<Quint<T, K, L, M, N>> i = iterator(); i.hasNext(); ) {
     pair = i.next();
     if ((m == null ? pair.fifth == null : m.equals(pair.fifth))) {
       i.remove();
       return true;
     }
   }
   return false;
 }
Пример #5
0
  @Override
  public Set<T> getEnabledTransitionsAtMarking(M marking) {
    Set<T> result = new HashSet<T>();

    for (T t : this.getTransitions()) {
      boolean flag = true;
      for (P p : this.getPreset(t)) {
        if (!marking.isMarked(p)) {
          flag = false;
          break;
        }
      }

      if (flag) result.add(t);
    }

    return result;
  }
Пример #6
0
 public boolean containsFifth(M m) {
   for (final Iterator<Quint<T, K, L, M, N>> i = iterator(); i.hasNext(); ) {
     if ((m == null) ? i.next() == null : m.equals(i.next().fifth)) return true;
   }
   return false;
 }