jakarta-slide-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pne...@apache.org
Subject cvs commit: jakarta-slide/src/share/org/apache/slide/structure StructureImpl.java
Date Tue, 06 Jan 2004 15:45:13 GMT
pnever      2004/01/06 07:45:13

  Modified:    src/share/org/apache/slide/common UriTokenizer.java
               src/share/org/apache/slide/structure StructureImpl.java
  Log:
  Let UriTokenizer know a SlideToken s.t. it can produce Uri instances knowing the SlideToken
  
  Revision  Changes    Path
  1.5       +61 -48    jakarta-slide/src/share/org/apache/slide/common/UriTokenizer.java
  
  Index: UriTokenizer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/UriTokenizer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- UriTokenizer.java	25 Apr 2002 21:15:10 -0000	1.4
  +++ UriTokenizer.java	6 Jan 2004 15:45:13 -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 apache@apache.org.
    *
    * 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;
   
  @@ -71,7 +71,7 @@
    * Tokenizes a scope.
    * <p/>
    * This tokenizer derives from StringTokenizer and tokenizes an Uri.
  - * This object is used for browsing down the main tree from the root 
  + * This object is used for browsing down the main tree from the root
    * element during retrieval and create operations.
    * <p/>
    * Ex : the uri /foo/bar/bar.txt will be tokenized in the following tokens :
  @@ -91,17 +91,17 @@
       
       /**
        * Constructor.
  -     * 
  +     *
        * @param namespace
        * @param uri
        */
  -    public UriTokenizer(Namespace namespace, String uri) {
  +    public UriTokenizer(SlideToken slideToken, Namespace namespace, String uri) {
           super(uri, "/");
           
           // We then build the scopes.
           uris = new Vector();
           
  -        // Storing namespace
  +        this.slideToken = slideToken;
           this.namespace = namespace;
           
           String courScope = new String();
  @@ -120,12 +120,23 @@
       
       /**
        * Constructor.
  -     * 
  -     * @param namespace 
  -     * @param scope 
  +     *
  +     * @param namespace
  +     * @param scope
  +     */
  +    public UriTokenizer(Namespace namespace, String uri) {
  +        this(null, namespace, uri);
  +    }
  +    
  +    
  +    /**
  +     * Constructor.
  +     *
  +     * @param namespace
  +     * @param scope
        */
       public UriTokenizer(Namespace namespace, Scope scope) {
  -        this(namespace, scope.toString());
  +        this(null, namespace, scope.toString());
       }
       
       
  @@ -149,27 +160,29 @@
        */
       Namespace namespace;
       
  +    SlideToken slideToken;
  +    
       
       // --------------------------------------------------------- Public Methods
       
       
       /**
        * Get the parent uri.
  -     * 
  +     *
        * @return Uri
        */
       public Uri getParentUri() {
           if (uris.size() < 1) {
               return null;
           } else {
  -            return namespace.getUri((String) uris.elementAt(uris.size() - 1));
  +            return namespace.getUri(slideToken, (String) uris.elementAt(uris.size() - 1));
           }
       }
       
       
       /**
        * True if the UriTokenizer contains additional scopes.
  -     * 
  +     *
        * @return boolean
        */
       public boolean hasMoreElements() {
  @@ -179,70 +192,70 @@
       
       /**
        * True if the UriTokenizer contains additional scopes.
  -     * 
  +     *
        * @return boolean
        */
       public boolean hasMoreTokens() {
  -	return hasMoreElements();
  +    return hasMoreElements();
       }
       
       
       /**
        * Returns the next Uri as an Object.
  -     * 
  +     *
        * @return Object
        * @exception NoSuchElementException
        */
  -    public Object nextElement() 
  -	throws NoSuchElementException {
  -	Object obj = null;
  -	try {
  -	    if (!hasMoreElements()) {
  -		throw new NoSuchElementException();
  -	    }
  -	    obj = uris.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 = uris.elementAt(pos);
  +        pos = pos + 1;
  +    } catch (ArrayIndexOutOfBoundsException e) {
  +        // Should NEVER happen.
  +        e.printStackTrace();
  +    }
  +    return obj;
       }
       
       
       /**
        * Returns the next Uri as a String object.
  -     * 
  +     *
        * @return String
        * @exception NoSuchElementException
        */
       public String nextToken()
  -	throws NoSuchElementException {
  -	return (String) nextElement();
  +    throws NoSuchElementException {
  +    return (String) nextElement();
       }
       
       
       /**
        * Returns the next Uri as an Uri object.
  -     * 
  +     *
        * @return Uri
        * @exception NoSuchElementException
        */
       public Uri nextUri()
  -	throws NoSuchElementException {
  -	return namespace.getUri(nextToken());
  +    throws NoSuchElementException {
  +    return namespace.getUri(slideToken, nextToken());
       }
       
       
       /**
        * Returns the next Uri as an Uri object.
  -     * 
  +     *
        * @param delim
        * @exception NoSuchElementException
        */
  -    public String nextToken(String delim) 
  -	throws NoSuchElementException {
  -	return nextToken();
  +    public String nextToken(String delim)
  +    throws NoSuchElementException {
  +    return nextToken();
       }
       
   }
  
  
  
  1.37      +8 -8      jakarta-slide/src/share/org/apache/slide/structure/StructureImpl.java
  
  Index: StructureImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/structure/StructureImpl.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- StructureImpl.java	12 Dec 2003 02:48:30 -0000	1.36
  +++ StructureImpl.java	6 Jan 2004 15:45:13 -0000	1.37
  @@ -217,7 +217,7 @@
               String resolvedUri = uri.toString();
               
               // 1 - Tokemization of the Uri
  -            UriTokenizer uriTokenizer = new UriTokenizer(uri.getNamespace(),
  +            UriTokenizer uriTokenizer = new UriTokenizer(token, uri.getNamespace(),
                                                            resolvedUri);
               
               // 2 - For each element of the Uri
  @@ -258,7 +258,7 @@
                           + resolvedUri.substring(courStrUri.length());
                       
                       // 7 - We tokenize again the uri
  -                    uriTokenizer = new UriTokenizer(uri.getNamespace(),
  +                    uriTokenizer = new UriTokenizer(token, uri.getNamespace(),
                                                       resolvedUri);
                       
                       // 8 - We parse it till we get back to the point
  @@ -314,7 +314,7 @@
           String resolvedUri = strUri;
           
           // 1 - Tokenization of the Uri
  -        UriTokenizer uriTokenizer = new UriTokenizer(namespace, resolvedUri);
  +        UriTokenizer uriTokenizer = new UriTokenizer(token, namespace, resolvedUri);
           
           // 2 - For each element of the Uri
           Uri courUri = null;
  @@ -411,7 +411,7 @@
                       + resolvedUri.substring(courStrUri.length());
                   
                   // 7 - We tokenize again the uri
  -                uriTokenizer = new UriTokenizer(namespace, resolvedUri);
  +                uriTokenizer = new UriTokenizer(token, namespace, resolvedUri);
                   
                   // 8 - We parse it till we get back to the point
                   // where we stopped
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org


Mime
View raw message