1 23 24 package org.xquark.xquery.typing; 25 26 import java.util.ArrayList ; 27 28 import org.xquark.schema.SchemaConstants; 29 import org.xquark.schema.SchemaManager; 30 import org.xquark.schema.SimpleType; 31 import org.xquark.xquery.parser.XQueryException; 32 33 public class QTypeText extends QTypeNode implements QTypeVisitable { 34 private static final String RCSRevision = "$Revision: 1.7 $"; 35 private static final String RCSName = "$Name: $"; 36 37 public QTypeText(SimpleType simpleType) { 38 setType(simpleType); 39 subclass = TEXT; 40 occurence = OCC_1_1; 41 } 42 public QTypeText(SimpleType simpleType, byte occurence) { 43 setType(simpleType); 44 subclass = TEXT; 45 this.occurence = occurence; 46 } 47 48 52 public void accept(QTypeVisitor visitor) throws XQueryException { 53 visitor.visit(this); 54 } 55 56 61 public boolean equals(Object qtype) { 63 if (!(qtype instanceof QTypeText)) 64 return false; 65 return compare(type, ((QTypeText) qtype).getSimpleType()); 68 } 69 70 public boolean isNumeric() { 72 if (type == null) 73 return false; 74 else 75 return isNumeric(type); 76 } 77 78 public boolean isBoolean() { 80 if (type == null) 81 return false; 82 else 83 return isBoolean(type); 84 } 85 86 public boolean isInteger() { 88 if (type == null) 89 return false; 90 else 91 return isInteger(type); 92 } 93 94 public boolean isString() { 96 if (type == null || isMultiple()) 97 return false; 98 else 99 return isString(type); 100 } 101 102 105 110 public boolean isDate() { 112 if (type == null) 113 return false; 114 else 115 return isDate(type); 116 } 117 118 public boolean isAttribute() { 120 return false; 121 } 122 123 132 public boolean isNode() { 134 return true; 135 } 136 137 public boolean isSimpleTypeNode() { 139 return true; 140 } 141 142 public boolean isAtomic() { 144 return !isMultiple(); 145 } 146 147 public boolean canBeComparedTo(QType compType) { 148 if (compType == null) 149 return false; 150 if (!(compType instanceof QTypeText)) 151 return compType.canBeComparedTo(this); 152 if (type == null) 153 return true; 154 if (((QTypeText) compType).getSimpleType() == null) 155 return true; 156 return canBeCompared(((SimpleType)type).getPrimitive().getType(), ((QTypeText) compType).getSimpleType().getPrimitive().getType()); 157 } 158 159 public QType applyTEXTFunction(boolean inDepth, ArrayList history, SchemaManager schemamanager) throws TypeException { 160 return new QTypeAtom((SimpleType) schemamanager.getType(SchemaConstants.XMLSCHEMA_URI, TypeVisitor.SC_STRING),occurence); 161 } 162 163 public QType applyDATAFunction() throws TypeException { 164 return new QTypeAtom((SimpleType)type,occurence); 165 } 166 167 public QType applyFILTERFunction() throws TypeException { 168 return this; 169 } 170 171 public Object clone() throws CloneNotSupportedException { 173 QTypeText newObj = new QTypeText((SimpleType)type,occurence); 174 return newObj; 175 } 176 public String toSimpleString() { 178 return "QTypeText(" + type.getName() + ")"; 179 } 180 181 public String toString() { 182 return "QTypeText(" + type + ")"; 183 } 184 185 } 186 | Popular Tags |