From 254ee6f47eebfc00462c10756a92066e82cc1a96 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 21 Jun 2011 15:46:02 +0200 Subject: Initial commit --- source/com/c2kernel/lifecycle/LoopDef.java | 74 ++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 source/com/c2kernel/lifecycle/LoopDef.java (limited to 'source/com/c2kernel/lifecycle/LoopDef.java') diff --git a/source/com/c2kernel/lifecycle/LoopDef.java b/source/com/c2kernel/lifecycle/LoopDef.java new file mode 100755 index 0000000..bee97c5 --- /dev/null +++ b/source/com/c2kernel/lifecycle/LoopDef.java @@ -0,0 +1,74 @@ +package com.c2kernel.lifecycle; + +import com.c2kernel.graph.model.Vertex; +import com.c2kernel.graph.traversal.GraphTraversal; +import com.c2kernel.lifecycle.instance.Loop; +import com.c2kernel.lifecycle.instance.WfVertex; + +/** + * @version $Revision: 1.19 $ $Date: 2005/09/29 10:18:31 $ + * @author $Author: abranson $ + */ + +public class LoopDef extends XOrSplitDef +{ + public boolean hasLoop = false; + public int isNext = 0; + + /** + * @see java.lang.Object#Object() + */ + public LoopDef() + { + super(); + } + + /** + * @see com.c2kernel.lifecycle.WfVertexDef#loop() + */ + public boolean loop() + { + return true; + } + + /** + * @see com.c2kernel.lifecycle.WfVertexDef#verify() + */ + public boolean verify() + { + if (!super.verify()) return false; + Vertex[] nexts = getOutGraphables(); + Vertex[] anteVertices = + GraphTraversal.getTraversal(this.getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false); + int k = 0; + int l = 0; + Vertex[] brothers = getParent().getChildren(); + for (int i = 0; i < brothers.length; i++) + if (brothers[i] instanceof LoopDef) l++; + for (int i = 0; i < nexts.length; i++) + for (int j = 0; j < anteVertices.length; j++) + if (nexts[i].equals(anteVertices[j])) + k++; + if (k != 1 && !(l>1)) + { + mErrors.add("bad number of pointing back nexts"); + return false; + } +// if (nexts.length>2) { +// mErrors.add("you must only have 2 nexts"); +// return false; +// } + return true; + } + + public boolean isLoop() { + return true; + } + + public WfVertex instantiate() { + Loop newLoop = new Loop(); + configureInstance(newLoop); + return newLoop; + } + +} -- cgit v1.2.3