1 23 24 package org.xquark.xquery.typing; 25 26 import java.util.ArrayList ; 27 import java.util.Iterator ; 28 import java.util.List ; 29 30 import org.xquark.xquery.parser.XQueryException; 31 32 public class QTypeUnion extends QTypePrime implements QTypeVisitable { 33 private static final String RCSRevision = "$Revision: 1.3 $"; 34 private static final String RCSName = "$Name: $"; 35 36 List list = null; 37 38 public QTypeUnion(List list) { 39 super(list,UNION); 40 setList(list); 41 subclass = UNION; 42 occurence = OCC_1_1; 44 } 45 public QTypeUnion(List list, byte occurence) { 46 super(list,UNION); 47 setList(list); 48 subclass = UNION; 49 this.occurence = occurence; 51 } 52 53 57 public void accept(QTypeVisitor visitor) throws XQueryException { 58 visitor.visit(this); 59 } 60 61 public List getList() { 63 return list; 64 } 65 66 private void setList(List list) { 67 this.list = new ArrayList (); 69 Iterator it = list.iterator(); 70 while (it.hasNext()) { 71 QType qtype = (QType) it.next(); 72 if (qtype instanceof QTypeUnion) 73 this.list.addAll(((QTypeUnion) qtype).getList()); 74 else 75 this.list.add(qtype); 76 } 77 } 78 79 public Object clone() throws CloneNotSupportedException { 81 QTypeUnion newObj = new QTypeUnion(list, occurence); 82 return newObj; 83 } 84 public String toSimpleString() { 86 return "QTypeUnion(" + list + ")"; 87 } 88 89 public String toString() { 90 return "QTypeUnion(" + list + ")"; 91 } 92 } 93 | Popular Tags |