Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

DefaultPlateform.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2005 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: openmobileis@e-care.fr
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA
00021  *
00022  *  Author : Philippe Delrieu
00023  * 
00024  */
00025 package org.openmobileis.common.context;
00026 
00027 import java.util.Enumeration;
00028 import java.util.Properties;
00029 
00037 public class DefaultPlateform implements Plateform {
00038   public String os;
00039   public String osversion;
00040   public String jvm;
00041   public String jvmspec;
00045   public DefaultPlateform() {
00046     super();
00047     //manage OS
00048     Properties props = System.getProperties();
00049     String osname = props.getProperty("os.name");
00050     if (osname.indexOf("Linux") != -1)  {
00051       this.os = Plateform.LINUXOS;
00052     } else  if (osname.indexOf("Windows CE")!=-1) {
00053  //   } else  if (osname.indexOf("PPC")!=-1) {
00054       this.os = Plateform.POCKETPCOS;
00055     } else  if (osname.indexOf("Windows")!=-1) {
00056       this.os = Plateform.WINOS;
00057     } else  {
00058       this.os = Plateform.UNKNOWNOS;
00059     }
00060     
00061     //os version
00062     this.osversion = props.getProperty("os.version");
00063     
00064     //jvm vendor
00065     this.jvm = props.getProperty("java.vendor");
00066     
00067     //jvm spec
00068     this.jvmspec = props.getProperty("java.specification.version");
00069     
00070     //trace info for test
00071  //   this.main(null);
00072     
00073     
00074   }
00075 
00076   /* (non-Javadoc)
00077    * @see org.openmobileis.common.context.Plateform#getOS()
00078    */
00079   public String getOS() {
00080      return this.os;
00081   }
00082 
00083   /* (non-Javadoc)
00084    * @see org.openmobileis.common.context.Plateform#getOSVersion()
00085    */
00086   public String getOSVersion() {
00087     return this.osversion;
00088   }
00089 
00090   /* (non-Javadoc)
00091    * @see org.openmobileis.common.context.Plateform#getJVM()
00092    */
00093   public String getJVMVendor() {
00094     return this.jvm;
00095   }
00096   
00102   public String getJVMSpecificationVersion()  {
00103     return this.jvmspec;
00104   }
00105 
00106   /* (non-Javadoc)
00107    * @see org.openmobileis.common.context.Plateform#getOpenMobileISMajorVersion()
00108    */
00109   public String getOpenMobileISMajorVersion() {
00110     return "1";
00111   }
00112 
00113   /* (non-Javadoc)
00114    * @see org.openmobileis.common.context.Plateform#getOpenMobileISMinorVersion()
00115    */
00116   public String getOpenMobileISMinorVersion() {
00117    return "R2";
00118   }
00119   
00120   public static void main(String[] args) {
00121     Properties props = System.getProperties();
00122     Enumeration enume = props.keys();
00123     while (enume.hasMoreElements()) {
00124       String key = (String) enume.nextElement();
00125       System.out.println("Property :"+key+" value:"+props.getProperty(key));
00126     }
00127   }
00128 
00129 }

Generated on Wed Dec 14 21:05:32 2005 for OpenMobileIS by  doxygen 1.4.4