cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/transformation TraxTransformer.java
Date Fri, 13 Apr 2001 18:19:33 GMT
dims        01/04/13 11:19:33

  Modified:    src/org/apache/cocoon/transformation Tag: xml-cocoon2
                        TraxTransformer.java
  Log:
  Updated TraxTransformer to use the new Browser component and
  populate the XSLT parameters.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.16  +42 -1     xml-cocoon/src/org/apache/cocoon/transformation/Attic/TraxTransformer.java
  
  Index: TraxTransformer.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/transformation/Attic/TraxTransformer.java,v
  retrieving revision 1.1.2.15
  retrieving revision 1.1.2.16
  diff -u -r1.1.2.15 -r1.1.2.16
  --- TraxTransformer.java	2001/04/13 16:02:27	1.1.2.15
  +++ TraxTransformer.java	2001/04/13 18:19:32	1.1.2.16
  @@ -13,6 +13,7 @@
   import java.util.Enumeration;
   import java.util.Map;
   import java.util.Hashtable;
  +import java.util.HashMap;
   import java.text.StringCharacterIterator;
   
   import java.lang.reflect.Method;
  @@ -35,6 +36,7 @@
   import org.apache.cocoon.Roles;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.store.Store;
  +import org.apache.cocoon.components.browser.Browser;
   import org.apache.cocoon.caching.Cacheable;
   import org.apache.cocoon.caching.CacheValidity;
   import org.apache.cocoon.caching.TimeStampCacheValidity;
  @@ -63,7 +65,7 @@
    *         (Apache Software Foundation, Exoffice Technologies)
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.1.2.15 $ $Date: 2001/04/13 16:02:27 $
  + * @version CVS $Revision: 1.1.2.16 $ $Date: 2001/04/13 18:19:32 $
    */
   public class TraxTransformer extends ContentHandlerWrapper
   implements Transformer, Composer, Recyclable, Configurable, Cacheable, Disposable {
  @@ -72,6 +74,9 @@
       /** The store service instance */
       private Store store = null;
   
  +    /** The Browser service instance */
  +    private Browser browser = null;
  +
       /** The trax TransformerFactory */
       private SAXTransformerFactory tfactory = (SAXTransformerFactory) TransformerFactory.newInstance();
   
  @@ -161,6 +166,7 @@
               this.manager = manager;
               log.debug("Looking up " + Roles.STORE);
               this.store = (Store) manager.lookup(Roles.STORE);
  +            this.browser = (Browser) manager.lookup(Roles.BROWSER);
           } catch (Exception e) {
               log.error("Could not find component", e);
           }
  @@ -267,6 +273,39 @@
               }
           }
   
  +        try
  +        {
  +            /* Get the accept header; it's needed to get the browser type. */
  +            String accept = request.getParameter("accept");
  +            if (accept == null)
  +                accept = request.getHeader("accept");
  +
  +            /* Get the user agent; it's needed to get the browser type. */
  +            String agent = request.getParameter("user-Agent");
  +            if (agent == null) 
  +                agent = request.getHeader("user-Agent");
  +            
  +            /* add the accept param */
  +            transformerHandler.getTransformer().setParameter("accept", accept);
  +
  +            /* add the user agent param */
  +            transformerHandler.getTransformer().setParameter("user-agent", java.net.URLEncoder.encode(agent));
  +
  +            /* add the map param */
  +            HashMap map = browser.getBrowser(agent, accept);
  +            transformerHandler.getTransformer().setParameter("browser",map);
  +
  +            /* add the media param */
  +            String browserMedia = browser.getMedia(map);
  +            transformerHandler.getTransformer().setParameter("browser-media",map);
  +
  +            /* add the uaCapabilities param */
  +            org.w3c.dom.Document uaCapabilities = browser.getUACapabilities(map);
  +            transformerHandler.getTransformer().setParameter("ua-capabilities", uaCapabilities);
  +        } catch (Exception e) {
  +            getLogger().error("Error setting Browser info", e);
  +        }    
  +
           super.setContentHandler(transformerHandler);
           if(transformerHandler instanceof Loggable) {
               ((Loggable)transformerHandler).setLogger(this.log);
  @@ -328,6 +367,8 @@
       {
           if(this.store != null)
               this.manager.release((Component)this.store);
  +        if(this.browser != null)
  +            this.manager.release((Component)this.browser);
       }
   
       public void recycle()
  
  
  

----------------------------------------------------------------------
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


Mime
View raw message