1 5 package com.opensymphony.workflow.loader; 6 7 import com.opensymphony.workflow.InvalidWorkflowDescriptorException; 8 import com.opensymphony.workflow.util.Validatable; 9 10 import org.w3c.dom.Element ; 11 import org.w3c.dom.NodeList ; 12 13 import java.io.PrintWriter ; 14 15 import java.util.ArrayList ; 16 import java.util.List ; 17 18 19 25 public class SplitDescriptor extends AbstractDescriptor implements Validatable { 26 28 protected List results = new ArrayList (); 29 30 32 public SplitDescriptor() { 33 } 34 35 public SplitDescriptor(Element split) { 36 init(split); 37 } 38 39 41 public List getResults() { 42 return results; 43 } 44 45 public void validate() throws InvalidWorkflowDescriptorException { 46 ValidationHelper.validate(results); 47 } 48 49 public void writeXML(PrintWriter out, int indent) { 50 XMLUtil.printIndent(out, indent++); 51 out.println("<split id=\"" + getId() + "\">"); 52 53 for (int i = 0; i < results.size(); i++) { 54 ResultDescriptor result = (ResultDescriptor) results.get(i); 55 result.writeXML(out, indent); 56 } 57 58 XMLUtil.printIndent(out, --indent); 59 out.println("</split>"); 60 } 61 62 private void init(Element split) { 63 try { 64 setId(Integer.parseInt(split.getAttribute("id"))); 65 } catch (Exception ex) { 66 throw new IllegalArgumentException ("Invalid split id value " + split.getAttribute("id")); 67 } 68 69 List uResults = XMLUtil.getChildElements(split, "unconditional-result"); 70 71 for (int i = 0; i < uResults.size(); i++) { 72 Element result = (Element ) uResults.get(i); 73 ResultDescriptor resultDescriptor = new ResultDescriptor(result); 74 resultDescriptor.setParent(this); 75 results.add(resultDescriptor); 76 } 77 } 78 } 79 | Popular Tags |