pnever 2004/01/09 10:43:51
Modified: src/share/org/apache/slide/common ScopeTokenizer.java
Log:
Let ScopeTokenizer know a SlideToken s.t. it can produce Uri instances knowing the
SlideToken
Revision Changes Path
1.5 +63 -50
jakarta-slide/src/share/org/apache/slide/common/ScopeTokenizer.java
Index: ScopeTokenizer.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/common/ScopeTokenizer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ScopeTokenizer.java 25 Apr 2002 21:30:12 -0000 1.4
+++ ScopeTokenizer.java 9 Jan 2004 18:43:51 -0000 1.5
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -23,15 +23,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Slide", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
@@ -59,7 +59,7 @@
*
* [Additional notices, if required by prior licensing conditions]
*
- */
+ */
package org.apache.slide.common;
@@ -80,7 +80,7 @@
* <li>/foo/bar
* <li>/foo
* <li>/
- *
+ *
* @see StringTokenizer
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
* @version $Revision$
@@ -93,16 +93,17 @@
/**
* Constructor.
- *
+ *
* @param uri Uri which needs to be tokenized in Scopes.
*/
- public ScopeTokenizer(Namespace namespace, String uri) {
+ public ScopeTokenizer(SlideToken slideToken, Namespace namespace, String uri) {
super(uri, "/");
// We then build the scopes.
scopes = new Vector();
// Initializing namespace
+ this.slideToken = slideToken;
this.namespace = namespace;
String courScope = new String();
@@ -121,12 +122,23 @@
/**
* Constructor.
- *
- * @param namespace
- * @param scope
+ *
+ * @param namespace
+ * @param uri
+ */
+ public ScopeTokenizer(Namespace namespace, String uri) {
+ this(null, namespace, uri);
+ }
+
+
+ /**
+ * Constructor.
+ *
+ * @param namespace
+ * @param scope
*/
public ScopeTokenizer(Namespace namespace, Scope scope) {
- this(namespace, scope.toString());
+ this(null, namespace, scope.toString());
}
@@ -149,6 +161,7 @@
* Namespace.
*/
Namespace namespace;
+ SlideToken slideToken;
// --------------------------------------------------------- Public Methods
@@ -156,21 +169,21 @@
/**
* Get the parent Uri of the top level scope.
- *
+ *
* @return Uri Parent Uri
*/
public Uri getParentUri() {
if (scopes.size() <= 1) {
return null;
} else {
- return namespace.getUri((String) scopes.elementAt(1));
+ return namespace.getUri(slideToken, (String) scopes.elementAt(1));
}
}
/**
* True if the ScopeTokenizer contains additional scopes.
- *
+ *
* @return boolean
*/
public boolean hasMoreElements() {
@@ -180,7 +193,7 @@
/**
* True if the ScopeTokenizer contains additional scopes.
- *
+ *
* @return boolean
*/
public boolean hasMoreTokens() {
@@ -190,70 +203,70 @@
/**
* Returns the next Scope as an Object.
- *
+ *
* @return Object
* @exception NoSuchElementException
*/
- public Object nextElement()
- throws NoSuchElementException {
- Object obj = null;
- try {
- if (!hasMoreElements()) {
- throw new NoSuchElementException();
- }
- obj = scopes.elementAt(pos);
- pos = pos + 1;
- } catch (ArrayIndexOutOfBoundsException e) {
- // Should NEVER happen.
- e.printStackTrace();
- }
- return obj;
+ public Object nextElement()
+ throws NoSuchElementException {
+ Object obj = null;
+ try {
+ if (!hasMoreElements()) {
+ throw new NoSuchElementException();
+ }
+ obj = scopes.elementAt(pos);
+ pos = pos + 1;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Should NEVER happen.
+ e.printStackTrace();
+ }
+ return obj;
}
/**
* Returns the next Scope as a String object.
- *
+ *
* @return String
* @exception NoSuchElementException
*/
public String nextToken()
- throws NoSuchElementException {
- return (String) nextElement();
+ throws NoSuchElementException {
+ return (String) nextElement();
}
/**
* Returns the next Scope as a Scope object.
- *
+ *
* @return Scope
* @exception NoSuchElementException
*/
public Scope nextScope()
- throws NoSuchElementException {
- return new Scope(nextToken());
+ throws NoSuchElementException {
+ return new Scope(nextToken());
}
/**
* Returns the next Scope as a String object.
- *
+ *
* @param delim
* @exception NoSuchElementException
*/
- public String nextToken(String delim)
- throws NoSuchElementException {
- return nextToken();
+ public String nextToken(String delim)
+ throws NoSuchElementException {
+ return nextToken();
}
/**
* Returns the scopes.
- *
- * @return Enumeration
+ *
+ * @return Enumeration
*/
public Enumeration elements() {
- return scopes.elements();
+ return scopes.elements();
}
@@ -262,7 +275,7 @@
/**
* Get the parsed uri.
- *
+ *
* @return String Uri
*/
String getUri() {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]