cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/java/org/apache/cocoon/transformation AugmentTransformer.java
Date Thu, 04 Sep 2003 14:49:03 GMT
cziegeler    2003/09/04 07:49:03

  Modified:    src/java/org/apache/cocoon/transformation
                        AugmentTransformer.java
  Log:
  Fixing releasing and code formatting
  
  Revision  Changes    Path
  1.3       +86 -83    cocoon-2.1/src/java/org/apache/cocoon/transformation/AugmentTransformer.java
  
  Index: AugmentTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/transformation/AugmentTransformer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AugmentTransformer.java	16 Mar 2003 17:49:15 -0000	1.2
  +++ AugmentTransformer.java	4 Sep 2003 14:49:03 -0000	1.3
  @@ -1,8 +1,8 @@
   package org.apache.cocoon.transformation;
   
  -import org.apache.avalon.excalibur.pool.Poolable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
  +import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.SourceResolver;
   import org.xml.sax.Attributes;
  @@ -29,92 +29,95 @@
    * @version CVS $Id$
    */
   public class AugmentTransformer
  -  extends AbstractTransformer
  -  implements Poolable
  -{
  -  Map objectModel;
  -  Request request;
  -  String baseURI;
  +    extends AbstractTransformer {
  +        
  +    protected Map objectModel;
  +    protected Request request;
  +    protected String baseURI;
     
  -  public void setup(SourceResolver resolver,
  -                    Map objectModel,
  -                    String source,
  -                    Parameters parameters)
  -    throws ProcessingException, SAXException, IOException
  -  {
  -    this.objectModel = objectModel;
  -    request = (Request)objectModel.get("request");
  -
  -    String mountPoint = (String)parameters.getParameter("mount", null);
  +    public void setup(SourceResolver resolver,
  +                      Map objectModel,
  +                      String source,
  +                      Parameters parameters)
  +    throws ProcessingException, SAXException, IOException {
  +        this.objectModel = objectModel;
  +        this.request = ObjectModelHelper.getRequest( this.objectModel );
       
  -    StringBuffer uribuf = new StringBuffer();
  -    boolean isSecure = request.isSecure();
  -    int port = request.getServerPort();
  -
  -    if (isSecure)
  -      uribuf.append("https://");
  -    else
  -      uribuf.append("http://");
  -
  -    uribuf.append(request.getServerName());
  -
  -    if (isSecure) {
  -      if (port != 443) {
  -        uribuf.append(":").append(port);
  -      }
  -    }
  -    else {
  -      if (port != 80) {
  -        uribuf.append(":").append(port);
  -      }
  -    }
  -    if (mountPoint == null) {
  -      String requestedURI = request.getRequestURI();
  -      requestedURI = requestedURI.substring(0, requestedURI.lastIndexOf("/"));
  -      uribuf.append(requestedURI);
  -      uribuf.append("/");
  -    }
  -    else {
  -      uribuf.append(request.getContextPath());
  -      uribuf.append("/");
  -      uribuf.append(mountPoint);
  +        String mountPoint = (String)parameters.getParameter("mount", null);
  +        
  +        StringBuffer uribuf = new StringBuffer();
  +        boolean isSecure = this.request.isSecure();
  +        int port = this.request.getServerPort();
  +    
  +        if (isSecure) {
  +            uribuf.append("https://");
  +        } else {
  +            uribuf.append("http://");
  +        }
  +        uribuf.append(request.getServerName());
  +    
  +        if (isSecure) {
  +            if (port != 443) {
  +                uribuf.append(":").append(port);
  +            }
  +        } else {
  +            if (port != 80) {
  +                uribuf.append(":").append(port);
  +            }
  +        }
  +        if (mountPoint == null) {
  +            String requestedURI = this.request.getRequestURI();
  +            requestedURI = requestedURI.substring(0, requestedURI.lastIndexOf("/"));
  +            uribuf.append(requestedURI);
  +            uribuf.append("/");
  +        } else {
  +            uribuf.append(request.getContextPath());
  +            uribuf.append("/");
  +            uribuf.append(mountPoint);
  +        }
  +        this.baseURI = uribuf.toString();
       }
  -    baseURI = uribuf.toString();
  -  }
   
  -  public void startElement(String uri,
  -                           String name,
  -                           String qname,
  -                           Attributes attrs)
  -    throws SAXException
  -  {
  -    AttributesImpl newAttrs = null;
  +    public void startElement(String uri,
  +                             String name,
  +                             String qname,
  +                             Attributes attrs)
  +    throws SAXException {
  +        AttributesImpl newAttrs = null;
       
  -    for (int i = 0, size = attrs.getLength(); i < size; i++) {
  -      String attrName = attrs.getLocalName(i);
  -      if (attrName.equals("href")) {
  -        String value = attrs.getValue(i);
  -
  -        // Don't touch the attribute if it's an absolute URL
  -        if (value.startsWith("http:") || value.startsWith("https:"))
  -          continue;
  -
  -        if (newAttrs == null)
  -          newAttrs = new AttributesImpl(attrs);
  -
  -        String newValue = baseURI + value;
  -        newAttrs.setValue(i, newValue);
  -      }
  +        for (int i = 0, size = attrs.getLength(); i < size; i++) {
  +            String attrName = attrs.getLocalName(i);
  +            if (attrName.equals("href")) {
  +                String value = attrs.getValue(i);
  +
  +                // Don't touch the attribute if it's an absolute URL
  +                if (value.startsWith("http:") || value.startsWith("https:")) {
  +                    continue;
  +                }
  +
  +                if (newAttrs == null) {
  +                    newAttrs = new AttributesImpl(attrs);
  +                }
  +
  +                String newValue = baseURI + value;
  +                newAttrs.setValue(i, newValue);
  +            }
  +        }
  +
  +        if (newAttrs == null) {
  +            super.startElement(uri, name, qname, attrs);
  +        } else {
  +            super.startElement(uri, name, qname, newAttrs);
  +        }
       }
   
  -    if (newAttrs == null)
  -      super.startElement(uri, name, qname, attrs);
  -    else
  -      super.startElement(uri, name, qname, newAttrs);
  -  }
  -
  -  public void recycle()
  -  {
  -    this.objectModel = null;
  -  }
  +    /**
  +     * Recyclable
  +     */
  +    public void recycle() {
  +        this.objectModel = null;
  +        this.request = null;
  +        this.baseURI = null;
  +        super.recycle();
  +    }
   }
  
  
  

Mime
View raw message