1 23 24 package org.xquark.xquery.typing; 25 26 import org.xquark.xquery.parser.XQueryException; 27 28 public class QTypeDocument extends QTypeNode implements QTypeVisitable { 29 private static final String RCSRevision = "$Revision: 1.5 $"; 30 private static final String RCSName = "$Name: $"; 31 32 public static final byte ANY_ORIGIN = 0; 33 public static final byte COLLECTION_ORIGIN = 1; 34 public static final byte DOCUMENT_ORIGIN = 2; 35 36 private QType qtype = null; 37 private byte origin = ANY_ORIGIN; 38 39 public QTypeDocument(QType qtype, byte origin) { 40 this.qtype = qtype; 41 subclass = DOCUMENT; 42 occurence = OCC_1_1; 43 this.origin = origin; 44 } 45 public QTypeDocument(QType qtype, byte occurence, byte origin) { 46 this.qtype = qtype; 47 subclass = DOCUMENT; 48 this.occurence = occurence; 49 this.origin = origin; 50 } 51 52 56 public void accept(QTypeVisitor visitor) throws XQueryException { 57 visitor.visit(this); 58 } 59 60 public QType getQType() { 62 return qtype; 63 } 64 65 public void setQType(QType qtype) throws TypeException { 66 this.qtype = qtype; 67 } 68 69 73 75 public boolean equals(Object type) { 76 if (!(type instanceof QTypeDocument)) 77 return false; 78 return qtype.equals(((QTypeDocument) type).getQType()); 81 } 82 83 public boolean isNode() { 85 if (qtype == null) 86 return false; 87 return qtype.isNode(); 88 } 89 90 public boolean isSimpleTypeNode() { 92 if (qtype == null) 93 return false; 94 return qtype.isSimpleTypeNode(); 95 } 96 97 public boolean isCollection() { 99 return false; 100 } 101 102 public boolean isDocument() { 104 return true; 105 } 106 107 112 public boolean isMixed() { 114 if (qtype == null) 115 return false; 116 return qtype.isMixed(); 117 } 118 119 public boolean isElement() { 121 if (qtype == null) 122 return false; 123 return qtype.isElement(); 124 } 125 126 public boolean canBeComparedTo(QType compType) { 127 if (compType == null) 128 return false; 129 if (!(compType instanceof QTypeDocument)) 130 return qtype.canBeComparedTo(compType); 131 return qtype.canBeComparedTo(((QTypeDocument) compType).getQType()); 132 } 133 134 153 public QType applyDATAFunction() throws TypeException { 154 if (qtype == null) 155 return null; 156 return qtype.applyDATAFunction(); 157 } 158 159 169 public boolean isFromDocument() { 171 return (origin == DOCUMENT_ORIGIN); 172 } 173 public Object clone() throws CloneNotSupportedException { 175 QTypeDocument newObj = new QTypeDocument(qtype, occurence, origin); 176 return newObj; 177 } 178 public String toSimpleString() { 180 return "QTypeDocument(" + qtype + ")"; 181 } 182 183 public String toString() { 184 return "QTypeDocument(" + qtype + ")"; 185 } 186 187 } 188 | Popular Tags |