You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ra...@apache.org on 2001/04/27 13:52:10 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/capability ClientCapabilityMap.java

raphael     01/04/27 04:52:10

  Modified:    src/java/org/apache/jetspeed/capability
                        ClientCapabilityMap.java
  Log:
  Add base VXML support based on patch from Manjuka Soysa <ma...@visto.com>
  
  Revision  Changes    Path
  1.9       +50 -21    jakarta-jetspeed/src/java/org/apache/jetspeed/capability/ClientCapabilityMap.java
  
  Index: ClientCapabilityMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/capability/ClientCapabilityMap.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ClientCapabilityMap.java	2001/03/12 19:02:11	1.8
  +++ ClientCapabilityMap.java	2001/04/27 11:52:10	1.9
  @@ -66,19 +66,19 @@
   handle more browsers.
   
   @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
  -@version $Id: ClientCapabilityMap.java,v 1.8 2001/03/12 19:02:11 sgala Exp $
  +@version $Id: ClientCapabilityMap.java,v 1.9 2001/04/27 11:52:10 raphael Exp $
   */
   public class ClientCapabilityMap extends BaseCapabilityMap implements CapabilityMap {
   
       private String      browser = "";
       private int         version = 0;
  -    
  +
       /**
       Strings for devices that support WAP.  These agent has to have these
       as the start string.
  -    
  +
       */
  -    private static final String[] WAP_DEVICES_STARTS = 
  +    private static final String[] WAP_DEVICES_STARTS =
       {
           "UP.",
           "Nokia",
  @@ -100,14 +100,23 @@
       };
   
       /**
  +     * Strings for devices supporting Voice XML
  +     */
  +    private static final String[] VOICE_DEVICES_CONTAINS =
  +    {
  +        "VoiceXML",
  +        "Nuance"
  +    };
  +
  +    /**
       Builds a new capability map.
       */
       protected ClientCapabilityMap( String useragent ) {
           setAgent( useragent );
  -        parseUserAgent();        
  +        parseUserAgent();
           findCapability();
       }
  -    
  +
       /**
       Parses a HTTP compliant User-agent string and creates internal tokens
       for the browser and its version.
  @@ -117,28 +126,28 @@
       private void parseUserAgent() {
           String useragent = getAgent();
           StringTokenizer st = new StringTokenizer( useragent, "/; ()" );
  -        
  +
           try {
               browser = st.nextToken();
               version = Math.round( Float.valueOf( st.nextToken() )
                      .floatValue() );
  -            
  +
               while ( st.hasMoreTokens() ) {
                   if ( "MSIE".equals( st.nextToken() ) ) {
                       browser = "MSIE";
                   }
               }
  -            
  +
           } catch (Exception e) {
               // malformed useragent
               browser = "";
               version = 0;
           }
  -        
  +
           browser = browser.toLowerCase();
  -        
  +
       }
  -     
  +
       /**
       Analyzes the currently stored user-agent to determine its capabilities
       */
  @@ -174,7 +183,7 @@
               setCapability( HTML_IMAGE );
               setCapability( HTML_TABLE );
               switch ( version ) {
  -                
  +
                   default:
                   case 5:
                      setCapability( HTML_XML );
  @@ -193,14 +202,16 @@
                      setCapability( HTML_FRAME );
                   case 2:
              }
  -        } 
  -        
  +        }
  +
           //go through each WAP device
           determineWAP();
  -        
  -        
  +
  +        //go through VoiceXML devices
  +        determineVoice();
  +
       }
  -    
  +
       /**
       Go through the given array fo strings and if this matches set WML MimeTypes
       correctly.
  @@ -213,16 +224,34 @@
                   this.setPreferredType( MimeType.WML );
                   this.setMimeTypes( MimeType.WML );
                   break;
  -            }            
  +            }
           }
  -        
  +
           for( int i = 0; i < WAP_DEVICES_CONTAINS.length; ++i ) {
   
               if ( this.getAgent().indexOf( WAP_DEVICES_CONTAINS[i] ) != -1 ) {
                   this.setPreferredType( MimeType.WML );
                   this.setMimeTypes( MimeType.WML );
  +                break;
  +            }
  +        }
  +
  +
  +    }
  +
  +    /**
  +    Go through the given array fo strings and if this matches set WML MimeTypes
  +    correctly.
  +    */
  +    private void determineVoice() {
  +
  +        for( int i = 0; i < VOICE_DEVICES_CONTAINS.length; ++i ) {
  +
  +            if ( this.getAgent().indexOf( VOICE_DEVICES_CONTAINS[i] ) != -1 ) {
  +                this.setPreferredType( MimeType.VXML );
  +                this.setMimeTypes( MimeType.VXML );
                   break;
  -            }            
  +            }
           }
   
   
  
  
  

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