001: /*
002: * CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003: * NETSCAPE COMMUNICATIONS CORPORATION
004: *
005: * Copyright (c) 1996 Netscape Communications Corporation.
006: * All Rights Reserved.
007: * Use of this Source Code is subject to the terms of the applicable
008: * license agreement from Netscape Communications Corporation.
009: */
010:
011: package util;
012:
013: /**
014: Encapsulate platform information.
015: *
016: */
017: public class SysInfo {
018: /**
019: * Operating system name.
020: */
021: String osName;
022: /**
023: * System architecture.
024: */
025: String osArch;
026: /**
027: * Operating system version.
028: */
029: String osVersion;
030:
031: /**
032: * Is a windoze system.
033: */
034: private boolean isW;
035: /**
036: * Is a mac system.
037: */
038: private boolean isM;
039: /**
040: * Is a unix system.
041: */
042: private boolean isU;
043:
044: /**
045: * Ye olde constructor.
046: */
047: public SysInfo() {
048: super ();
049:
050: osName = System.getProperty("os.name");
051: osArch = System.getProperty("os.arch");
052: osVersion = System.getProperty("os.version");
053:
054: isW = false;
055: isM = false;
056:
057: if ((osName.compareTo((String) "Windows NT") == 0)
058: || (osName.compareTo((String) "Windows 95") == 0)) {
059: isW = true;
060: }
061:
062: if (osArch.compareTo((String) "Pentium") == 0) {
063: isW = true;
064: }
065:
066: if (osName.compareTo((String) "Mac OS") == 0) {
067: isM = true;
068: }
069:
070: if (osArch.compareTo((String) "PowerPC") == 0) {
071: isM = true;
072: }
073:
074: isU = (isM || isW) ? false : true;
075: }
076:
077: /**
078: * Returns whether the system is windoze or not.
079: */
080: public boolean isWindows() {
081: return isW;
082: }
083:
084: /**
085: * Returns whether the system is mac or not.
086: */
087: public boolean isMac() {
088: return isM;
089: }
090:
091: /**
092: * Returns whether the system is unix or not.
093: */
094: public boolean isUnix() {
095: return isU;
096: }
097:
098: /**
099: * True or false - is the os name known?
100: */
101: public boolean osNameKnown() {
102: if (osName.compareTo((String) "Windows NT") == 0) {
103: return true;
104: }
105:
106: if (osName.compareTo((String) "Windows 95") == 0) {
107: return true;
108: }
109:
110: if (osName.compareTo((String) "SunOS") == 0) {
111: return true;
112: }
113:
114: if (osName.compareTo((String) "Mac OS") == 0) {
115: return true;
116: }
117:
118: return false;
119: }
120:
121: /**
122: * True or false - is the architecture known?
123: */
124: public boolean osArchKnown() {
125: if (osArch.compareTo((String) "Pentium") == 0) {
126: return true;
127: }
128:
129: if (osArch.compareTo((String) "sparc") == 0) {
130: return true;
131: }
132:
133: if (osArch.compareTo((String) "PowerPC") == 0) {
134: return true;
135: }
136:
137: return false;
138: }
139:
140: /**
141: * True or false - is the version known?
142: */
143: public boolean osVersionKnown() {
144: if (osVersion.compareTo((String) "3.51") == 0) {
145: return true;
146: }
147:
148: if (osVersion.compareTo((String) "4.0") == 0) {
149: return true;
150: }
151:
152: if (osVersion.compareTo((String) "5.4") == 0) {
153: return true;
154: }
155:
156: if (osVersion.compareTo((String) "7.5") == 0) {
157: return true;
158: }
159:
160: return false;
161: }
162:
163: /**
164: * True or false - is the system known?
165: */
166: public boolean isKnown() {
167: if (osNameKnown() == false) {
168: return false;
169: }
170:
171: if (osArchKnown() == false) {
172: return false;
173: }
174:
175: if (osVersionKnown() == false) {
176: return false;
177: }
178:
179: return true;
180: }
181:
182: public String toString() {
183: return "SysInfo: " + " osName [" + osName + " ("
184: + ((osNameKnown() == true) ? "known" : "unknown")
185: + ")]," + " osArch [" + osArch + " ("
186: + ((osArchKnown() == true) ? "known" : "unknown")
187: + ")]," + " osVersion [" + osVersion + " ("
188: + ((osVersionKnown() == true) ? "known" : "unknown")
189: + ")]" + " isW [" + isW + "]" + " isM [" + isM + "]"
190: + " isU [" + isU + "]";
191: }
192: }
|