packagecom.fly.jenkins.util;/*** Operating system class: get System.getproperty ("os.name") corresponding to the operating system * *@authorisea533*/ public classOSinfo {Private StaticString OS = System.getproperty ("os.name"). toLowerCase (); Private StaticOSinfo _instance =NewOSinfo (); PrivateEplatform platform; PrivateOSinfo () {} public Static Booleanislinux () {returnOs.indexof ("linux") >= 0; } public Static BooleanIsmacos () {returnOs.indexof ("mac") >= 0 && os.indexof ("OS") > 0 && os.indexof ("x") < 0; } public Static Booleanismacosx () {returnOs.indexof ("mac") >= 0 && os.indexof ("OS") > 0 && os.indexof ("x") > 0; } public Static Booleaniswindows () {returnOs.indexof ("windows") >= 0; } public Static BooleanisOS2 () {returnOs.indexof ("os/2") >= 0; } public Static BooleanIssolaris () {returnOs.indexof ("solaris") >= 0; } public Static BooleanIssunos () {returnOs.indexof ("sunos") >= 0; } public Static BooleanIsmpeix () {returnOs.indexof ("mpe/ix") >= 0; } public Static Booleanishpux () {returnOs.indexof ("hp-ux") >= 0; } public Static BooleanIsaix () {returnOs.indexof ("aix") >= 0; } public Static BooleanisOS390 () {returnOs.indexof ("os/390") >= 0; } public Static BooleanIsfreebsd () {returnOs.indexof ("freebsd") >= 0; } public Static BooleanIsirix () {returnOs.indexof ("irix") >= 0; } public Static BooleanIsdigitalunix () {returnOs.indexof ("digital") >= 0 && os.indexof ("unix") > 0; } public Static Booleanisnetware () {returnOs.indexof ("netware") >= 0; } public Static BooleanisOSF1 () {returnOs.indexof ("osf1") >= 0; } public Static BooleanIsopenvms () {returnOs.indexof ("openvms") >= 0; } /*** Get Operating system name * *@returnOperating system name*/ public Staticeplatform getosname () {if(isaix ()) {_instance.platform=eplatform.aix; } Else if(isdigitalunix ()) {_instance.platform=eplatform.digital_unix; } Else if(isfreebsd ()) {_instance.platform=eplatform.freebsd; } Else if(ishpux ()) {_instance.platform=eplatform.hp_ux; } Else if(isirix ()) {_instance.platform=eplatform.irix; } Else if(islinux ()) {_instance.platform=eplatform.linux; } Else if(ismacos ()) {_instance.platform=eplatform.mac_os; } Else if(ismacosx ()) {_instance.platform=eplatform.mac_os_x; } Else if(ismpeix ()) {_instance.platform=eplatform.mpeix; } Else if(isnetware ()) {_instance.platform=eplatform.netware_411; } Else if(isopenvms ()) {_instance.platform=eplatform.openvms; } Else if(isOS2 ()) {_instance.platform=eplatform.os2; } Else if(isOS390 ()) {_instance.platform=eplatform.os390; } Else if(isOSF1 ()) {_instance.platform=eplatform.osf1; } Else if(issolaris ()) {_instance.platform=eplatform.solaris; } Else if(issunos ()) {_instance.platform=eplatform.sunos; } Else if(iswindows ()) {_instance.platform=eplatform.windows; } Else{_instance.platform=eplatform.others; } return_instance.platform; } /** * @paramargs*/ public Static voidmain (string[] Args) {System.out.println (osinfo.getosname ()); } /*** Platform * *@authorisea533*/ public enumeplatform {any ("any"), linux ("linux"), mac_os ("mac os"), mac_os_x ("mac os X"), windows ("windows"), OS2 ("os/2"), Solaris ("Solaris"), SunOS ("SunOS"), Mpeix ("mpe/ix"), hp_ux ("hp-ux"), Aix ("aix"), OS390 ("os/390"), FreeBSD ("FreeBSD"), Irix ("Irix"), Digital_unix ("Digital Unix"), netware_411 ("NetWare"), OSF1 ("OSF1"), OpenVMS ("OpenVMS"), Others ("Others")); Privateeplatform (String Desc) { this. Description =desc; } publicString toString () {returndescription; } PrivateString description; }}
Java Tools Class (gets the current host operating system Name)