incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r425276 [2/12] - in /incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src: main/java/org/apache/myfaces/adfinternal/agent/ main/java/org/apache/myfaces/adfinternal/agent/parse/ main/java/org/apache/myfaces/adfi...
Date Tue, 25 Jul 2006 04:42:46 GMT
Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentFactoryImpl.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentFactoryImpl.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentFactoryImpl.java Mon Jul 24 21:42:41 2006
@@ -13,703 +13,703 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adfinternal.agent;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.myfaces.adf.context.Agent;
-
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.adf.logging.ADFLogger;
-
-
-/**
- * ADF implementation of AgentFactory.
- */
-public class AgentFactoryImpl implements AgentFactory
-{
-  /**
-   * @param facesContext
-   * @return
-   */
-
-  public Agent createAgent(String userAgent, String accept)
-  {
-    AgentImpl agent = new AgentImpl();
-    _populateAgentImpl(userAgent,accept,agent);
-    return agent;
-  }
-
-  public Agent createAgent(FacesContext facesContext)
-  {
-    AgentImpl agent = new AgentImpl();
-
-    Map headerMap;
-    if (facesContext != null)
-    {
-      headerMap = facesContext.getExternalContext().getRequestHeaderMap();
-    }
-    else
-    {
-      headerMap = Collections.EMPTY_MAP;
-    }
-
-    //TODO: Add declarative and extensible means for populating AgentImpl object
-    _populateAgentImpl(headerMap, agent);
-
-    return agent;
-  }
-
-
-  private void _populateAgentImpl(Map headerMap, AgentImpl agent)
-  {
-    String userAgent = (String) headerMap.get("User-Agent");
-
-    if ((userAgent != null) && userAgent.startsWith("PTG"))
-    {
-      _populateIaswAgentImpl(userAgent,
-                             (String) headerMap.get(_IASW_DEVICE_HINT_PARAM),agent);
-      return;
-    }
-
-    // determine the agent from the headers
-    _populateAgentImpl(userAgent, (String) headerMap.get("Accept"),agent);
-  }
-
-  private void _populateAgentImpl(String userAgent, String accept,AgentImpl agent)
-  {
-    /* for testing PocketPC */
-
-    //PPC 02
-    //userAgent = "Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; PPC; 240x320)";
-    // PPC 03
-    //userAgent = "Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)";
-    // Web Pro
-    //userAgent = "Mozilla/4.76 (compatible; MSIE 6.0; U; Windows 95; PalmSource; PalmOS; WebPro; Tungsten Proxyless 1.1 320x320x16)";
-    // See if the agent wants WML - if so, we're talking WAP.
-    if ((accept != null) &&
-        accept.regionMatches(true, 0, "vnd.wap.wml", 0, 11))
-    {
-      _populateWAPAgentImpl(agent);
-      return;
-    }
-
-    if (userAgent == null)
-    {
-      _populateNullAgentImpl(userAgent, agent);
-      return;
-    }
-    //the useragent string for telnet and PDA design time will start with
-    //OracleJDevMobile because in each of these cases we know we have an
-    //exact match in the device repository for the agent name.  This is
-    //because the jdev design time and ITS runtime have access to the same
-    //device repository as the ADF runtime
-    //The PDA DT useragent string will be: OracleJDevMobile/PDA/[agentName]
-    //The telnet DT and RT useragent string will be:
-    //OracleJDevMobile/ITS/[agentName]
-    if (userAgent.startsWith("OracleJDevMobile"))
-    {
-      _populateJDevMobileAgentImpl(userAgent,agent);
-      return;
-    }
-    if (userAgent.startsWith("OracleITS"))
-    {
-      _populateTelnetAgentImpl(userAgent,agent);
-      return;
-    }
-    if (userAgent.startsWith("Pixo-Browser"))
-    {
-       _populatePixoAgentImpl(userAgent,agent);
-       return;
-    }
-
-    if (userAgent.startsWith("ICE Browser"))
-    {
-       _populateIceAgentImpl(userAgent,agent);
-       return;
-    }
-
-    // I need to search for more than just "WebPro" because ie's header can be
-    // altered to include "FunWebProducts" in which case ie desktop was being
-    // mapped to a pda
-    // see bug 3362116
-    if (userAgent.indexOf("NetFront/3.") != -1)
-    {
-      _populateNetFrontAgentImpl(userAgent,agent);
-      return;
-    }
-
-    if ( (userAgent.indexOf( "WebPro") != -1 &&
-          userAgent.indexOf("Palm")!= -1)||
-         userAgent.indexOf("Blazer/3.") != -1)
-    {
-      _populatePalmWebBrowserProAgentImpl(userAgent,agent);
-      return;
-    }
-
-/*  //Commenting - Confirm this pattern fornBlazer before uncommenting
-    //and remove the Blazer 3.0 check in the previous if
-    if (((userAgent.indexOf("Blazer/4.") != -1) ||
-        (userAgent.indexOf("Blazer 3.") != -1)) &&
-        ((userAgent.indexOf("Palm") != -1)))
-    {
-      return _getPalmBlazerAgentEntry(userAgent);
-    }
-*/
-
-    if (userAgent.indexOf("Windows CE") != -1)
-    {
-      _populatePocketPCAgentImpl(userAgent,agent);
-      return;
-    }
-
-    // This needs to be before check for mozilla!
-    if ((userAgent.indexOf("PalmOS") != -1) ||
-        (userAgent.indexOf("Blazer") != -1) ||
-        (userAgent.indexOf("Xiino") != -1))
-    {
-      _populatePalmAgentImpl(userAgent,agent);
-      return;
-    }
-
-    if ((userAgent.indexOf("AppleWebKit") != -1) ||
-        (userAgent.indexOf("Safari") != -1))
-    {
-      _populateSafariAgentImpl(userAgent,agent);
-      return;
-    }
-
-    if (userAgent.indexOf("Gecko/") != -1)
-    {
-      _populateGeckoAgentImpl(userAgent,agent);
-      return;
-    }
-    // must check for gecko before checking for mozilla:
-    else if (userAgent.startsWith("Mozilla"))
-    {
-      _populateMozillaAgentImpl(userAgent,agent);
-      return;
-    }
-
-    _populateNullAgentImpl(userAgent, agent);
-  }
-
-  private void _populateNullAgentImpl(String userAgent, AgentImpl agent)
-  {
-    // Log warning message that we are setting the agent entry to null
-    _LOG.warning(
-      "The User-Agent \"{0}\" is unknown;"+
-      " creating an agent with null agent attributes.", userAgent);
-    agent.setAgentEntryToNULL();
-  }
-
-  //populates the agent entry for DT access for either Telnet or PDA
-  //for jdev mobile there are two user agent strings possible:
-  //1. OracleJDevMobile_PDA(DeviceName:[name of device])
-  //2. OracleJDevMobile_ITS(DeviceName:[name of device])
-  private void _populateJDevMobileAgentImpl(String agent,AgentImpl agentObj)
-  {
-    //the form of JDEVMobile user agent string will be:
-    //OracleJDevMobile_[PDA or ITS]/[version](DeviceName:[device name];[capability1]:[capability 1 value];...)
-
-    boolean returnNullAgentObj = false;
-    int itsIndex = agent.indexOf("ITS");
-    int pdaIndex = agent.indexOf("PDA");
-    int versionStartIndex = -1;
-    if (itsIndex > -1)
-    {
-      agentObj.setType(Agent.TYPE_TELNET);
-      versionStartIndex = "OracleJDevMobile_ITS".length()+1;
-    }
-    else
-      if (pdaIndex > -1)
-    {
-
-      agentObj.setType(Agent.TYPE_PDA);
-      versionStartIndex = "OracleJDevMobile_PDA".length()+1;
-    }
-    else
-    {
-      returnNullAgentObj = true;
-    }
-    //Now find the name of the device
-    if (!returnNullAgentObj){
-      int versionEndIndex = agent.indexOf("(");
-      String version = agent.substring(versionStartIndex,versionEndIndex);
-      agentObj.setAgentVersion(version);
-      //parse agentName
-      int agentNameStartIndex = agent.indexOf(":",versionEndIndex) +1;
-      //find end of agentName (ie. when we see a semicolon
-      int agentNameEndIndex = agentNameStartIndex;
-      for (;agent.charAt(agentNameEndIndex)!=';' &&
-          agent.charAt(agentNameEndIndex) !=')';
-          agentNameEndIndex++);
-      String agentName = agent.substring(agentNameStartIndex,agentNameEndIndex);
-      agentObj.setAgent(agentName);
-      if (agent.charAt(agentNameEndIndex) == ')')
-        return;
-      //now parse remaining request specific capabilities
-      int capabilityNameStartIndex;
-      int capabilityNameEndIndex;
-      int capabilityValueStartIndex;
-      int capabilityValueEndIndex = agentNameEndIndex;
-      while(agent.charAt(capabilityValueEndIndex)!= ')')
-      {
-        capabilityNameStartIndex = capabilityValueEndIndex + 1;
-        capabilityNameEndIndex = agent.indexOf(":",capabilityNameStartIndex);
-        String capabilityName = agent.substring(capabilityNameStartIndex,capabilityNameEndIndex);
-        capabilityValueStartIndex = capabilityNameEndIndex +1;
-        capabilityValueEndIndex = agent.indexOf(";",capabilityValueStartIndex);
-        if (capabilityValueEndIndex == -1)
-        {
-          capabilityValueEndIndex = agent.indexOf(")",capabilityValueEndIndex);
-        }
-        String capabilityValue = agent.substring(capabilityValueStartIndex,capabilityValueEndIndex);
-        agentObj.__addRequestCapability(CapabilityKey.getCapabilityKey(capabilityName,true),capabilityValue);
-      }
-    }
-    if (returnNullAgentObj)
-    {
-      _populateNullAgentImpl(agent, agentObj);
-    }
-  }
-
-  private void _populateTelnetAgentImpl(String agent,AgentImpl agentObj)
-  {
-    //the form of an ITS user agent will be
-    //OracleITS/[version](DeviceName:[device name];[capability1]:[capability 1 value];...)
-    agentObj.setType(Agent.TYPE_TELNET);
-    int versionStartIndex = "OracleITS".length() +1;
-    int versionEndIndex = agent.indexOf("(");
-    String version = agent.substring(versionStartIndex,versionEndIndex);
-    agentObj.setAgentVersion(version);
-    //parse agentName
-    int agentNameStartIndex = agent.indexOf(":",versionEndIndex) +1;
-    //find end of agentName (ie. when we see a semicolon
-    int agentNameEndIndex = agentNameStartIndex;
-    for (;agent.charAt(agentNameEndIndex)!=';' &&
-          agent.charAt(agentNameEndIndex) !=')';
-          agentNameEndIndex++);
-    String agentName = agent.substring(agentNameStartIndex,agentNameEndIndex);
-    agentObj.setAgent(agentName);
-    if (agent.charAt(agentNameEndIndex) == ')')
-      return;
-    //now parse remaining request specific capabilities
-    int capabilityNameStartIndex;
-    int capabilityNameEndIndex;
-    int capabilityValueStartIndex;
-    int capabilityValueEndIndex = agentNameEndIndex;
-    while(agent.charAt(capabilityValueEndIndex)!= ')')
-    {
-      capabilityNameStartIndex = capabilityValueEndIndex + 1;
-      capabilityNameEndIndex = agent.indexOf(":",capabilityNameStartIndex);
-      String capabilityName = agent.substring(capabilityNameStartIndex,capabilityNameEndIndex);
-      capabilityValueStartIndex = capabilityNameEndIndex +1;
-      capabilityValueEndIndex = agent.indexOf(";",capabilityValueStartIndex);
-      if (capabilityValueEndIndex == -1)
-      {
-        capabilityValueEndIndex = agent.indexOf(")",capabilityValueEndIndex);
-      }
-      String capabilityValue = agent.substring(capabilityValueStartIndex,capabilityValueEndIndex);
-      agentObj.__addRequestCapability(CapabilityKey.getCapabilityKey(capabilityName,true),capabilityValue);
-    }
-  }
-
-  /**
-   * populates data from a PocketPC IE request
-   */
-  private void _populatePocketPCAgentImpl(String agent,AgentImpl agentObj)
-  {
-    int start = agent.indexOf("MSIE");
-    String version = null;
-
-    if (start > -1)
-    {
-      version = _getVersion(agent, start + "MSIE".length());
-    }
-    agentObj.setType(Agent.TYPE_PDA);
-    agentObj.setAgent(Agent.AGENT_IE);
-    agentObj.setAgentVersion(version);
-    agentObj.setPlatform(Agent.PLATFORM_PPC);
-  }
-
-  /**
-   * returns the data for the Palm NetFront browser request
-   */
-  private void _populateNetFrontAgentImpl(String agent, AgentImpl agentObj)
-  {
-    agentObj.setType(Agent.TYPE_PDA);
-    agentObj.setAgent(AdfFacesAgent.AGENT_NETFRONT);
-
-    int start = agent.indexOf("NetFront/");
-
-    if (start > -1)
-    {
-      agentObj.setAgentVersion(_getVersion(agent, start + 8));
-    }
-
-    int paren = agent.indexOf('(');
-
-    if (paren >= 0)
-    {
-      // try to determine the OS
-      if (agent.indexOf("Windows CE", paren) > 0)
-      {
-        agentObj.setPlatform(Agent.PLATFORM_PPC);
-      }
-/*
-      //Embedded Linux is not be same as Linux
-      //so leave it as unknown
-      else if (agent.indexOf("Embedix", paren) > 0)
-      {
-        entry._platform = Agent.PLATFORM_LINUX;
-      }
-*/
-      else if (agent.indexOf("Palm", paren) > 0)
-      {
-        agentObj.setPlatform(Agent.PLATFORM_PALM);
-      }
-    }
-
-  }
-
-  /**
-   * returns the data for the Palm Web Pro browser request
-   */
-  private void _populatePalmWebBrowserProAgentImpl(String agent,AgentImpl agentObj)
-  {
-    agentObj.setType(Agent.TYPE_PDA);
-    agentObj.setAgent(AdfFacesAgent.AGENT_WEBPRO);
-
-    int start = agent.indexOf("WebPro/");
-
-    if (start > -1)
-    {
-      agentObj.setAgentVersion(_getVersion(agent, start + 6));
-    }
-
-    agentObj.setPlatform(Agent.PLATFORM_PALM);
-
-  }
-
-  /**
-   * returns the data for the Palm blazer browser request
-   */
-/* //comment for now
-  private AgentEntry _getPalmBlazerAgentEntry(String agent)
-  {
-    AgentEntry entry = new AgentEntry();
-    entry._type = TYPE_PDA;
-    entry._agent = AdfFacesAgent.AGENT_BLAZER;
-
-    //balzer 3 has "Blazer 3..." and 4.0 has Blazer 4/....
-    int start = agent.indexOf("Blazer");
-
-    if (start > -1)
-    {
-      entry._agentVersion = _getVersion(agent, start + 6);
-    }
-
-    entry._platform = Agent.PLATFORM_PALM;
-
-    return entry;
-  }
-*/
-
-  /**
-   * returns the AgentEntry for ias wireless
-   */
-  private void _populateIaswAgentImpl(String agent, String wirelessType,AgentImpl agentObj)
-  {
-    // map device hint to agent type
-    if (wirelessType == null)
-    {
-      _populateNullAgentImpl(agent, agentObj);
-      return;
-    }
-
-    String version = _getVersion(agent, agent.indexOf('/'));
-    agentObj.setType(Agent.TYPE_PHONE);
-    agentObj.setAgent(AdfFacesAgent.AGENT_PTG);
-    agentObj.setAgentVersion(version);
-  }
-
-  /**
-   * returns the AgentEntry for the Palm
-   */
-  private void _populatePalmAgentImpl(String userAgent,AgentImpl agentObj)
-  {
-    agentObj.setType(Agent.TYPE_PDA);
-
-    if (userAgent.indexOf("Blazer") != -1)
-      agentObj.setAgent(AdfFacesAgent.AGENT_BLAZER);
-    else if (userAgent.indexOf("Xiino") != -1)
-      agentObj.setAgent(AdfFacesAgent.AGENT_XIINO);
-
-    agentObj.setPlatform(Agent.PLATFORM_PALM);
-
-  }
-
-  /**
-   * returns the AgentEntry for the Ice brwoser
-   */
-  private void _populateIceAgentImpl(String agent,AgentImpl agentObj)
-  {
-    int slashIndex = agent.indexOf('/');
-    agentObj.setType(Agent.TYPE_DESKTOP);
-    agentObj.setAgent(AdfFacesAgent.AGENT_ICE_BROWSER);
-    agentObj.setAgentVersion(_getVersion(agent, slashIndex));
-    agentObj.setPlatform(_getJavaOS(agent, slashIndex));
-  }
-
-  /**
-   * returns the AgentEntry for the Pixo Microbrowser
-   */
-  private void  _populatePixoAgentImpl(String agent,AgentImpl agentObj)
-  {
-    agentObj.setType(Agent.TYPE_PHONE);
-    agentObj.setAgent(AdfFacesAgent.AGENT_PIXO);
-    agentObj.setAgentVersion(_getVersion(agent, agent.indexOf('/')));
-  }
-
-  /**
-   * Returns an AgentEntry for a WML client.
-   */
-  private void _populateWAPAgentImpl(AgentImpl agentObj)
-  {
-    //TODO: Add generic wmlbrowser when wml browsers are supported
-    // Generic WML support
-    agentObj.setType(Agent.TYPE_PHONE);
-  }
-
-  /**
-   * Returns an AgentEntry for the browsers that use the Gecko Layout Engine.
-   */
-  private void _populateGeckoAgentImpl(String agent,AgentImpl agentObj)
-  {
-   //Identifying an Gecko Based agent as Gecko (and not Mozilla, Netscape, Firefox)
-    //could be an issue
-    //E.g User-Agent String
-    //Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
-    //For Gecko based agents
-    //    - Gecko uses Date string as a version number
-    //    - Mozilla uses the revision number as the version number rv:x.x.x
-    //    - Each vendor has a version number (like firefox/1.0,  Netscape/7.0)
-    // Mozilla revision : Gecko Version
-    //           1.0.1  : 20020826
-    //           1.1    : 20020826
-    //           1.2.1  : 20021130
-
-    //Currently (in UIX 2.2 base agent Impl)
-    //  - All Gecko Based agents are identified as Gecko
-    //  - But PPR capability is determined is based on the Mozilla version number (rv:x.x.x)
-    //  - For Major version , for Gecko, always "1" is returned
-    //so stricly speaking all capabilities are not based on the layout engine.
-
-    //New Impl.
-    //  - Still using Gecko as the identifier for all gecko based agents
-    //  - Still returning date string as version number of Gecko. But this can get messy to use
-    //    by the applications. The version number could change everyday and may not be the same for
-    //    different platforms.  (An alternate option is to return version number of Mozilla
-    //    that would be equivalent to current browser for Gecko-based browsers)
-    //  - But assumes PPR Support in all Gecko versions.
-
-    agentObj.setType(Agent.TYPE_DESKTOP);
-    agentObj.setAgent(Agent.AGENT_GECKO);
-
-    int geckoIndex = agent.indexOf("Gecko/");
-    agentObj.setAgentVersion(agent.substring(geckoIndex+6, // skip over 'Gecko/'
-            geckoIndex+14)); // always 8 chars length
-
-    //int start = agent.indexOf("rv:");
-    //entry._agentVersion = _getVersion(agent, start + 2);
-
-    int paren = agent.indexOf('(');
-
-    if (paren >= 0)
-    {
-      // try to determine the OS
-      if (agent.indexOf("Win", paren) > 0)
-      {
-        agentObj.setPlatform(Agent.PLATFORM_WINDOWS);
-      }
-      else if (agent.indexOf("Mac", paren) > 0)
-      {
-        agentObj.setPlatform(Agent.PLATFORM_MAC);
-      }
-      else if (agent.indexOf("Linux", paren) > 0)
-      {
-        agentObj.setPlatform(Agent.PLATFORM_LINUX);
-      }
-      else if (agent.indexOf("Sun", paren) > 0)
-      {
-        agentObj.setPlatform(Agent.PLATFORM_SOLARIS);
-      }
-    }
-  }
-
-  /**
-   * returns the AgentEntry for Safari
-   */
-  private void  _populateSafariAgentImpl(String agent, AgentImpl agentObj)
-  {
-    int start = agent.indexOf("AppleWebKit");
-
-    if (start < 0)
-    {
-      start = agent.indexOf("Safari");
-    }
-
-    if (start >= 0)
-    {
-      start = agent.indexOf('/', start);
-    }
-
-    String version = _getVersion(agent, start);
-    agentObj.setType(Agent.TYPE_DESKTOP);
-    agentObj.setAgent(Agent.AGENT_WEBKIT);
-    agentObj.setAgentVersion(version);
-    agentObj.setPlatform(Agent.PLATFORM_MAC);
-  }
-
-  /**
-   * Returns an AgentEntry for the "Mozilla" family of browsers - which
-   * most at least pretend to be.
-   */
-  private void _populateMozillaAgentImpl(String agent,AgentImpl agentObj)
-  {
-    int paren = agent.indexOf('(');
-    agentObj.setType(Agent.TYPE_DESKTOP); //Is this default realli okay??? These days Mobile agents also use Mozilla/xx.xx
-
-    // No section to qualify the agent;  assume Mozilla/Netscape
-    if (paren == -1)
-    {
-      agentObj.setAgent(AdfFacesAgent.AGENT_NETSCAPE);
-      agentObj.setAgentVersion(_getVersion(agent, agent.indexOf('/')));
-    }
-    else
-    {
-      paren = paren + 1;
-
-      boolean isJDevVE = agent.indexOf("JDeveloper", paren) > 0;
-      boolean isJDevJSVE = agent.indexOf("JDeveloper JS", paren) > 0;
-
-      if (agent.startsWith("compatible", paren))
-      {
-        int ieIndex = agent.indexOf("MSIE", paren);
-
-        if (ieIndex < 0)
-        {
-          // check for Palm
-          int palmIndex = agent.indexOf("Elaine", paren);
-
-          if (palmIndex > 0)
-          {
-            agentObj.setType(Agent.TYPE_PDA);
-            agentObj.setAgent(AdfFacesAgent.AGENT_ELAINE);
-            agentObj.setAgentVersion(_getVersion(agent, palmIndex));
-            agentObj.setPlatform(Agent.PLATFORM_PALM);
-          }
-        }
-        else
-        {
-          agentObj.setAgent(Agent.AGENT_IE);
-          agentObj.setAgentVersion(_getVersion(agent, ieIndex + 4));
-        }
-      }
-      else
-      {
-        agentObj.setAgent(AdfFacesAgent.AGENT_NETSCAPE);
-        agentObj.setAgentVersion(_getVersion(agent, agent.indexOf('/')));
-      }
-
-      // try to determine the OS, if unknown
-      if (agentObj.getPlatformName() == null)
-      {
-        // Hack: treat the JDeveloper agent as Windows,
-        // so that we assume IE 6.0 Windows capabilities
-        if ((agent.indexOf("Win", paren) > 0) || isJDevVE)
-        {
-          agentObj.setPlatform(Agent.PLATFORM_WINDOWS);
-        }
-        else if (agent.indexOf("Mac", paren) > 0)
-        {
-          agentObj.setPlatform(Agent.PLATFORM_MAC);
-        }
-        else if (agent.indexOf("Linux", paren) > 0)
-        {
-          agentObj.setPlatform(Agent.PLATFORM_LINUX);
-        }
-        else if (agent.indexOf("Sun", paren) > 0)
-        {
-          agentObj.setPlatform(Agent.PLATFORM_SOLARIS);
-        }
-      }
-
-      if (isJDevVE)
-      {
-        agentObj.__addRequestCapability(AdfFacesAgent.CAP_IS_JDEV_VE,
-                                        Boolean.TRUE);
-        if (isJDevJSVE)
-        {
-          agentObj.__addRequestCapability(AdfFacesAgent.CAP_IS_JDEV_JAVASCRIPT_VE,
-                                          Boolean.TRUE);
-        }
-          
-      }
-    }
-  }
-
-
-  private String _getVersion(String base, int start)
-  {
-    if (start < 0)
-    {
-      return null;
-    }
-
-    int end = base.length();
-    start = start + 1;
-
-    for (int i = start; i < end; i++)
-    {
-      // Find the last non-numeric character; that'll
-      // mark the end of the version
-      char ch = base.charAt(i);
-
-      if ((ch != '.') && ((ch < '0') || (ch > '9')))
-      {
-        return base.substring(start, i);
-      }
-    }
-
-    return base.substring(start);
-  }
-
-  /**
-   * Parse the OS string returned from java.System.
-   * <p/>
-   * Currently, only checks for Windows
-   */
-  private String _getJavaOS(String base, int start)
-  {
-    if (start < 0)
-    {
-      return null;
-    }
-
-    // check for Windows
-    if (base.regionMatches(start, "Windows", 0, base.length() - start))
-    {
-      return Agent.PLATFORM_WINDOWS;
-    }
-
-    return null;
-  }
-
-  static final private String _IASW_DEVICE_HINT_PARAM = "X-Oracle-Device.Class";
-  static final private ADFLogger _LOG = ADFLogger.createADFLogger(AgentFactoryImpl.class);
-
-}
+package org.apache.myfaces.adfinternal.agent;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.myfaces.adf.context.Agent;
+
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.adf.logging.ADFLogger;
+
+
+/**
+ * ADF implementation of AgentFactory.
+ */
+public class AgentFactoryImpl implements AgentFactory
+{
+  /**
+   * @param facesContext
+   * @return
+   */
+
+  public Agent createAgent(String userAgent, String accept)
+  {
+    AgentImpl agent = new AgentImpl();
+    _populateAgentImpl(userAgent,accept,agent);
+    return agent;
+  }
+
+  public Agent createAgent(FacesContext facesContext)
+  {
+    AgentImpl agent = new AgentImpl();
+
+    Map headerMap;
+    if (facesContext != null)
+    {
+      headerMap = facesContext.getExternalContext().getRequestHeaderMap();
+    }
+    else
+    {
+      headerMap = Collections.EMPTY_MAP;
+    }
+
+    //TODO: Add declarative and extensible means for populating AgentImpl object
+    _populateAgentImpl(headerMap, agent);
+
+    return agent;
+  }
+
+
+  private void _populateAgentImpl(Map headerMap, AgentImpl agent)
+  {
+    String userAgent = (String) headerMap.get("User-Agent");
+
+    if ((userAgent != null) && userAgent.startsWith("PTG"))
+    {
+      _populateIaswAgentImpl(userAgent,
+                             (String) headerMap.get(_IASW_DEVICE_HINT_PARAM),agent);
+      return;
+    }
+
+    // determine the agent from the headers
+    _populateAgentImpl(userAgent, (String) headerMap.get("Accept"),agent);
+  }
+
+  private void _populateAgentImpl(String userAgent, String accept,AgentImpl agent)
+  {
+    /* for testing PocketPC */
+
+    //PPC 02
+    //userAgent = "Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; PPC; 240x320)";
+    // PPC 03
+    //userAgent = "Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)";
+    // Web Pro
+    //userAgent = "Mozilla/4.76 (compatible; MSIE 6.0; U; Windows 95; PalmSource; PalmOS; WebPro; Tungsten Proxyless 1.1 320x320x16)";
+    // See if the agent wants WML - if so, we're talking WAP.
+    if ((accept != null) &&
+        accept.regionMatches(true, 0, "vnd.wap.wml", 0, 11))
+    {
+      _populateWAPAgentImpl(agent);
+      return;
+    }
+
+    if (userAgent == null)
+    {
+      _populateNullAgentImpl(userAgent, agent);
+      return;
+    }
+    //the useragent string for telnet and PDA design time will start with
+    //OracleJDevMobile because in each of these cases we know we have an
+    //exact match in the device repository for the agent name.  This is
+    //because the jdev design time and ITS runtime have access to the same
+    //device repository as the ADF runtime
+    //The PDA DT useragent string will be: OracleJDevMobile/PDA/[agentName]
+    //The telnet DT and RT useragent string will be:
+    //OracleJDevMobile/ITS/[agentName]
+    if (userAgent.startsWith("OracleJDevMobile"))
+    {
+      _populateJDevMobileAgentImpl(userAgent,agent);
+      return;
+    }
+    if (userAgent.startsWith("OracleITS"))
+    {
+      _populateTelnetAgentImpl(userAgent,agent);
+      return;
+    }
+    if (userAgent.startsWith("Pixo-Browser"))
+    {
+       _populatePixoAgentImpl(userAgent,agent);
+       return;
+    }
+
+    if (userAgent.startsWith("ICE Browser"))
+    {
+       _populateIceAgentImpl(userAgent,agent);
+       return;
+    }
+
+    // I need to search for more than just "WebPro" because ie's header can be
+    // altered to include "FunWebProducts" in which case ie desktop was being
+    // mapped to a pda
+    // see bug 3362116
+    if (userAgent.indexOf("NetFront/3.") != -1)
+    {
+      _populateNetFrontAgentImpl(userAgent,agent);
+      return;
+    }
+
+    if ( (userAgent.indexOf( "WebPro") != -1 &&
+          userAgent.indexOf("Palm")!= -1)||
+         userAgent.indexOf("Blazer/3.") != -1)
+    {
+      _populatePalmWebBrowserProAgentImpl(userAgent,agent);
+      return;
+    }
+
+/*  //Commenting - Confirm this pattern fornBlazer before uncommenting
+    //and remove the Blazer 3.0 check in the previous if
+    if (((userAgent.indexOf("Blazer/4.") != -1) ||
+        (userAgent.indexOf("Blazer 3.") != -1)) &&
+        ((userAgent.indexOf("Palm") != -1)))
+    {
+      return _getPalmBlazerAgentEntry(userAgent);
+    }
+*/
+
+    if (userAgent.indexOf("Windows CE") != -1)
+    {
+      _populatePocketPCAgentImpl(userAgent,agent);
+      return;
+    }
+
+    // This needs to be before check for mozilla!
+    if ((userAgent.indexOf("PalmOS") != -1) ||
+        (userAgent.indexOf("Blazer") != -1) ||
+        (userAgent.indexOf("Xiino") != -1))
+    {
+      _populatePalmAgentImpl(userAgent,agent);
+      return;
+    }
+
+    if ((userAgent.indexOf("AppleWebKit") != -1) ||
+        (userAgent.indexOf("Safari") != -1))
+    {
+      _populateSafariAgentImpl(userAgent,agent);
+      return;
+    }
+
+    if (userAgent.indexOf("Gecko/") != -1)
+    {
+      _populateGeckoAgentImpl(userAgent,agent);
+      return;
+    }
+    // must check for gecko before checking for mozilla:
+    else if (userAgent.startsWith("Mozilla"))
+    {
+      _populateMozillaAgentImpl(userAgent,agent);
+      return;
+    }
+
+    _populateNullAgentImpl(userAgent, agent);
+  }
+
+  private void _populateNullAgentImpl(String userAgent, AgentImpl agent)
+  {
+    // Log warning message that we are setting the agent entry to null
+    _LOG.warning(
+      "The User-Agent \"{0}\" is unknown;"+
+      " creating an agent with null agent attributes.", userAgent);
+    agent.setAgentEntryToNULL();
+  }
+
+  //populates the agent entry for DT access for either Telnet or PDA
+  //for jdev mobile there are two user agent strings possible:
+  //1. OracleJDevMobile_PDA(DeviceName:[name of device])
+  //2. OracleJDevMobile_ITS(DeviceName:[name of device])
+  private void _populateJDevMobileAgentImpl(String agent,AgentImpl agentObj)
+  {
+    //the form of JDEVMobile user agent string will be:
+    //OracleJDevMobile_[PDA or ITS]/[version](DeviceName:[device name];[capability1]:[capability 1 value];...)
+
+    boolean returnNullAgentObj = false;
+    int itsIndex = agent.indexOf("ITS");
+    int pdaIndex = agent.indexOf("PDA");
+    int versionStartIndex = -1;
+    if (itsIndex > -1)
+    {
+      agentObj.setType(Agent.TYPE_TELNET);
+      versionStartIndex = "OracleJDevMobile_ITS".length()+1;
+    }
+    else
+      if (pdaIndex > -1)
+    {
+
+      agentObj.setType(Agent.TYPE_PDA);
+      versionStartIndex = "OracleJDevMobile_PDA".length()+1;
+    }
+    else
+    {
+      returnNullAgentObj = true;
+    }
+    //Now find the name of the device
+    if (!returnNullAgentObj){
+      int versionEndIndex = agent.indexOf("(");
+      String version = agent.substring(versionStartIndex,versionEndIndex);
+      agentObj.setAgentVersion(version);
+      //parse agentName
+      int agentNameStartIndex = agent.indexOf(":",versionEndIndex) +1;
+      //find end of agentName (ie. when we see a semicolon
+      int agentNameEndIndex = agentNameStartIndex;
+      for (;agent.charAt(agentNameEndIndex)!=';' &&
+          agent.charAt(agentNameEndIndex) !=')';
+          agentNameEndIndex++);
+      String agentName = agent.substring(agentNameStartIndex,agentNameEndIndex);
+      agentObj.setAgent(agentName);
+      if (agent.charAt(agentNameEndIndex) == ')')
+        return;
+      //now parse remaining request specific capabilities
+      int capabilityNameStartIndex;
+      int capabilityNameEndIndex;
+      int capabilityValueStartIndex;
+      int capabilityValueEndIndex = agentNameEndIndex;
+      while(agent.charAt(capabilityValueEndIndex)!= ')')
+      {
+        capabilityNameStartIndex = capabilityValueEndIndex + 1;
+        capabilityNameEndIndex = agent.indexOf(":",capabilityNameStartIndex);
+        String capabilityName = agent.substring(capabilityNameStartIndex,capabilityNameEndIndex);
+        capabilityValueStartIndex = capabilityNameEndIndex +1;
+        capabilityValueEndIndex = agent.indexOf(";",capabilityValueStartIndex);
+        if (capabilityValueEndIndex == -1)
+        {
+          capabilityValueEndIndex = agent.indexOf(")",capabilityValueEndIndex);
+        }
+        String capabilityValue = agent.substring(capabilityValueStartIndex,capabilityValueEndIndex);
+        agentObj.__addRequestCapability(CapabilityKey.getCapabilityKey(capabilityName,true),capabilityValue);
+      }
+    }
+    if (returnNullAgentObj)
+    {
+      _populateNullAgentImpl(agent, agentObj);
+    }
+  }
+
+  private void _populateTelnetAgentImpl(String agent,AgentImpl agentObj)
+  {
+    //the form of an ITS user agent will be
+    //OracleITS/[version](DeviceName:[device name];[capability1]:[capability 1 value];...)
+    agentObj.setType(Agent.TYPE_TELNET);
+    int versionStartIndex = "OracleITS".length() +1;
+    int versionEndIndex = agent.indexOf("(");
+    String version = agent.substring(versionStartIndex,versionEndIndex);
+    agentObj.setAgentVersion(version);
+    //parse agentName
+    int agentNameStartIndex = agent.indexOf(":",versionEndIndex) +1;
+    //find end of agentName (ie. when we see a semicolon
+    int agentNameEndIndex = agentNameStartIndex;
+    for (;agent.charAt(agentNameEndIndex)!=';' &&
+          agent.charAt(agentNameEndIndex) !=')';
+          agentNameEndIndex++);
+    String agentName = agent.substring(agentNameStartIndex,agentNameEndIndex);
+    agentObj.setAgent(agentName);
+    if (agent.charAt(agentNameEndIndex) == ')')
+      return;
+    //now parse remaining request specific capabilities
+    int capabilityNameStartIndex;
+    int capabilityNameEndIndex;
+    int capabilityValueStartIndex;
+    int capabilityValueEndIndex = agentNameEndIndex;
+    while(agent.charAt(capabilityValueEndIndex)!= ')')
+    {
+      capabilityNameStartIndex = capabilityValueEndIndex + 1;
+      capabilityNameEndIndex = agent.indexOf(":",capabilityNameStartIndex);
+      String capabilityName = agent.substring(capabilityNameStartIndex,capabilityNameEndIndex);
+      capabilityValueStartIndex = capabilityNameEndIndex +1;
+      capabilityValueEndIndex = agent.indexOf(";",capabilityValueStartIndex);
+      if (capabilityValueEndIndex == -1)
+      {
+        capabilityValueEndIndex = agent.indexOf(")",capabilityValueEndIndex);
+      }
+      String capabilityValue = agent.substring(capabilityValueStartIndex,capabilityValueEndIndex);
+      agentObj.__addRequestCapability(CapabilityKey.getCapabilityKey(capabilityName,true),capabilityValue);
+    }
+  }
+
+  /**
+   * populates data from a PocketPC IE request
+   */
+  private void _populatePocketPCAgentImpl(String agent,AgentImpl agentObj)
+  {
+    int start = agent.indexOf("MSIE");
+    String version = null;
+
+    if (start > -1)
+    {
+      version = _getVersion(agent, start + "MSIE".length());
+    }
+    agentObj.setType(Agent.TYPE_PDA);
+    agentObj.setAgent(Agent.AGENT_IE);
+    agentObj.setAgentVersion(version);
+    agentObj.setPlatform(Agent.PLATFORM_PPC);
+  }
+
+  /**
+   * returns the data for the Palm NetFront browser request
+   */
+  private void _populateNetFrontAgentImpl(String agent, AgentImpl agentObj)
+  {
+    agentObj.setType(Agent.TYPE_PDA);
+    agentObj.setAgent(AdfFacesAgent.AGENT_NETFRONT);
+
+    int start = agent.indexOf("NetFront/");
+
+    if (start > -1)
+    {
+      agentObj.setAgentVersion(_getVersion(agent, start + 8));
+    }
+
+    int paren = agent.indexOf('(');
+
+    if (paren >= 0)
+    {
+      // try to determine the OS
+      if (agent.indexOf("Windows CE", paren) > 0)
+      {
+        agentObj.setPlatform(Agent.PLATFORM_PPC);
+      }
+/*
+      //Embedded Linux is not be same as Linux
+      //so leave it as unknown
+      else if (agent.indexOf("Embedix", paren) > 0)
+      {
+        entry._platform = Agent.PLATFORM_LINUX;
+      }
+*/
+      else if (agent.indexOf("Palm", paren) > 0)
+      {
+        agentObj.setPlatform(Agent.PLATFORM_PALM);
+      }
+    }
+
+  }
+
+  /**
+   * returns the data for the Palm Web Pro browser request
+   */
+  private void _populatePalmWebBrowserProAgentImpl(String agent,AgentImpl agentObj)
+  {
+    agentObj.setType(Agent.TYPE_PDA);
+    agentObj.setAgent(AdfFacesAgent.AGENT_WEBPRO);
+
+    int start = agent.indexOf("WebPro/");
+
+    if (start > -1)
+    {
+      agentObj.setAgentVersion(_getVersion(agent, start + 6));
+    }
+
+    agentObj.setPlatform(Agent.PLATFORM_PALM);
+
+  }
+
+  /**
+   * returns the data for the Palm blazer browser request
+   */
+/* //comment for now
+  private AgentEntry _getPalmBlazerAgentEntry(String agent)
+  {
+    AgentEntry entry = new AgentEntry();
+    entry._type = TYPE_PDA;
+    entry._agent = AdfFacesAgent.AGENT_BLAZER;
+
+    //balzer 3 has "Blazer 3..." and 4.0 has Blazer 4/....
+    int start = agent.indexOf("Blazer");
+
+    if (start > -1)
+    {
+      entry._agentVersion = _getVersion(agent, start + 6);
+    }
+
+    entry._platform = Agent.PLATFORM_PALM;
+
+    return entry;
+  }
+*/
+
+  /**
+   * returns the AgentEntry for ias wireless
+   */
+  private void _populateIaswAgentImpl(String agent, String wirelessType,AgentImpl agentObj)
+  {
+    // map device hint to agent type
+    if (wirelessType == null)
+    {
+      _populateNullAgentImpl(agent, agentObj);
+      return;
+    }
+
+    String version = _getVersion(agent, agent.indexOf('/'));
+    agentObj.setType(Agent.TYPE_PHONE);
+    agentObj.setAgent(AdfFacesAgent.AGENT_PTG);
+    agentObj.setAgentVersion(version);
+  }
+
+  /**
+   * returns the AgentEntry for the Palm
+   */
+  private void _populatePalmAgentImpl(String userAgent,AgentImpl agentObj)
+  {
+    agentObj.setType(Agent.TYPE_PDA);
+
+    if (userAgent.indexOf("Blazer") != -1)
+      agentObj.setAgent(AdfFacesAgent.AGENT_BLAZER);
+    else if (userAgent.indexOf("Xiino") != -1)
+      agentObj.setAgent(AdfFacesAgent.AGENT_XIINO);
+
+    agentObj.setPlatform(Agent.PLATFORM_PALM);
+
+  }
+
+  /**
+   * returns the AgentEntry for the Ice brwoser
+   */
+  private void _populateIceAgentImpl(String agent,AgentImpl agentObj)
+  {
+    int slashIndex = agent.indexOf('/');
+    agentObj.setType(Agent.TYPE_DESKTOP);
+    agentObj.setAgent(AdfFacesAgent.AGENT_ICE_BROWSER);
+    agentObj.setAgentVersion(_getVersion(agent, slashIndex));
+    agentObj.setPlatform(_getJavaOS(agent, slashIndex));
+  }
+
+  /**
+   * returns the AgentEntry for the Pixo Microbrowser
+   */
+  private void  _populatePixoAgentImpl(String agent,AgentImpl agentObj)
+  {
+    agentObj.setType(Agent.TYPE_PHONE);
+    agentObj.setAgent(AdfFacesAgent.AGENT_PIXO);
+    agentObj.setAgentVersion(_getVersion(agent, agent.indexOf('/')));
+  }
+
+  /**
+   * Returns an AgentEntry for a WML client.
+   */
+  private void _populateWAPAgentImpl(AgentImpl agentObj)
+  {
+    //TODO: Add generic wmlbrowser when wml browsers are supported
+    // Generic WML support
+    agentObj.setType(Agent.TYPE_PHONE);
+  }
+
+  /**
+   * Returns an AgentEntry for the browsers that use the Gecko Layout Engine.
+   */
+  private void _populateGeckoAgentImpl(String agent,AgentImpl agentObj)
+  {
+   //Identifying an Gecko Based agent as Gecko (and not Mozilla, Netscape, Firefox)
+    //could be an issue
+    //E.g User-Agent String
+    //Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+    //For Gecko based agents
+    //    - Gecko uses Date string as a version number
+    //    - Mozilla uses the revision number as the version number rv:x.x.x
+    //    - Each vendor has a version number (like firefox/1.0,  Netscape/7.0)
+    // Mozilla revision : Gecko Version
+    //           1.0.1  : 20020826
+    //           1.1    : 20020826
+    //           1.2.1  : 20021130
+
+    //Currently (in UIX 2.2 base agent Impl)
+    //  - All Gecko Based agents are identified as Gecko
+    //  - But PPR capability is determined is based on the Mozilla version number (rv:x.x.x)
+    //  - For Major version , for Gecko, always "1" is returned
+    //so stricly speaking all capabilities are not based on the layout engine.
+
+    //New Impl.
+    //  - Still using Gecko as the identifier for all gecko based agents
+    //  - Still returning date string as version number of Gecko. But this can get messy to use
+    //    by the applications. The version number could change everyday and may not be the same for
+    //    different platforms.  (An alternate option is to return version number of Mozilla
+    //    that would be equivalent to current browser for Gecko-based browsers)
+    //  - But assumes PPR Support in all Gecko versions.
+
+    agentObj.setType(Agent.TYPE_DESKTOP);
+    agentObj.setAgent(Agent.AGENT_GECKO);
+
+    int geckoIndex = agent.indexOf("Gecko/");
+    agentObj.setAgentVersion(agent.substring(geckoIndex+6, // skip over 'Gecko/'
+            geckoIndex+14)); // always 8 chars length
+
+    //int start = agent.indexOf("rv:");
+    //entry._agentVersion = _getVersion(agent, start + 2);
+
+    int paren = agent.indexOf('(');
+
+    if (paren >= 0)
+    {
+      // try to determine the OS
+      if (agent.indexOf("Win", paren) > 0)
+      {
+        agentObj.setPlatform(Agent.PLATFORM_WINDOWS);
+      }
+      else if (agent.indexOf("Mac", paren) > 0)
+      {
+        agentObj.setPlatform(Agent.PLATFORM_MAC);
+      }
+      else if (agent.indexOf("Linux", paren) > 0)
+      {
+        agentObj.setPlatform(Agent.PLATFORM_LINUX);
+      }
+      else if (agent.indexOf("Sun", paren) > 0)
+      {
+        agentObj.setPlatform(Agent.PLATFORM_SOLARIS);
+      }
+    }
+  }
+
+  /**
+   * returns the AgentEntry for Safari
+   */
+  private void  _populateSafariAgentImpl(String agent, AgentImpl agentObj)
+  {
+    int start = agent.indexOf("AppleWebKit");
+
+    if (start < 0)
+    {
+      start = agent.indexOf("Safari");
+    }
+
+    if (start >= 0)
+    {
+      start = agent.indexOf('/', start);
+    }
+
+    String version = _getVersion(agent, start);
+    agentObj.setType(Agent.TYPE_DESKTOP);
+    agentObj.setAgent(Agent.AGENT_WEBKIT);
+    agentObj.setAgentVersion(version);
+    agentObj.setPlatform(Agent.PLATFORM_MAC);
+  }
+
+  /**
+   * Returns an AgentEntry for the "Mozilla" family of browsers - which
+   * most at least pretend to be.
+   */
+  private void _populateMozillaAgentImpl(String agent,AgentImpl agentObj)
+  {
+    int paren = agent.indexOf('(');
+    agentObj.setType(Agent.TYPE_DESKTOP); //Is this default realli okay??? These days Mobile agents also use Mozilla/xx.xx
+
+    // No section to qualify the agent;  assume Mozilla/Netscape
+    if (paren == -1)
+    {
+      agentObj.setAgent(AdfFacesAgent.AGENT_NETSCAPE);
+      agentObj.setAgentVersion(_getVersion(agent, agent.indexOf('/')));
+    }
+    else
+    {
+      paren = paren + 1;
+
+      boolean isJDevVE = agent.indexOf("JDeveloper", paren) > 0;
+      boolean isJDevJSVE = agent.indexOf("JDeveloper JS", paren) > 0;
+
+      if (agent.startsWith("compatible", paren))
+      {
+        int ieIndex = agent.indexOf("MSIE", paren);
+
+        if (ieIndex < 0)
+        {
+          // check for Palm
+          int palmIndex = agent.indexOf("Elaine", paren);
+
+          if (palmIndex > 0)
+          {
+            agentObj.setType(Agent.TYPE_PDA);
+            agentObj.setAgent(AdfFacesAgent.AGENT_ELAINE);
+            agentObj.setAgentVersion(_getVersion(agent, palmIndex));
+            agentObj.setPlatform(Agent.PLATFORM_PALM);
+          }
+        }
+        else
+        {
+          agentObj.setAgent(Agent.AGENT_IE);
+          agentObj.setAgentVersion(_getVersion(agent, ieIndex + 4));
+        }
+      }
+      else
+      {
+        agentObj.setAgent(AdfFacesAgent.AGENT_NETSCAPE);
+        agentObj.setAgentVersion(_getVersion(agent, agent.indexOf('/')));
+      }
+
+      // try to determine the OS, if unknown
+      if (agentObj.getPlatformName() == null)
+      {
+        // Hack: treat the JDeveloper agent as Windows,
+        // so that we assume IE 6.0 Windows capabilities
+        if ((agent.indexOf("Win", paren) > 0) || isJDevVE)
+        {
+          agentObj.setPlatform(Agent.PLATFORM_WINDOWS);
+        }
+        else if (agent.indexOf("Mac", paren) > 0)
+        {
+          agentObj.setPlatform(Agent.PLATFORM_MAC);
+        }
+        else if (agent.indexOf("Linux", paren) > 0)
+        {
+          agentObj.setPlatform(Agent.PLATFORM_LINUX);
+        }
+        else if (agent.indexOf("Sun", paren) > 0)
+        {
+          agentObj.setPlatform(Agent.PLATFORM_SOLARIS);
+        }
+      }
+
+      if (isJDevVE)
+      {
+        agentObj.__addRequestCapability(AdfFacesAgent.CAP_IS_JDEV_VE,
+                                        Boolean.TRUE);
+        if (isJDevJSVE)
+        {
+          agentObj.__addRequestCapability(AdfFacesAgent.CAP_IS_JDEV_JAVASCRIPT_VE,
+                                          Boolean.TRUE);
+        }
+          
+      }
+    }
+  }
+
+
+  private String _getVersion(String base, int start)
+  {
+    if (start < 0)
+    {
+      return null;
+    }
+
+    int end = base.length();
+    start = start + 1;
+
+    for (int i = start; i < end; i++)
+    {
+      // Find the last non-numeric character; that'll
+      // mark the end of the version
+      char ch = base.charAt(i);
+
+      if ((ch != '.') && ((ch < '0') || (ch > '9')))
+      {
+        return base.substring(start, i);
+      }
+    }
+
+    return base.substring(start);
+  }
+
+  /**
+   * Parse the OS string returned from java.System.
+   * <p/>
+   * Currently, only checks for Windows
+   */
+  private String _getJavaOS(String base, int start)
+  {
+    if (start < 0)
+    {
+      return null;
+    }
+
+    // check for Windows
+    if (base.regionMatches(start, "Windows", 0, base.length() - start))
+    {
+      return Agent.PLATFORM_WINDOWS;
+    }
+
+    return null;
+  }
+
+  static final private String _IASW_DEVICE_HINT_PARAM = "X-Oracle-Device.Class";
+  static final private ADFLogger _LOG = ADFLogger.createADFLogger(AgentFactoryImpl.class);
+
+}

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentImpl.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentImpl.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentImpl.java Mon Jul 24 21:42:41 2006
@@ -13,149 +13,149 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adfinternal.agent;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.myfaces.adf.logging.ADFLogger;
-
-
-/**
- * The implementation of agent interface
- * <p></p>
- * This implementation supports agents recognized by all uix22
- * This class returns name strings (instead of int's)
- * Certain agents/platforms have been renamed
- * - using "webkit" (instead of safari), on recommendation from uix team
- * - using "gecko" for all gecko based browsers
- * - using "ppc" (instead of windows) for platform
- * <p></p>
- *
- */
-
-public class AgentImpl extends DefaultAgent
-{
-
-  public AgentImpl()
-  {
-    this(false);
-  }
-
-  public AgentImpl(boolean nullAgentEntry)
-  {
-    if (nullAgentEntry)
-    {
-      _LOG.warning(
-      "The agent type is unknown; creating an agent with null agent attributes.");
-      _entry = _NULL_AGENT_ENTRY;
-    }
-    else
-    {
-      _entry = new AgentEntry();
-    }
-  }
-
-/*  public AgentImpl(String userAgent, String accept)
-  {
-    _entry = _getAgentEntry(userAgent, accept);
-  }
-  */
-  public Object getType()
-  {
-    return _entry._type;
-  }
-
-  public String getAgentName()
-  {
-    return _entry._agent;
-  }
-
-  public String getAgentVersion()
-  {
-    return _entry._agentVersion;
-  }
-
-  public String getPlatformName()
-  {
-    return _entry._platform;
-  }
-
-  public String getPlatformVersion()
-  {
-    return _entry._platformVersion;
-  }
-
-  public String getHardwareMakeModel()
-  {
-    return _entry._makeModel;
-  }
-
-  public Map getCapabilities()
-  {
-    return _requestCapabilities;
-  }
-
-  //setter methods for AgentImpl
-  public void setType(Object type)
-  {
-    _entry._type = type;
-  }
-
-  public void setAgent(String agent)
-  {
-    _entry._agent = agent;
-  }
-
-  public void setAgentVersion(String version)
-  {
-    _entry._agentVersion = version;
-  }
-
-  public void setPlatform(String platform)
-  {
-    _entry._platform = platform;
-  }
-
-  public void setPlatformVersion(String version)
-  {
-    _entry._platformVersion = version;
-  }
-
-  public void setMakeModel(String makemodel)
-  {
-    _entry._makeModel = makemodel;
-  }
-
-  public void setAgentEntryToNULL()
-  {
-    _entry = _NULL_AGENT_ENTRY;
-  }
-
-  //Private entry structure to
-  //store the Agent attributes
-  private static class AgentEntry
-  {
-    Object _type = TYPE_UNKNOWN;
-    String _agent;
-    String _agentVersion;
-    String _platform;
-    String _platformVersion;
-    String _makeModel;
-  }
-
-  void __addRequestCapability(CapabilityKey key,Object value)
-  {
-     if (_requestCapabilities == null)
-     {
-       _requestCapabilities = new HashMap();
-     }
-    _requestCapabilities.put(key,value);
-  }
-
-  private HashMap _requestCapabilities;
-  private AgentEntry _entry;
-  static private final AgentEntry _NULL_AGENT_ENTRY = new AgentEntry();
-  static final private ADFLogger _LOG = ADFLogger.createADFLogger(AgentImpl.class);
-
-}
+package org.apache.myfaces.adfinternal.agent;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.myfaces.adf.logging.ADFLogger;
+
+
+/**
+ * The implementation of agent interface
+ * <p></p>
+ * This implementation supports agents recognized by all uix22
+ * This class returns name strings (instead of int's)
+ * Certain agents/platforms have been renamed
+ * - using "webkit" (instead of safari), on recommendation from uix team
+ * - using "gecko" for all gecko based browsers
+ * - using "ppc" (instead of windows) for platform
+ * <p></p>
+ *
+ */
+
+public class AgentImpl extends DefaultAgent
+{
+
+  public AgentImpl()
+  {
+    this(false);
+  }
+
+  public AgentImpl(boolean nullAgentEntry)
+  {
+    if (nullAgentEntry)
+    {
+      _LOG.warning(
+      "The agent type is unknown; creating an agent with null agent attributes.");
+      _entry = _NULL_AGENT_ENTRY;
+    }
+    else
+    {
+      _entry = new AgentEntry();
+    }
+  }
+
+/*  public AgentImpl(String userAgent, String accept)
+  {
+    _entry = _getAgentEntry(userAgent, accept);
+  }
+  */
+  public Object getType()
+  {
+    return _entry._type;
+  }
+
+  public String getAgentName()
+  {
+    return _entry._agent;
+  }
+
+  public String getAgentVersion()
+  {
+    return _entry._agentVersion;
+  }
+
+  public String getPlatformName()
+  {
+    return _entry._platform;
+  }
+
+  public String getPlatformVersion()
+  {
+    return _entry._platformVersion;
+  }
+
+  public String getHardwareMakeModel()
+  {
+    return _entry._makeModel;
+  }
+
+  public Map getCapabilities()
+  {
+    return _requestCapabilities;
+  }
+
+  //setter methods for AgentImpl
+  public void setType(Object type)
+  {
+    _entry._type = type;
+  }
+
+  public void setAgent(String agent)
+  {
+    _entry._agent = agent;
+  }
+
+  public void setAgentVersion(String version)
+  {
+    _entry._agentVersion = version;
+  }
+
+  public void setPlatform(String platform)
+  {
+    _entry._platform = platform;
+  }
+
+  public void setPlatformVersion(String version)
+  {
+    _entry._platformVersion = version;
+  }
+
+  public void setMakeModel(String makemodel)
+  {
+    _entry._makeModel = makemodel;
+  }
+
+  public void setAgentEntryToNULL()
+  {
+    _entry = _NULL_AGENT_ENTRY;
+  }
+
+  //Private entry structure to
+  //store the Agent attributes
+  private static class AgentEntry
+  {
+    Object _type = TYPE_UNKNOWN;
+    String _agent;
+    String _agentVersion;
+    String _platform;
+    String _platformVersion;
+    String _makeModel;
+  }
+
+  void __addRequestCapability(CapabilityKey key,Object value)
+  {
+     if (_requestCapabilities == null)
+     {
+       _requestCapabilities = new HashMap();
+     }
+    _requestCapabilities.put(key,value);
+  }
+
+  private HashMap _requestCapabilities;
+  private AgentEntry _entry;
+  static private final AgentEntry _NULL_AGENT_ENTRY = new AgentEntry();
+  static final private ADFLogger _LOG = ADFLogger.createADFLogger(AgentImpl.class);
+
+}

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentNameUtil.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentNameUtil.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentNameUtil.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentNameUtil.java Mon Jul 24 21:42:41 2006
@@ -13,214 +13,214 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adfinternal.agent;
-
-import org.apache.myfaces.adf.context.Agent;
-
-
-/**
- * An utility class that maps agent/platform name strings to AdFacesAgent
- * Application constants and vice versa
- *
- */
-public class AgentNameUtil
-{
-  /**
-   * utility method to get AdfFacesAgent application constant (int) from agent name strings
-   *
-   * @param agentName
-   * @return
-   */
-  public static int getAgent(String agentName)
-  {
-    if (AdfFacesAgent.AGENT_NETSCAPE.equals(agentName))
-    {
-      return AdfFacesAgent.APPLICATION_NETSCAPE;
-    }
-
-    if (AdfFacesAgent.AGENT_IE.equals(agentName))
-    {
-      return AdfFacesAgent.APPLICATION_IEXPLORER;
-    }
-
-    if (AdfFacesAgent.AGENT_GECKO.equals(agentName))
-    {
-      return AdfFacesAgent.APPLICATION_GECKO;
-    }
-
-    if (AdfFacesAgent.AGENT_ELAINE.equals(agentName))
-    {
-      return AdfFacesAgent.APPLICATION_WEB_CLIPPING;
-    }
-
-    if (AdfFacesAgent.AGENT_ICE_BROWSER.equals(agentName))
-    {
-      return AdfFacesAgent.APPLICATION_ICE;
-    }
-
-    if (AdfFacesAgent.AGENT_PIXO.equals(agentName))
-    {
-      return AdfFacesAgent.APPLICATION_PIXO;
-    }
-
-    if ((AdfFacesAgent.AGENT_NETFRONT.equals(agentName)) ||
-        (AdfFacesAgent.AGENT_WEBPRO.equals(agentName)))
-    {
-      return AdfFacesAgent.APPLICATION_NET_FRONT;
-    }
-
-    if (AdfFacesAgent.AGENT_WEBKIT.equals(agentName))
-    {
-      return AdfFacesAgent.APPLICATION_SAFARI;
-    }
-
-    return AdfFacesAgent.APPLICATION_UNKNOWN;
-  }
-
-  /**
-   * utility method to get AdfFacesAgent application constant (int) from platform/os name strings
-   *
-   * @param platformName
-   * @return
-   */
-  public static int getPlatform(String platformName)
-  {
-    if (AdfFacesAgent.PLATFORM_WINDOWS.equals(platformName))
-    {
-      return AdfFacesAgent.OS_WINDOWS;
-    }
-
-    if (AdfFacesAgent.PLATFORM_MAC.equals(platformName))
-    {
-      return AdfFacesAgent.OS_MACOS;
-    }
-
-    if (AdfFacesAgent.PLATFORM_LINUX.equals(platformName))
-    {
-      return AdfFacesAgent.OS_LINUX;
-    }
-
-    if (AdfFacesAgent.PLATFORM_SOLARIS.equals(platformName))
-    {
-      return AdfFacesAgent.OS_SOLARIS;
-    }
-
-    if (AdfFacesAgent.PLATFORM_PALM.equals(platformName))
-    {
-      return AdfFacesAgent.OS_PALM;
-    }
-
-    if (AdfFacesAgent.PLATFORM_PPC.equals(platformName))
-    {
-      //return unknown for now
-      return AdfFacesAgent.OS_PPC;
-    }
-
-    return AdfFacesAgent.OS_UNKNOWN;
-  }
-
-  /**
-   * utility method to get AdfFacesAgent application constant (int) from Agent type objects
-   *
-   * @param otype
-   * @return
-   */
-  public static int getAgentType(Object otype)
-  {
-    if (otype == Agent.TYPE_PDA)
-    {
-      return AdfFacesAgent.TYPE_PDA;
-    }
-
-    if (otype == Agent.TYPE_PHONE)
-    {
-      return AdfFacesAgent.TYPE_PHONE;
-    }
-
-    //Default to desktop (This is UIX 2.2 logic)
-    return AdfFacesAgent.TYPE_DESKTOP;
-  }
-
-  /**
-   * utility method to get agent name string from AdfFacesAgent application constant (int)
-   *
-   * @param agentId
-   * @return
-   */
-  public static String getAgentName(int agentId)
-  {
-    switch (agentId) {
-      case AdfFacesAgent.APPLICATION_UNKNOWN:
-        return null;
-      case AdfFacesAgent.APPLICATION_NETSCAPE:
-        return AdfFacesAgent.AGENT_NETSCAPE;
-      case AdfFacesAgent.APPLICATION_IEXPLORER:
-        return AdfFacesAgent.AGENT_IE;
-      case AdfFacesAgent.APPLICATION_GECKO:
-        return AdfFacesAgent.AGENT_GECKO;
-      case AdfFacesAgent.APPLICATION_WEB_CLIPPING:
-        return AdfFacesAgent.AGENT_ELAINE;
-      case AdfFacesAgent.APPLICATION_ICE:
-        return AdfFacesAgent.AGENT_ICE_BROWSER;
-      case AdfFacesAgent.APPLICATION_PIXO:
-        return AdfFacesAgent.AGENT_PIXO;
-      case AdfFacesAgent.APPLICATION_NET_FRONT:
-        return AdfFacesAgent.AGENT_NETFRONT;
-      case AdfFacesAgent.APPLICATION_SAFARI:
-        return AdfFacesAgent.AGENT_WEBKIT;
-       default:
-        return null;
-    }
-  }
-
-
-
-  /**
-   * utility method to get platform name string from AdfFacesAgent application constant (int)
-   *
-   * @param platformId
-   * @return
-   */
-  public static String getPlatformName(int platformId)
-  {
-    switch (platformId) {
-      case AdfFacesAgent.OS_UNKNOWN:
-        return null;
-      case AdfFacesAgent.OS_WINDOWS:
-        return AdfFacesAgent.PLATFORM_WINDOWS;
-      case AdfFacesAgent.OS_MACOS:
-        return AdfFacesAgent.PLATFORM_MAC;
-      case AdfFacesAgent.OS_LINUX:
-        return AdfFacesAgent.PLATFORM_LINUX;
-      case AdfFacesAgent.OS_SOLARIS:
-        return AdfFacesAgent.PLATFORM_SOLARIS;
-      case AdfFacesAgent.OS_PALM:
-        return AdfFacesAgent.PLATFORM_PALM;
-      case AdfFacesAgent.OS_PPC:
-        return AdfFacesAgent.PLATFORM_PPC;
-      default:
-        return null;
-    }
-  }
-
-  /**
-   * utility method to get type obejct from AdfFacesAgent application constant (int)
-   *
-   * @param type
-   * @return
-   */
-  public Object getType (int type) {
-    switch (type) {
-      case AdfFacesAgent.TYPE_DESKTOP:
-        return null;
-      case AdfFacesAgent.TYPE_PDA:
-        return Agent.TYPE_PDA;
-      case AdfFacesAgent.TYPE_PHONE:
-        return Agent.TYPE_PHONE;
-      case AdfFacesAgent.TYPE_VOICE:
-      default:
-        return Agent.TYPE_UNKNOWN;
-    }
-  }
-
-}
+package org.apache.myfaces.adfinternal.agent;
+
+import org.apache.myfaces.adf.context.Agent;
+
+
+/**
+ * An utility class that maps agent/platform name strings to AdFacesAgent
+ * Application constants and vice versa
+ *
+ */
+public class AgentNameUtil
+{
+  /**
+   * utility method to get AdfFacesAgent application constant (int) from agent name strings
+   *
+   * @param agentName
+   * @return
+   */
+  public static int getAgent(String agentName)
+  {
+    if (AdfFacesAgent.AGENT_NETSCAPE.equals(agentName))
+    {
+      return AdfFacesAgent.APPLICATION_NETSCAPE;
+    }
+
+    if (AdfFacesAgent.AGENT_IE.equals(agentName))
+    {
+      return AdfFacesAgent.APPLICATION_IEXPLORER;
+    }
+
+    if (AdfFacesAgent.AGENT_GECKO.equals(agentName))
+    {
+      return AdfFacesAgent.APPLICATION_GECKO;
+    }
+
+    if (AdfFacesAgent.AGENT_ELAINE.equals(agentName))
+    {
+      return AdfFacesAgent.APPLICATION_WEB_CLIPPING;
+    }
+
+    if (AdfFacesAgent.AGENT_ICE_BROWSER.equals(agentName))
+    {
+      return AdfFacesAgent.APPLICATION_ICE;
+    }
+
+    if (AdfFacesAgent.AGENT_PIXO.equals(agentName))
+    {
+      return AdfFacesAgent.APPLICATION_PIXO;
+    }
+
+    if ((AdfFacesAgent.AGENT_NETFRONT.equals(agentName)) ||
+        (AdfFacesAgent.AGENT_WEBPRO.equals(agentName)))
+    {
+      return AdfFacesAgent.APPLICATION_NET_FRONT;
+    }
+
+    if (AdfFacesAgent.AGENT_WEBKIT.equals(agentName))
+    {
+      return AdfFacesAgent.APPLICATION_SAFARI;
+    }
+
+    return AdfFacesAgent.APPLICATION_UNKNOWN;
+  }
+
+  /**
+   * utility method to get AdfFacesAgent application constant (int) from platform/os name strings
+   *
+   * @param platformName
+   * @return
+   */
+  public static int getPlatform(String platformName)
+  {
+    if (AdfFacesAgent.PLATFORM_WINDOWS.equals(platformName))
+    {
+      return AdfFacesAgent.OS_WINDOWS;
+    }
+
+    if (AdfFacesAgent.PLATFORM_MAC.equals(platformName))
+    {
+      return AdfFacesAgent.OS_MACOS;
+    }
+
+    if (AdfFacesAgent.PLATFORM_LINUX.equals(platformName))
+    {
+      return AdfFacesAgent.OS_LINUX;
+    }
+
+    if (AdfFacesAgent.PLATFORM_SOLARIS.equals(platformName))
+    {
+      return AdfFacesAgent.OS_SOLARIS;
+    }
+
+    if (AdfFacesAgent.PLATFORM_PALM.equals(platformName))
+    {
+      return AdfFacesAgent.OS_PALM;
+    }
+
+    if (AdfFacesAgent.PLATFORM_PPC.equals(platformName))
+    {
+      //return unknown for now
+      return AdfFacesAgent.OS_PPC;
+    }
+
+    return AdfFacesAgent.OS_UNKNOWN;
+  }
+
+  /**
+   * utility method to get AdfFacesAgent application constant (int) from Agent type objects
+   *
+   * @param otype
+   * @return
+   */
+  public static int getAgentType(Object otype)
+  {
+    if (otype == Agent.TYPE_PDA)
+    {
+      return AdfFacesAgent.TYPE_PDA;
+    }
+
+    if (otype == Agent.TYPE_PHONE)
+    {
+      return AdfFacesAgent.TYPE_PHONE;
+    }
+
+    //Default to desktop (This is UIX 2.2 logic)
+    return AdfFacesAgent.TYPE_DESKTOP;
+  }
+
+  /**
+   * utility method to get agent name string from AdfFacesAgent application constant (int)
+   *
+   * @param agentId
+   * @return
+   */
+  public static String getAgentName(int agentId)
+  {
+    switch (agentId) {
+      case AdfFacesAgent.APPLICATION_UNKNOWN:
+        return null;
+      case AdfFacesAgent.APPLICATION_NETSCAPE:
+        return AdfFacesAgent.AGENT_NETSCAPE;
+      case AdfFacesAgent.APPLICATION_IEXPLORER:
+        return AdfFacesAgent.AGENT_IE;
+      case AdfFacesAgent.APPLICATION_GECKO:
+        return AdfFacesAgent.AGENT_GECKO;
+      case AdfFacesAgent.APPLICATION_WEB_CLIPPING:
+        return AdfFacesAgent.AGENT_ELAINE;
+      case AdfFacesAgent.APPLICATION_ICE:
+        return AdfFacesAgent.AGENT_ICE_BROWSER;
+      case AdfFacesAgent.APPLICATION_PIXO:
+        return AdfFacesAgent.AGENT_PIXO;
+      case AdfFacesAgent.APPLICATION_NET_FRONT:
+        return AdfFacesAgent.AGENT_NETFRONT;
+      case AdfFacesAgent.APPLICATION_SAFARI:
+        return AdfFacesAgent.AGENT_WEBKIT;
+       default:
+        return null;
+    }
+  }
+
+
+
+  /**
+   * utility method to get platform name string from AdfFacesAgent application constant (int)
+   *
+   * @param platformId
+   * @return
+   */
+  public static String getPlatformName(int platformId)
+  {
+    switch (platformId) {
+      case AdfFacesAgent.OS_UNKNOWN:
+        return null;
+      case AdfFacesAgent.OS_WINDOWS:
+        return AdfFacesAgent.PLATFORM_WINDOWS;
+      case AdfFacesAgent.OS_MACOS:
+        return AdfFacesAgent.PLATFORM_MAC;
+      case AdfFacesAgent.OS_LINUX:
+        return AdfFacesAgent.PLATFORM_LINUX;
+      case AdfFacesAgent.OS_SOLARIS:
+        return AdfFacesAgent.PLATFORM_SOLARIS;
+      case AdfFacesAgent.OS_PALM:
+        return AdfFacesAgent.PLATFORM_PALM;
+      case AdfFacesAgent.OS_PPC:
+        return AdfFacesAgent.PLATFORM_PPC;
+      default:
+        return null;
+    }
+  }
+
+  /**
+   * utility method to get type obejct from AdfFacesAgent application constant (int)
+   *
+   * @param type
+   * @return
+   */
+  public Object getType (int type) {
+    switch (type) {
+      case AdfFacesAgent.TYPE_DESKTOP:
+        return null;
+      case AdfFacesAgent.TYPE_PDA:
+        return Agent.TYPE_PDA;
+      case AdfFacesAgent.TYPE_PHONE:
+        return Agent.TYPE_PHONE;
+      case AdfFacesAgent.TYPE_VOICE:
+      default:
+        return Agent.TYPE_UNKNOWN;
+    }
+  }
+
+}

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentNameUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentUtil.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentUtil.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentUtil.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentUtil.java Mon Jul 24 21:42:41 2006
@@ -13,118 +13,118 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adfinternal.agent;
-
-import java.util.Map;
-
-import org.apache.myfaces.adf.context.Agent;
-import org.apache.myfaces.adf.context.AdfFacesContext;
-
-import javax.faces.context.FacesContext;
-
-/**
- * agent util class
- */
-public class AgentUtil
-{
-  /**
-   * Construct an AdfFacesAgent from agentType, agent application constant, agent version
-   * and plaform application constant
-   *
-   * //TODO: Check: if this is really needed
-   *
-   * @param type
-   * @param browser
-   * @param agentVersion
-   * @param platform
-   * @return
-   */
-  public static AdfFacesAgent getAgent(int type, int browser, String agentVersion, int platform)
-  {
-    final int fType = type;
-    final int fBrowser = browser;
-    final String fAgentVersion = agentVersion;
-    final int fPlatform = platform;
-
-    Agent agent =
-            new DefaultAgent ()
-            {
-              public Object getType() {
-                return AgentNameUtil.getAgentName(fType);
-              }
-
-              public String getAgentName() {
-                return AgentNameUtil.getAgentName(fBrowser);
-              }
-
-              public String getAgentVersion() {
-                return fAgentVersion;
-              }
-
-              public String getPlatFormName() {
-                return AgentNameUtil.getPlatformName(fPlatform);
-              }
-            };
-    return new AdfFacesAgentImpl(agent);
-  }
-
-  /**
-   * Get a default agent, that defines no characteristics.
-   *
-   * @return
-   */
-  public static AdfFacesAgent getUnknownAgent()
-  {
-    DefaultAgent adfAgent = new DefaultAgent();
-    return new AdfFacesAgentImpl(adfAgent);
-  }
-
-  /**
-   * Get agent for the current faces context
-   *
-   * @param context
-   * @return
-   */
-  public static AdfFacesAgent getAgent(FacesContext context)
-  {
-    Agent agent = AdfFacesContext.getCurrentInstance().getAgent();
-    if (agent instanceof AdfFacesAgent)
-      return (AdfFacesAgent) agent;
-
-    return new AdfFacesAgentImpl(context, agent);
-  }
-
-
-  /**
-   *
-   * Merge capabilities provided with the Agent capabilities
-   *
-   * @param agent  Agent to merge the capabilities with
-   * @param capabilities  List (array of {name, value}) capabilities that should be merged
-   * @return An Agent with the capabilities merged with the provided agent
-   */
-   //@TODO: Check this: Why is this called from an LookAndFeel.
-   //@Ideally the an Agent's display mode (called facet in uix22), should be
-   //@built into the capabilities repository, hence is should not be
-   //@look and feel sepecific
-  //=-=AEW: I don't believe this is a repository thing:  the concept
-  //of output mode is entirely renderkit specific, and the tweaks
-  //that are made to the capabilities are also renderkit specific.
-  public static AdfFacesAgent mergeCapabilities(AdfFacesAgent agent, Map capabilities)
-  {
-    if (!(agent instanceof AdfFacesAgentImpl))
-      throw new IllegalArgumentException("mergeCapabilities() may only be " +
-                                         "used with Agents created by this " +
-                                         "class.");
-    // Make a copy of the agent first
-    agent = (AdfFacesAgent) agent.clone();
-
-    // Then merge in the capabilities
-    // =-=AEW This codepath ends up creating copies of the
-    // capability map twice, once in clone(), once in __mergeCapabilities()
-    ((AdfFacesAgentImpl)agent).__mergeCapabilities(capabilities);
-
-    return agent;
-  }
-
+package org.apache.myfaces.adfinternal.agent;
+
+import java.util.Map;
+
+import org.apache.myfaces.adf.context.Agent;
+import org.apache.myfaces.adf.context.AdfFacesContext;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * agent util class
+ */
+public class AgentUtil
+{
+  /**
+   * Construct an AdfFacesAgent from agentType, agent application constant, agent version
+   * and plaform application constant
+   *
+   * //TODO: Check: if this is really needed
+   *
+   * @param type
+   * @param browser
+   * @param agentVersion
+   * @param platform
+   * @return
+   */
+  public static AdfFacesAgent getAgent(int type, int browser, String agentVersion, int platform)
+  {
+    final int fType = type;
+    final int fBrowser = browser;
+    final String fAgentVersion = agentVersion;
+    final int fPlatform = platform;
+
+    Agent agent =
+            new DefaultAgent ()
+            {
+              public Object getType() {
+                return AgentNameUtil.getAgentName(fType);
+              }
+
+              public String getAgentName() {
+                return AgentNameUtil.getAgentName(fBrowser);
+              }
+
+              public String getAgentVersion() {
+                return fAgentVersion;
+              }
+
+              public String getPlatFormName() {
+                return AgentNameUtil.getPlatformName(fPlatform);
+              }
+            };
+    return new AdfFacesAgentImpl(agent);
+  }
+
+  /**
+   * Get a default agent, that defines no characteristics.
+   *
+   * @return
+   */
+  public static AdfFacesAgent getUnknownAgent()
+  {
+    DefaultAgent adfAgent = new DefaultAgent();
+    return new AdfFacesAgentImpl(adfAgent);
+  }
+
+  /**
+   * Get agent for the current faces context
+   *
+   * @param context
+   * @return
+   */
+  public static AdfFacesAgent getAgent(FacesContext context)
+  {
+    Agent agent = AdfFacesContext.getCurrentInstance().getAgent();
+    if (agent instanceof AdfFacesAgent)
+      return (AdfFacesAgent) agent;
+
+    return new AdfFacesAgentImpl(context, agent);
+  }
+
+
+  /**
+   *
+   * Merge capabilities provided with the Agent capabilities
+   *
+   * @param agent  Agent to merge the capabilities with
+   * @param capabilities  List (array of {name, value}) capabilities that should be merged
+   * @return An Agent with the capabilities merged with the provided agent
+   */
+   //@TODO: Check this: Why is this called from an LookAndFeel.
+   //@Ideally the an Agent's display mode (called facet in uix22), should be
+   //@built into the capabilities repository, hence is should not be
+   //@look and feel sepecific
+  //=-=AEW: I don't believe this is a repository thing:  the concept
+  //of output mode is entirely renderkit specific, and the tweaks
+  //that are made to the capabilities are also renderkit specific.
+  public static AdfFacesAgent mergeCapabilities(AdfFacesAgent agent, Map capabilities)
+  {
+    if (!(agent instanceof AdfFacesAgentImpl))
+      throw new IllegalArgumentException("mergeCapabilities() may only be " +
+                                         "used with Agents created by this " +
+                                         "class.");
+    // Make a copy of the agent first
+    agent = (AdfFacesAgent) agent.clone();
+
+    // Then merge in the capabilities
+    // =-=AEW This codepath ends up creating copies of the
+    // capability map twice, once in clone(), once in __mergeCapabilities()
+    ((AdfFacesAgentImpl)agent).__mergeCapabilities(capabilities);
+
+    return agent;
+  }
+
 }

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/AgentUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/CapabilitiesProvider.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/CapabilitiesProvider.java?rev=425276&r1=425275&r2=425276&view=diff
==============================================================================
--- incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/CapabilitiesProvider.java (original)
+++ incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/CapabilitiesProvider.java Mon Jul 24 21:42:41 2006
@@ -13,213 +13,213 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adfinternal.agent;
-
-import org.apache.myfaces.adf.context.Agent;
-import org.apache.myfaces.adf.logging.ADFLogger;
-import org.apache.myfaces.adfinternal.agent.parse.CapabilitiesDocument;
-import org.apache.myfaces.adfinternal.agent.parse.CapabilitiesDocumentParser;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.net.URL;
-
-/**
- * An implementation of Capabilities Provider. The Capabilities provider
- * provides capabilities (CapabilityMap) for the context Agent from
- * a configured capabilities store (currently XML files)
- *
- */
-public class CapabilitiesProvider
-{
-
-  /**
-   * @param capUrl URL to the capabilities document defining the
-   * capabilities for various clients/agents
-   * //TODO: Right now all capabilities get an Key. Do we really need to that?
-   * //--why should we create a key for capabilities we don't care?
-   */
-  private CapabilitiesProvider(URL capUrl)
-  {
-    _capUrl = capUrl;
-  }
-
-  /**
-   * @param capUrl URL to the capabilities document defining the
-   * capabilities for various clients/agents
-   * @return A provider of Capabilities based on the context Agent
-   */
-  static public CapabilitiesProvider getCapabilitiesProvider(URL capUrl)
-  {
-    //getCapabilitiesProvider
-    //--Are we really going to support multiple files??
-    CapabilitiesProvider provider = null;
-    Map providerMap = _getProviderMap();
-    synchronized (providerMap)
-    {
-      provider = (CapabilitiesProvider) providerMap.get(capUrl);
-      if (provider == null)
-      {
-        provider = new CapabilitiesProvider(capUrl);
-        providerMap.put(capUrl, provider);
-      }
-    }
-    return provider;
-  }
-
-  /**
-   * @param agent Agent for which the capabilities are to be evaluated
-   * @return capability map that has merged capabilities from the Agent provided and
-   *         capabilities defined in the configured provider
-   */
-  public CapabilityMap getCapabilities(Agent agent)
-  {
-    if (agent == null)
-      return _EMPTY_MAP;
-
-    //get out of cache
-    CapabilityMap caps = null;
-    CacheKey key = new CacheKey(agent);
-    synchronized (this) {
-      try
-      {
-        caps = (CapabilityMap) _sCache.get(key);
-
-        //if not in cache, acquire
-        if (caps == null)
-        {
-          caps = _getCapabilities(agent);
-          _sCache.put(key, caps);
-        }
-      }
-      catch (RuntimeException re)
-      {
-        _LOG.severe("could not get capabilities from capabilities document", re);
-      }
-    }
-
-    //finally merge the capabilities of the current agent
-    //and the capabilities we acquired
-    caps = caps.merge(agent.getCapabilities());
-    return (caps);
-  }
-
-
-  private CapabilityMap _getCapabilities(Agent agent)
-  {
-    CapabilitiesDocument doc = _getCapabilityDocument();
-    Object[][] capArray = doc.getCapabilities(agent);
-    if (capArray != null)
-      return new CapabilityMap(capArray);
-
-    return _EMPTY_MAP;
-  }
-
-
-  private CapabilitiesDocument _getCapabilityDocument()
-  {
-    if (_document != null)
-      return _document;
-
-    synchronized (this)
-    {
-      if (_document == null)
-      {
-        CapabilitiesDocument doc =
-                CapabilitiesDocumentParser.createInstance(_capUrl);
-        _document = doc;
-      }
-    }
-
-    return _document;
-  }
-
-  static private Map _getProviderMap()
-  {
-    return _providerMap;
-  }
-
-  /**
-   * Cachekey for the Agent
-   */
-  static private class CacheKey
-  {
-    CacheKey(Agent ag)
-    {
-      _agentName = ag.getAgentName();
-      if (_agentName == null)
-        _agentName = _EMPTY;
-
-      _agentVersion = ag.getAgentVersion();
-      if (_agentVersion == null)
-        _agentVersion = _EMPTY;
-
-      _platformName = ag.getPlatformName();
-      if (_platformName == null)
-        _platformName = _EMPTY;
-
-      _platformVersion = ag.getPlatformVersion();
-      if (_platformVersion == null)
-        _platformVersion = _EMPTY;
-
-      _hardwareMakeModel = null;
-      if (_hardwareMakeModel == null)
-        _hardwareMakeModel = _EMPTY;
-
-      //pre compute the hash code
-      _hashCode = _agentName.hashCode() ^
-                  _agentVersion.hashCode() ^
-                  _platformName.hashCode() ^
-                  _platformVersion.hashCode() ^
-                  _hardwareMakeModel.hashCode();
-
-    }
-
-    public int hashCode()
-    {
-      return _hashCode;
-    }
-
-    public boolean equals(Object obj)
-    {
-      if (obj == this)
-        return true;
-      if (!(obj instanceof CacheKey))
-        return false;
-      CacheKey key = (CacheKey) obj;
-
-      if ((_agentName.equals(key._agentName)) &&
-          _agentVersion.equals(key._agentVersion) &&
-          _platformName.equals(key._platformName) &&
-          _platformVersion.equals(key._platformVersion) &&
-          _hardwareMakeModel.equals(key._hardwareMakeModel))
-        return true;
-
-      return false;
-    }
-
-    private Object _agentName;
-    private Object _agentVersion;
-    private Object _platformName;
-    private Object _platformVersion;
-    private Object _hardwareMakeModel;
-    private int _hashCode;
-
-    static final private Object _EMPTY = new Object();
-  }
-
-
-  private URL _capUrl;
-  private CapabilitiesDocument _document;
-
-  static private CapabilityMap _EMPTY_MAP = new CapabilityMap(new Object[0][0]);
-
-  //@todo: The caches are global. Should we store in SC?
-  //@todo: Use an LRU, to limit number of entries
-  static private HashMap _sCache = new HashMap(64);
-
-
-  static private Map _providerMap = new HashMap(4);
-  static final private ADFLogger _LOG = ADFLogger.createADFLogger(CapabilitiesProvider.class);
-
-}
+package org.apache.myfaces.adfinternal.agent;
+
+import org.apache.myfaces.adf.context.Agent;
+import org.apache.myfaces.adf.logging.ADFLogger;
+import org.apache.myfaces.adfinternal.agent.parse.CapabilitiesDocument;
+import org.apache.myfaces.adfinternal.agent.parse.CapabilitiesDocumentParser;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.net.URL;
+
+/**
+ * An implementation of Capabilities Provider. The Capabilities provider
+ * provides capabilities (CapabilityMap) for the context Agent from
+ * a configured capabilities store (currently XML files)
+ *
+ */
+public class CapabilitiesProvider
+{
+
+  /**
+   * @param capUrl URL to the capabilities document defining the
+   * capabilities for various clients/agents
+   * //TODO: Right now all capabilities get an Key. Do we really need to that?
+   * //--why should we create a key for capabilities we don't care?
+   */
+  private CapabilitiesProvider(URL capUrl)
+  {
+    _capUrl = capUrl;
+  }
+
+  /**
+   * @param capUrl URL to the capabilities document defining the
+   * capabilities for various clients/agents
+   * @return A provider of Capabilities based on the context Agent
+   */
+  static public CapabilitiesProvider getCapabilitiesProvider(URL capUrl)
+  {
+    //getCapabilitiesProvider
+    //--Are we really going to support multiple files??
+    CapabilitiesProvider provider = null;
+    Map providerMap = _getProviderMap();
+    synchronized (providerMap)
+    {
+      provider = (CapabilitiesProvider) providerMap.get(capUrl);
+      if (provider == null)
+      {
+        provider = new CapabilitiesProvider(capUrl);
+        providerMap.put(capUrl, provider);
+      }
+    }
+    return provider;
+  }
+
+  /**
+   * @param agent Agent for which the capabilities are to be evaluated
+   * @return capability map that has merged capabilities from the Agent provided and
+   *         capabilities defined in the configured provider
+   */
+  public CapabilityMap getCapabilities(Agent agent)
+  {
+    if (agent == null)
+      return _EMPTY_MAP;
+
+    //get out of cache
+    CapabilityMap caps = null;
+    CacheKey key = new CacheKey(agent);
+    synchronized (this) {
+      try
+      {
+        caps = (CapabilityMap) _sCache.get(key);
+
+        //if not in cache, acquire
+        if (caps == null)
+        {
+          caps = _getCapabilities(agent);
+          _sCache.put(key, caps);
+        }
+      }
+      catch (RuntimeException re)
+      {
+        _LOG.severe("could not get capabilities from capabilities document", re);
+      }
+    }
+
+    //finally merge the capabilities of the current agent
+    //and the capabilities we acquired
+    caps = caps.merge(agent.getCapabilities());
+    return (caps);
+  }
+
+
+  private CapabilityMap _getCapabilities(Agent agent)
+  {
+    CapabilitiesDocument doc = _getCapabilityDocument();
+    Object[][] capArray = doc.getCapabilities(agent);
+    if (capArray != null)
+      return new CapabilityMap(capArray);
+
+    return _EMPTY_MAP;
+  }
+
+
+  private CapabilitiesDocument _getCapabilityDocument()
+  {
+    if (_document != null)
+      return _document;
+
+    synchronized (this)
+    {
+      if (_document == null)
+      {
+        CapabilitiesDocument doc =
+                CapabilitiesDocumentParser.createInstance(_capUrl);
+        _document = doc;
+      }
+    }
+
+    return _document;
+  }
+
+  static private Map _getProviderMap()
+  {
+    return _providerMap;
+  }
+
+  /**
+   * Cachekey for the Agent
+   */
+  static private class CacheKey
+  {
+    CacheKey(Agent ag)
+    {
+      _agentName = ag.getAgentName();
+      if (_agentName == null)
+        _agentName = _EMPTY;
+
+      _agentVersion = ag.getAgentVersion();
+      if (_agentVersion == null)
+        _agentVersion = _EMPTY;
+
+      _platformName = ag.getPlatformName();
+      if (_platformName == null)
+        _platformName = _EMPTY;
+
+      _platformVersion = ag.getPlatformVersion();
+      if (_platformVersion == null)
+        _platformVersion = _EMPTY;
+
+      _hardwareMakeModel = null;
+      if (_hardwareMakeModel == null)
+        _hardwareMakeModel = _EMPTY;
+
+      //pre compute the hash code
+      _hashCode = _agentName.hashCode() ^
+                  _agentVersion.hashCode() ^
+                  _platformName.hashCode() ^
+                  _platformVersion.hashCode() ^
+                  _hardwareMakeModel.hashCode();
+
+    }
+
+    public int hashCode()
+    {
+      return _hashCode;
+    }
+
+    public boolean equals(Object obj)
+    {
+      if (obj == this)
+        return true;
+      if (!(obj instanceof CacheKey))
+        return false;
+      CacheKey key = (CacheKey) obj;
+
+      if ((_agentName.equals(key._agentName)) &&
+          _agentVersion.equals(key._agentVersion) &&
+          _platformName.equals(key._platformName) &&
+          _platformVersion.equals(key._platformVersion) &&
+          _hardwareMakeModel.equals(key._hardwareMakeModel))
+        return true;
+
+      return false;
+    }
+
+    private Object _agentName;
+    private Object _agentVersion;
+    private Object _platformName;
+    private Object _platformVersion;
+    private Object _hardwareMakeModel;
+    private int _hashCode;
+
+    static final private Object _EMPTY = new Object();
+  }
+
+
+  private URL _capUrl;
+  private CapabilitiesDocument _document;
+
+  static private CapabilityMap _EMPTY_MAP = new CapabilityMap(new Object[0][0]);
+
+  //@todo: The caches are global. Should we store in SC?
+  //@todo: Use an LRU, to limit number of entries
+  static private HashMap _sCache = new HashMap(64);
+
+
+  static private Map _providerMap = new HashMap(4);
+  static final private ADFLogger _LOG = ADFLogger.createADFLogger(CapabilitiesProvider.class);
+
+}

Propchange: incubator/adffaces/branches/matzew-repackaging-trinidad/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/adfinternal/agent/CapabilitiesProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message