DefaultPlateform.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2006 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: pdelrieu@openmobileis.org
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  /*   Properties propss  = System.getProperties();
00048     Enumeration en = propss.keys();
00049     while (en.hasMoreElements())        {
00050         String key = (String)en.nextElement();
00051         String value = propss.getProperty(key);
00052         System.out.println("System props :"+key+" val:"+value);
00053     }  */
00054     
00055     //manage OS
00056     Properties props = System.getProperties();
00057     String osname = props.getProperty("os.name");
00058     if (osname.indexOf("Linux") != -1)  {
00059       this.os = Plateform.LINUXOS;
00060     } else  if (osname.indexOf("Windows CE")!=-1) {
00061  //   } else  if (osname.indexOf("PPC")!=-1) {
00062       this.os = Plateform.POCKETPCOS;
00063     } else  if (osname.indexOf("Windows")!=-1) {
00064       this.os = Plateform.WINOS;
00065     } else  {
00066       this.os = Plateform.UNKNOWNOS;
00067     }
00068     
00069     //os version
00070     this.osversion = props.getProperty("os.version");
00071     
00072     //jvm vendor
00073     this.jvm = props.getProperty("java.vendor");
00074     
00075     //jvm spec
00076     this.jvmspec = props.getProperty("java.specification.version");
00077     
00078     //trace info for test
00079  //   this.main(null);
00080     
00081     
00082   }
00083 
00084   /* (non-Javadoc)
00085    * @see org.openmobileis.common.context.Plateform#getOS()
00086    */
00087   public String getOS() {
00088      return this.os;
00089   }
00090 
00091   /* (non-Javadoc)
00092    * @see org.openmobileis.common.context.Plateform#getOSVersion()
00093    */
00094   public String getOSVersion() {
00095     return this.osversion;
00096   }
00097 
00098   /* (non-Javadoc)
00099    * @see org.openmobileis.common.context.Plateform#getJVM()
00100    */
00101   public String getJVMVendor() {
00102     return this.jvm;
00103   }
00104   
00110   public String getJVMSpecificationVersion()  {
00111     return this.jvmspec;
00112   }
00113 
00114   /* (non-Javadoc)
00115    * @see org.openmobileis.common.context.Plateform#getOpenMobileISMajorVersion()
00116    */
00117   public String getOpenMobileISMajorVersion() {
00118     return "1";
00119   }
00120 
00121   /* (non-Javadoc)
00122    * @see org.openmobileis.common.context.Plateform#getOpenMobileISMinorVersion()
00123    */
00124   public String getOpenMobileISMinorVersion() {
00125    return "R2";
00126   }
00127   
00128   public static void main(String[] args) {
00129     Properties props = System.getProperties();
00130     Enumeration enume = props.keys();
00131     while (enume.hasMoreElements()) {
00132       String key = (String) enume.nextElement();
00133       System.out.println("Property :"+key+" value:"+props.getProperty(key));
00134     }
00135   }
00136 
00137         public void setJvm(String jvm) {
00138                 this.jvm = jvm;
00139         }
00140 
00141         public void setJvmspec(String jvmspec) {
00142                 this.jvmspec = jvmspec;
00143         }
00144 
00145         public void setOs(String os) {
00146                 this.os = os;
00147         }
00148 
00149         public void setOsversion(String osversion) {
00150                 this.osversion = osversion;
00151         }
00152 
00153 }

Generated on Mon Jan 11 21:19:14 2010 for OpenMobileIS by  doxygen 1.5.4