You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2001/05/23 16:55:58 UTC

cvs commit: xml-cocoon2/src/org/apache/cocoon/transformation I18nTransformer.java I18nTransformer2.java

cziegeler    01/05/23 07:55:57

  Modified:    src/org/apache/cocoon/acting ResourceExistsAction.java
               src/org/apache/cocoon/environment Source.java
               src/org/apache/cocoon/transformation I18nTransformer.java
                        I18nTransformer2.java
  Log:
  Cleaned up Source interface for our cocoon: urls
  
  Revision  Changes    Path
  1.3       +3 -4      xml-cocoon2/src/org/apache/cocoon/acting/ResourceExistsAction.java
  
  Index: ResourceExistsAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/acting/ResourceExistsAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourceExistsAction.java	2001/05/22 14:31:10	1.2
  +++ ResourceExistsAction.java	2001/05/23 14:55:35	1.3
  @@ -7,8 +7,8 @@
    *****************************************************************************/
   package org.apache.cocoon.acting;
   
  +import java.io.InputStream;
   import java.io.IOException;
  -import java.net.URL;
   import java.util.Collections;
   import java.util.HashMap;
   import java.util.Map;
  @@ -34,7 +34,7 @@
    * null otherwise. It has only been tested with context urls.
    *
    * @author <a href="mailto:balld@apache.org">Donald Ball</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/05/22 14:31:10 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/05/23 14:55:35 $
    */
   public class ResourceExistsAction extends ComposerAction {
   
  @@ -42,8 +42,7 @@
           HashMap results = new HashMap();
           String urlstring = parameters.getParameter("url",null);
           try {
  -            URL url = resolver.resolve(urlstring).getURL();
  -            url.getContent();
  +            InputStream input = resolver.resolve(urlstring).getInputStream();
           } catch (Exception e) {
               getLogger().debug("ResourceExistsAction: exception: ",e);
               return null;
  
  
  
  1.2       +1 -18     xml-cocoon2/src/org/apache/cocoon/environment/Source.java
  
  Index: Source.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/environment/Source.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Source.java	2001/05/22 14:38:52	1.1
  +++ Source.java	2001/05/23 14:55:43	1.2
  @@ -24,7 +24,7 @@
    * for accessing any resource (URL, local file etc).
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/05/22 14:38:52 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/05/23 14:55:43 $
    */
   
   public final class Source {
  @@ -122,13 +122,6 @@
       }
   
       /**
  -     * Return the URL for this source.
  -     */
  -    public URL getURL() {
  -        return this.url;
  -    }
  -
  -    /**
        * Return an <code>Reader</code> object to read from the source.
        */
       public Reader getReader()
  @@ -168,15 +161,5 @@
           return null;
       }
   
  -    /**
  -     * If this is not a file this method returns the
  -     * <code>URLConnection</code> object for the url.
  -     */
  -    public URLConnection getURLConnection() {
  -        if (this.isFile == false) {
  -            return this.connection;
  -        }
  -        return null;
  -    }
   }
   
  
  
  
  1.5       +4 -16     xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer.java
  
  Index: I18nTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- I18nTransformer.java	2001/05/23 12:32:18	1.4
  +++ I18nTransformer.java	2001/05/23 14:55:49	1.5
  @@ -152,7 +152,7 @@
   
           this.source = source;
   
  -        initialiseDictionary(this.inputSource.getURL());
  +        initialiseDictionary();
       }
   
       /**
  @@ -325,26 +325,14 @@
       /**
        *Loads translations from given URL
        */
  -    private void initialiseDictionary(URL url)
  -            throws SAXException, MalformedURLException, IOException {
  -
  -        Object object = url.getContent();
  +    private void initialiseDictionary()
  +    throws SAXException, MalformedURLException, IOException {
           Parser parser = null;
   
           try
           {
               parser = (Parser)(manager.lookup(Roles.PARSER));
  -            InputSource input;
  -            if (object instanceof Loggable) {
  -                ((Loggable)object).setLogger(getLogger());
  -            }
  -            if (object instanceof Reader) {
  -                input = new InputSource(new BufferedReader((Reader)(object)));
  -            } else if (object instanceof InputStream) {
  -                input = new InputSource(new BufferedInputStream((InputStream)(object)));
  -            } else {
  -                throw new SAXException("Unknown object type: " + object);
  -            }
  +            InputSource input = new InputSource(this.inputSource.getReader());;
   
               // How this could be cached?
               dictionary = new Hashtable();
  
  
  
  1.4       +4 -15     xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer2.java
  
  Index: I18nTransformer2.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer2.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- I18nTransformer2.java	2001/05/23 12:32:18	1.3
  +++ I18nTransformer2.java	2001/05/23 14:55:51	1.4
  @@ -13,6 +13,7 @@
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.acting.LangSelect;
   import org.apache.cocoon.components.parser.Parser;
  +import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.SourceResolver;
   
   import org.apache.avalon.excalibur.pool.Poolable;
  @@ -208,8 +209,7 @@
   
           String translations_file = parameters.getParameter("src", null);
   
  -        URL tr = resolver.resolve(source).getURL();
  -        initialiseDictionary(tr);
  +        initialiseDictionary(resolver.resolve(source));
       }
   
   
  @@ -508,26 +508,15 @@
       /**
        *Loads translations from given URL
        */
  -    private void initialiseDictionary(URL url)
  +    private void initialiseDictionary(Source inputSource)
               throws SAXException, MalformedURLException, IOException {
   
  -        Object object = url.getContent();
           Parser parser = null;
   
           try
           {
               parser = (Parser)(manager.lookup(Roles.PARSER));
  -            InputSource input;
  -            if (object instanceof Loggable) {
  -                ((Loggable)object).setLogger(getLogger());
  -            }
  -            if (object instanceof Reader) {
  -                input = new InputSource(new BufferedReader((Reader)(object)));
  -            } else if (object instanceof InputStream) {
  -                input = new InputSource(new BufferedInputStream((InputStream)(object)));
  -            } else {
  -                throw new SAXException("Unknown object type: " + object);
  -            }
  +            InputSource input = new InputSource(inputSource.getReader());
   
               // How this could be cached?
               dictionary = new HashMap();
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org