001: /*
002: *
003: * Copyright (c) 2000-2001 Silvere Martin-Michiellot All Rights Reserved.
004: *
005: * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
006: * royalty free, license to use, modify but not to redistribute this
007: * software in source and binary code form,
008: * provided that i) this copyright notice and license appear on all copies of
009: * the software; and ii) Licensee does not utilize the software in a manner
010: * which is disparaging to Silvere Martin-Michiellot.
011: *
012: * This software is provided "AS IS," without a warranty of any kind. ALL
013: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
014: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
015: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
016: * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
017: * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
018: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
019: * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
020: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
021: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
022: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
023: * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
024: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
025: *
026: * This software is not designed or intended for use in on-line control of
027: * aircraft, air traffic, aircraft navigation or aircraft communications; or in
028: * the design, construction, operation or maintenance of any nuclear
029: * facility. Licensee represents and warrants that it will not use or
030: * redistribute the Software for such purposes.
031: *
032: * @Author: Silvere Martin-Michiellot
033: *
034: */
035:
036: package com.db.version;
037:
038: public class QueryJava3D {
039:
040: public QueryJava3D() {
041: }
042:
043: public boolean isInstalled() {
044:
045: ClassLoader classLoader = getClass().getClassLoader();
046:
047: try {
048: //load a class from the package to ensure Package will find the class
049: classLoader.loadClass("javax.vecmath.Point3d");
050: Package p = Package.getPackage("javax.vecmath");
051: return (p != null);
052: } catch (ClassNotFoundException e) {
053: return false;
054: }
055:
056: }
057:
058: // use com.db.utils.Java3DVersionCheck to compare two version numbers,
059: // once you are sure that the package is installed
060:
061: // the test is done against javax.vecmath.Point3d
062: // we could have choosen javax.media.j3d.SceneGraphObject
063: // or com.sun.j3d.utils.universe.SimpleUniverse as alternate classes/packages
064:
065: // another way would be to use:
066: // VirtualUniverse vu = new VirtualUniverse();
067: // Map vuMap = vu.getProperties();
068: // new String(vuMap.get("j3d.version"));
069:
070: public String getVersion() {
071:
072: ClassLoader classLoader = getClass().getClassLoader();
073:
074: try {
075: //load a class from the package to ensure Package will find the class
076: classLoader.loadClass("javax.vecmath.Point3d");
077: Package p = Package.getPackage("javax.vecmath");
078: if (p != null) {
079: return p.getImplementationVersion();
080: } else
081: return new String();
082: } catch (ClassNotFoundException e) {
083: return new String();
084: }
085:
086: }
087:
088: public String getDetails() {
089:
090: ClassLoader classLoader = getClass().getClassLoader();
091:
092: try {
093: //load a class from the package to ensure Package will find the class
094: classLoader.loadClass("javax.vecmath.Point3d");
095: Package p = Package.getPackage("javax.vecmath");
096: if (p != null) {
097: String string = new String("Specification Title: ");
098: string.concat(p.getSpecificationTitle());
099: string.concat(", Specification Vendor: ");
100: p.getSpecificationVendor();
101: string.concat(", Specification Version: ");
102: p.getSpecificationVersion();
103: string.concat(", Implementation Vendor: ");
104: p.getImplementationVendor();
105: string.concat(", Implementation Version: ");
106: p.getImplementationVersion();
107: return string;
108: } else
109: return new String();
110: } catch (ClassNotFoundException e) {
111: return new String();
112: }
113:
114: }
115:
116: }
|