summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2005-04-26 11:03:53 +0000
committerburaq <buraq@epfl.ch>2005-04-26 11:03:53 +0000
commit31b680f267bc76cd6e338e22ec885574181a7d23 (patch)
treeaeb1abbbf9df1f798a3407a952e822fdf769f1e2
parentc0f530cfa0d402a4563ef2af421ff4992885316e (diff)
downloadscala-31b680f267bc76cd6e338e22ec885574181a7d23.tar.gz
scala-31b680f267bc76cd6e338e22ec885574181a7d23.tar.bz2
scala-31b680f267bc76cd6e338e22ec885574181a7d23.zip
resurrected
-rw-r--r--sources/scala/xml/Null.scala59
-rw-r--r--sources/scala/xml/PrefixedAttribute.scala63
-rw-r--r--sources/scala/xml/UnprefixedAttribute.scala44
3 files changed, 166 insertions, 0 deletions
diff --git a/sources/scala/xml/Null.scala b/sources/scala/xml/Null.scala
new file mode 100644
index 0000000000..544b05c743
--- /dev/null
+++ b/sources/scala/xml/Null.scala
@@ -0,0 +1,59 @@
+package scala.xml;
+
+case object Null extends MetaData {
+
+ /** appends given MetaData items to this MetaData list */
+ override def append(m: MetaData): MetaData = m;
+
+ override def containedIn1(m:MetaData): Boolean = false;
+
+ /** returns a copy of this MetaData item with next field set to argument */
+ def copy(next: MetaData) = next;
+
+ /** returns null */
+ def getNamespace(owner: Node) = null;
+
+ final override def hasNext = false;
+
+ final override def length = 0;
+
+ final override def length(i:Int) = i;
+
+ def isPrefixed = false;
+
+ /** deep equals method */
+ override def equals(that: Any) = that match {
+ case m:MetaData => m.length == 0
+ case _ => false;
+ }
+
+ def equals1(that:MetaData) = that.length == 0;
+
+ def key = null;
+
+ def value = null;
+
+ def next = null;
+
+ /** null */
+ def getValue(key: String) = null;
+
+ /** gets value of qualified (prefixed) attribute with given key */
+ def getValue(namespace: String, scope: NamespaceBinding, key: String) =
+ null;
+
+ override def hashCode(): Int = 0;
+
+ override def toString1(): String = "";
+
+ //appends string representations of single attribute to StringBuffer
+ def toString1(sb:StringBuffer) = {};
+
+ override def toString(): String = "";
+
+ override def toString(sb: StringBuffer): Unit = {}
+
+ override def wellformed(scope: NamespaceBinding) = true;
+
+
+}
diff --git a/sources/scala/xml/PrefixedAttribute.scala b/sources/scala/xml/PrefixedAttribute.scala
new file mode 100644
index 0000000000..7be7ffe338
--- /dev/null
+++ b/sources/scala/xml/PrefixedAttribute.scala
@@ -0,0 +1,63 @@
+package scala.xml;
+
+/** prefixed attributes always have a non-null namespace
+ */
+class PrefixedAttribute(val pre: String, val key: String, val value: String, val next: MetaData) extends MetaData {
+
+ /** returns a copy of this unprefixed attribute with the given next field*/
+ def copy(next: MetaData) =
+ new PrefixedAttribute(pre, key, value, next);
+
+ //** duplicates the MetaData (deep copy), not preserving order */
+ //def deepCopy: MetaData = deepCopy(null);
+
+ //** duplicates the MetaData (deep copy), prepending it to tail */
+ /*
+ def deepCopy(tail:MetaData): MetaData = {
+ val md = copy(tail);
+ if(null == next)
+ md
+ else
+ next.deepCopy(md)
+ }
+ */
+
+ def equals1(m:MetaData) = m.isPrefixed && (m.asInstanceOf[PrefixedAttribute].pre == pre) && (m.key == key) && (m.value == value);
+
+ def getNamespace(owner: Node) =
+ owner.getNamespace(pre);
+
+ /** forwards the call to next */
+ def getValue(key: String): String = next.getValue(key);
+
+ /** gets attribute value of qualified (prefixed) attribute with given key
+ */
+ def getValue(namespace: String, scope: NamespaceBinding, key: String): String = {
+ if(key == this.key && scope.getURI(pre) == namespace)
+ value
+ else
+ next.getValue(namespace, scope, key);
+ }
+
+ /** returns true */
+ final def isPrefixed = true;
+
+ override def hashCode() =
+ pre.hashCode() * 41 + key.hashCode() * 7 + value.hashCode() * 3 + next.hashCode();
+
+
+ def toString1(sb:StringBuffer): Unit = {
+ sb.append(pre);
+ sb.append(':');
+ sb.append(key);
+ sb.append('=');
+ Utility.appendQuoted(value, sb);
+ }
+
+ def wellformed(scope: NamespaceBinding): Boolean = {
+ (null == next.getValue(scope.getURI(pre), scope, key)
+ && next.wellformed(scope));
+ }
+
+}
+
diff --git a/sources/scala/xml/UnprefixedAttribute.scala b/sources/scala/xml/UnprefixedAttribute.scala
new file mode 100644
index 0000000000..90081909a6
--- /dev/null
+++ b/sources/scala/xml/UnprefixedAttribute.scala
@@ -0,0 +1,44 @@
+package scala.xml;
+
+/** unprefixed attributes have the null namespace
+ */
+class UnprefixedAttribute(val key: String, val value: String, val next: MetaData) extends MetaData {
+
+ /** returns a copy of this unprefixed attribute with the given next field*/
+ def copy(next: MetaData) =
+ new UnprefixedAttribute(key, value, next);
+
+ def equals1(m:MetaData) = !m.isPrefixed && (m.key == key) && (m.value == value);
+
+ /** returns null */
+ final def getNamespace(owner: Node): String =
+ null;
+
+ /** gets value of unqualified (unprefixed) attribute with given key */
+ def getValue(key: String): String =
+ if(key == this.key)
+ value
+ else
+ next.getValue(key);
+
+ /** forwards the call to next */
+ def getValue(namespace: String, scope: NamespaceBinding, key: String): String =
+ next.getValue(namespace, scope, key);
+
+ override def hashCode() =
+ key.hashCode() * 7 + value.hashCode() * 53 + next.hashCode();
+
+ /** returns false */
+ final def isPrefixed = false;
+
+ def toString1(sb:StringBuffer): Unit = {
+ sb.append(key);
+ sb.append('=');
+ Utility.appendQuoted(value, sb);
+ }
+
+ def wellformed(scope: NamespaceBinding): Boolean =
+ (null == next.getValue(null, scope, key)) && next.wellformed(scope);
+
+}
+