001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * SystemInfo.java
044: *
045: * Created on November 1, 2001, 6:33 PM
046: */
047:
048: package org.netbeans.xtest.pe.xmlbeans;
049:
050: // for getting hostname
051: import java.net.InetAddress;
052: import java.net.UnknownHostException;
053:
054: /**
055: *
056: * @author mb115822
057: */
058: public class SystemInfo extends XMLBean {
059:
060: /** Creates new SystemInfo */
061: public SystemInfo() {
062: getCurrentSystemInfo();
063: }
064:
065: // attributes
066: public String xmlat_host;
067: public String xmlat_osArch;
068: public String xmlat_osName;
069: public String xmlat_osVersion;
070: public String xmlat_javaVendor;
071: public String xmlat_javaVersion;
072: public String xmlat_userLanguage;
073: public String xmlat_userRegion;
074:
075: /** Holds value of property osArch. */
076: private String osArch;
077:
078: // bussiness methods
079:
080: public static String getCurrentHost() {
081: // if xtest.machine set use it, otherwise try to get it. Used in test4u.
082: String host = System.getProperty("xtest.machine");
083: if (host == null) {
084: try {
085: host = InetAddress.getLocalHost().getHostName();
086: } catch (UnknownHostException uhe) {
087: // we cannot get the hostname
088: host = "UnknownHost";
089: }
090: }
091: return host;
092: }
093:
094: public static String getCurrentOsArch() {
095: return System.getProperty("os.arch");
096: }
097:
098: public static String getCurrentOsName() {
099: return System.getProperty("os.name");
100: }
101:
102: public static String getCurrentOsVersion() {
103: return System.getProperty("os.version");
104: }
105:
106: public static String getCurrentJavaVendor() {
107: return System.getProperty("java.vendor");
108: }
109:
110: public static String getCurrentJavaVersion() {
111: return System.getProperty("java.version");
112: }
113:
114: public static String getCurrentUserLanguage() {
115: return System.getProperty("user.language");
116: }
117:
118: public static String getCurrentUserRegion() {
119: return System.getProperty("user.region");
120: }
121:
122: public static String getCurrentPlatform() {
123: return "OS: " + getCurrentOsName() + " "
124: + getCurrentOsVersion() + " " + getCurrentOsArch()
125: + ", JDK: " + getCurrentJavaVersion() + " "
126: + getCurrentJavaVendor();
127: }
128:
129: public void getCurrentSystemInfo() {
130: xmlat_host = getCurrentHost();
131: xmlat_osArch = getCurrentOsArch();
132: xmlat_osName = getCurrentOsName();
133: xmlat_osVersion = getCurrentOsVersion();
134: xmlat_javaVendor = getCurrentJavaVendor();
135: xmlat_javaVersion = getCurrentJavaVersion();
136: xmlat_userLanguage = getCurrentUserLanguage();
137: xmlat_userRegion = getCurrentUserRegion();
138: }
139:
140: public void readSystemInfo(SystemInfo si) {
141: xmlat_osArch = si.xmlat_osArch;
142: xmlat_osName = si.xmlat_osName;
143: xmlat_osVersion = si.xmlat_osVersion;
144: xmlat_javaVendor = si.xmlat_javaVendor;
145: xmlat_javaVersion = si.xmlat_javaVersion;
146: xmlat_host = si.xmlat_host;
147: xmlat_userLanguage = si.xmlat_userLanguage;
148: xmlat_userRegion = si.xmlat_userRegion;
149: }
150:
151: /** Getter for property host.
152: * @return Value of property host.
153: */
154: public String getHost() {
155: return xmlat_host;
156: }
157:
158: /** Setter for property host.
159: * @param host New value of property host.
160: */
161: public void setHost(String host) {
162: xmlat_host = host;
163: }
164:
165: /** Getter for property osArch.
166: * @return Value of property osArch.
167: */
168: public String getOsArch() {
169: return xmlat_osArch;
170: }
171:
172: /** Setter for property osArch.
173: * @param osArch New value of property osArch.
174: */
175: public void setOsArch(String osArch) {
176: xmlat_osArch = osArch;
177: }
178:
179: /** Getter for property osName.
180: * @return Value of property osName.
181: */
182: public String getOsName() {
183: return xmlat_osName;
184: }
185:
186: /** Setter for property osName.
187: * @param osName New value of property osName.
188: */
189: public void setOsName(String osName) {
190: xmlat_osName = osName;
191: }
192:
193: /** Getter for property osVersion.
194: * @return Value of property osVersion.
195: */
196: public String getOsVersion() {
197: return xmlat_osVersion;
198: }
199:
200: /** Setter for property osVersion.
201: * @param osVersion New value of property osVersion.
202: */
203: public void setOsVersion(String osVersion) {
204: xmlat_osVersion = osVersion;
205: }
206:
207: /** Getter for property javaVendor.
208: * @return Value of property javaVendor.
209: */
210: public String getJavaVendor() {
211: return xmlat_javaVendor;
212: }
213:
214: /** Setter for property javaVendor.
215: * @param javaVendor New value of property javaVendor.
216: */
217: public void setJavaVendor(String javaVendor) {
218: xmlat_javaVendor = javaVendor;
219: }
220:
221: /** Getter for property javaVersion.
222: * @return Value of property javaVersion.
223: */
224: public String getJavaVersion() {
225: return xmlat_javaVersion;
226: }
227:
228: /** Setter for property javaVersion.
229: * @param javaVersion New value of property javaVersion.
230: */
231: public void setJavaVersion(String javaVersion) {
232: xmlat_javaVersion = javaVersion;
233: }
234:
235: /** Getter for property userLanguage.
236: * @return Value of property userLanguage.
237: */
238: public String getUserLanguage() {
239: return xmlat_userLanguage;
240: }
241:
242: /** Setter for property userLanguage.
243: * @param userLanguage New value of property userLanguage.
244: */
245: public void setUserLanguage(String userLanguage) {
246: xmlat_userLanguage = userLanguage;
247: }
248:
249: /** Getter for property userRegion.
250: * @return Value of property userRegion.
251: */
252: public String getUserRegion() {
253: return xmlat_userRegion;
254: }
255:
256: /** Setter for property userRegion.
257: * @param userRegion New value of property userRegion.
258: */
259: public void setUserRegion(String userRegion) {
260: xmlat_userRegion = userRegion;
261: }
262:
263: }
|