1 22 23 package org.xquark.xquery.parser; 24 25 import org.xquark.util.NamespaceContext; 26 import org.xquark.xquery.typing.TypeException; 27 import org.xquark.util.NamespaceContext; 28 29 public class QName extends XQueryExpression implements Cloneable { 30 31 private static final String RCSRevision = "$Revision: 1.14 $"; 32 private static final String RCSName = "$Name: $"; 33 34 protected String namespace = null; 35 protected String prefixname = null; 36 protected String localname = null; 38 NamespaceContext namespaceContext = null; 40 41 45 public void accept(ParserVisitor visitor) throws XQueryException { 46 visitor.visit(this); 47 } 48 49 53 public QName(String localname, XQueryModule parentModule) throws TypeException, XQueryException { 54 setLocalName(localname); 55 setParentModule(parentModule); 56 } 57 58 public QName(String namespace, String prefixname, String localname, XQueryModule parentModule, NamespaceContext namespaceContext) throws TypeException, XQueryException { 59 setNameSpace(namespace); 60 setPrefixName(prefixname); 61 setLocalName(localname); 62 setParentModule(parentModule); 63 this.namespaceContext = namespaceContext; 64 } 65 66 70 public String toString() { 71 return toString(false, false, false); 72 } 73 74 public String getStringValue() { 75 return getStringValue(false, false); 76 } 77 78 public String getLocalName() { 79 return localname; 80 } 81 public void setLocalName(String localname) throws XQueryException { 82 if (localname == null || localname.equals("")) 83 throw new XQueryException("local name of QName cannot be empty string"); 84 this.localname = localname; 85 } 86 87 public String getPrefixName() { 88 return prefixname; 89 } 90 public void setPrefixName(String prefixname) { 91 this.prefixname = prefixname; 92 } 93 94 public String getNameSpace() { 95 return namespace; 96 } 97 public void setNameSpace(String namespace) { 98 this.namespace = namespace; 99 } 100 101 public String getName() { 102 return localname; 103 } 104 public void setName(String name) { 105 localname = name; 106 } 107 public NamespaceContext getNamespaceContext() { 108 return namespaceContext; 109 } 110 111 public boolean equals(XQueryExpression expr) { 112 if (expr instanceof QName) { 113 if (!localname.equals(((QName) expr).getLocalName())) 114 return false; 115 if (namespace == null && ((QName) expr).getNameSpace() == null) 116 return true; 117 if (namespace != null && namespace.equals(((QName) expr).getNameSpace())) 118 return true; 119 } 120 if (expr instanceof Value) { 121 if (namespace == null && localname.equals(((Value) expr).getValue())) 122 return true; 123 } 124 return false; 125 } 126 127 } 128 | Popular Tags |