[izpack-changes] r1868 - in izpack-src/trunk: . src/lib/com/izforge/izpack/util

noreply at berlios.de noreply at berlios.de
Mon Aug 20 22:26:51 CEST 2007


Author: jponge
Date: 2007-08-20 22:26:21 +0200 (Mon, 20 Aug 2007)
New Revision: 1868

Modified:
   izpack-src/trunk/IzPack-head.iml
   izpack-src/trunk/IzPack-head.ipr
   izpack-src/trunk/Versions.txt
   izpack-src/trunk/src/lib/com/izforge/izpack/util/OsConstraint.java
Log:
File / fileset Os constraints: addition of a JRE version test (e.g., <os jre="1.5" />)
(Gilles Wiart via Julien Ponge)



Modified: izpack-src/trunk/IzPack-head.iml
===================================================================
--- izpack-src/trunk/IzPack-head.iml	2007-08-09 20:33:59 UTC (rev 1867)
+++ izpack-src/trunk/IzPack-head.iml	2007-08-20 20:26:21 UTC (rev 1868)
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<module version="4" relativePaths="true" type="JAVA_MODULE">
-  <component name="ModuleRootManager" />
+<module relativePaths="true" type="JAVA_MODULE" version="4">
   <component name="NewModuleRootManager" inherit-compiler-output="false">
     <output url="file://$MODULE_DIR$/.idea-classes" />
     <exclude-output />

Modified: izpack-src/trunk/IzPack-head.ipr
===================================================================
--- izpack-src/trunk/IzPack-head.ipr	2007-08-09 20:33:59 UTC (rev 1867)
+++ izpack-src/trunk/IzPack-head.ipr	2007-08-20 20:26:21 UTC (rev 1868)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project version="4" relativePaths="true">
+<project relativePaths="true" version="4">
   <component name="AntConfiguration">
     <defaultAnt bundledAnt="true" />
     <buildFile url="file://$PROJECT_DIR$/src/build.xml">
@@ -40,11 +40,12 @@
       <entry name="?*.tld" />
     </wildcardResourcePatterns>
   </component>
-  <component name="DataSourceManagerImpl" />
   <component name="DependenciesAnalyzeManager">
     <option name="myForwardDirection" value="false" />
   </component>
-  <component name="DependencyValidationManager" />
+  <component name="DependencyValidationManager">
+    <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+  </component>
   <component name="EclipseCompilerSettings">
     <option name="DEBUGGING_INFO" value="true" />
     <option name="GENERATE_NO_WARNINGS" value="true" />
@@ -60,14 +61,13 @@
     <option name="MAXIMUM_HEAP_SIZE" value="128" />
   </component>
   <component name="EntryPointsManager">
-    <entry_points />
+    <entry_points version="2.0" />
   </component>
   <component name="ExportToHTMLSettings">
     <option name="PRINT_LINE_NUMBERS" value="false" />
     <option name="OPEN_IN_BROWSER" value="false" />
     <option name="OUTPUT_DIRECTORY" />
   </component>
-  <component name="GUI Designer component loader factory" />
   <component name="IdProvider" IDEtalkID="F66F8E4B88443419F1E5C108B16FCE75" />
   <component name="InspectionProjectProfileManager">
     <option name="PROJECT_PROFILE" value="Project Default" />
@@ -77,26 +77,9 @@
       <profile version="1.0" is_locked="false">
         <option name="myName" value="Project Default" />
         <option name="myLocal" value="false" />
-        <used_levels>
-          <error>
-            <option name="myName" value="ERROR" />
-            <option name="myVal" value="400" />
-          </error>
-          <warning>
-            <option name="myName" value="WARNING" />
-            <option name="myVal" value="300" />
-          </warning>
-          <information>
-            <option name="myName" value="INFO" />
-            <option name="myVal" value="200" />
-          </information>
-          <server>
-            <option name="myName" value="SERVER PROBLEM" />
-            <option name="myVal" value="100" />
-          </server>
-        </used_levels>
       </profile>
     </profiles>
+    <list size="0" />
   </component>
   <component name="JavacSettings">
     <option name="DEBUGGING_INFO" value="true" />
@@ -257,13 +240,20 @@
       </item>
     </group>
   </component>
+  <component name="ProjectFileVersion" converted="true" />
   <component name="ProjectModuleManager">
     <modules>
       <module fileurl="file://$PROJECT_DIR$/IzPack-head.iml" filepath="$PROJECT_DIR$/IzPack-head.iml" />
     </modules>
   </component>
   <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="false" project-jdk-name="1.5" />
-  <component name="ProjectRunConfigurationManager" />
+  <component name="ResourceManagerContainer">
+    <option name="myResourceBundles">
+      <value>
+        <list size="0" />
+      </value>
+    </option>
+  </component>
   <component name="RmicSettings">
     <option name="IS_EANABLED" value="false" />
     <option name="DEBUGGING_INFO" value="true" />
@@ -271,9 +261,9 @@
     <option name="GENERATE_IIOP_STUBS" value="false" />
     <option name="ADDITIONAL_OPTIONS_STRING" value="" />
   </component>
-  <component name="StarteamVcsAdapter" />
-  <component name="VssVcs" />
-  <component name="XSLT-Support.FileAssociationsManager" />
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="svn" />
+  </component>
   <component name="com.intellij.jsf.UserDefinedFacesConfigs">
     <option name="USER_DEFINED_CONFIGS">
       <value>
@@ -281,12 +271,10 @@
       </value>
     </option>
   </component>
-  <component name="libraryTable" />
   <component name="uidesigner-configuration">
     <option name="INSTRUMENT_CLASSES" value="true" />
     <option name="COPY_FORMS_RUNTIME_TO_OUTPUT" value="true" />
     <option name="DEFAULT_LAYOUT_MANAGER" value="GridLayoutManager" />
   </component>
-  <UsedPathMacros />
 </project>
 

Modified: izpack-src/trunk/Versions.txt
===================================================================
--- izpack-src/trunk/Versions.txt	2007-08-09 20:33:59 UTC (rev 1867)
+++ izpack-src/trunk/Versions.txt	2007-08-20 20:26:21 UTC (rev 1868)
@@ -28,6 +28,8 @@
 - Workaround for layout problems in UserInputPanel when clicking previous button (Dennis Reil)
 - Nimbus look and feel support (Julien Ponge)
 - Try to load a 64-bit dll if the 32-bit load fails and 64-bit ShellLink (Vladimir Ralev)
+- File / fileset Os constraints: addition of a JRE version test (e.g., <os jre="1.5" />)
+  (Gilles Wiart via Julien Ponge)
 
   > 3.10.3 (build xxxx.xx.xx)
 

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/util/OsConstraint.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/util/OsConstraint.java	2007-08-09 20:33:59 UTC (rev 1867)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/util/OsConstraint.java	2007-08-20 20:26:21 UTC (rev 1868)
@@ -1,80 +1,135 @@
 /*
  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
- * 
+ *
  * https://izpack.github.io/
  * http://developer.berlios.de/projects/izpack/
- * 
+ *
  * Copyright 2002 Olexij Tkatchenko
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- *     
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.izforge.izpack.util;
 
+
+import net.n3.nanoxml.XMLElement;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-import net.n3.nanoxml.XMLElement;
 
 /**
  * Encapsulates OS constraints specified on creation time and allows to check them against the
  * current OS.
- * 
+ * <p/>
  * For example, this is used for &lt;executable&gt;s to check whether the executable is suitable for
  * the current OS.
- * 
+ *
  * @author Olexij Tkatchenko <ot at parcs.de>
  */
-public class OsConstraint implements java.io.Serializable
+public class OsConstraint
+        implements java.io.Serializable
 {
+    //~ Static variables/initializers ·····················································································
 
     /**
-     * 
+     *
      */
     private static final long serialVersionUID = 3762248660406450488L;
 
-    /** The OS family */
+    //~ Instance variables ································································································
+
+    /**
+     * OS architecture from java system properties
+     */
+    private String arch;
+
+    /**
+     * The OS family
+     */
     private String family;
 
-    /** OS name from java system properties */
+    /**
+     * JRE version used for installation
+     */
+    private String jre;
+
+    /**
+     * OS name from java system properties
+     */
     private String name;
 
-    /** OS version from java system properties */
+    /**
+     * OS version from java system properties
+     */
     private String version;
 
-    /** OS architecture from java system properties */
-    private String arch;
+    //~ Constructors ······································································································
 
     /**
      * Constructs a new instance. Please remember, MacOSX belongs to Unix family.
-     * 
-     * @param family The OS family (unix, windows or mac).
-     * @param name The exact OS name.
+     *
+     * @param family  The OS family (unix, windows or mac).
+     * @param name    The exact OS name.
      * @param version The exact OS version (check property <code>os.version</code> for values).
-     * @param arch The machine architecture (check property <code>os.arch</code> for values).
+     * @param arch    The machine architecture (check property <code>os.arch</code> for values).
+     * @param jre     The Java version used for installation (check property <code>java.version</code> for values).
      */
-    public OsConstraint(String family, String name, String version, String arch)
+    public OsConstraint(String family,
+                        String name,
+                        String version,
+                        String arch,
+                        String jre)
     {
-        this.family = family != null ? family.toLowerCase() : null;
-        this.name = name != null ? name.toLowerCase() : null;
-        this.version = version != null ? version.toLowerCase() : null;
-        this.arch = arch != null ? arch.toLowerCase() : null;
-    }
+        this.family = (family != null)
+                ? family.toLowerCase()
+                : null;
+        this.name = (name != null)
+                ? name.toLowerCase()
+                : null;
+        this.version = (version != null)
+                ? version.toLowerCase()
+                : null;
+        this.arch = (arch != null)
+                ? arch.toLowerCase()
+                : null;
+        this.jre = (jre != null)
+                ? jre.toLowerCase()
+                : null;
+    }    // end OsConstraint()
 
+
     /**
+     * Creates a new instance. Please remember, MacOSX belongs to Unix family.
+     *
+     * @param family  The OS family (unix, windows or mac).
+     * @param name    The exact OS name.
+     * @param version The exact OS version (check property <code>os.version</code> for values).
+     * @param arch    The machine architecture (check property <code>os.arch</code> for values).
+     */
+    public OsConstraint(String family,
+                        String name,
+                        String version,
+                        String arch)
+    {
+        this(family, name, version, arch, null);
+    }    // end OsConstraint()
+
+    //~ Methods ···········································································································
+
+    /**
      * Matches OS specification in this class against current system properties.
-     * 
+     *
      * @return Description of the Return Value
      */
     public boolean matchCurrentSystem()
@@ -82,166 +137,212 @@
         boolean match = true;
         String osName = System.getProperty("os.name").toLowerCase();
 
-        if (arch != null && arch.length() != 0)
+
+        if ((arch != null) && (arch.length() != 0))
         {
             match = System.getProperty("os.arch").toLowerCase().equals(arch);
-        }
-        if (match && version != null && version.length() != 0)
+        }    // end if
+
+        if (match && (version != null) && (version.length() != 0))
         {
             match = System.getProperty("os.version").toLowerCase().equals(version);
-        }
-        if (match && name != null && name.length() != 0)
+        }    // end if
+
+        if (match && (name != null) && (name.length() != 0))
         {
             match = osName.equals(name);
-        }
-        if (match && family != null)
+        }    // end if
+
+        if (match && (family != null))
         {
             if ("windows".equals(family))
             {
                 match = OsVersion.IS_WINDOWS;
-            }
+            }    // end if
             else if ("mac".equals(family) || "osx".equals(family))
             {
                 match = OsVersion.IS_OSX;
-            }
+            }    // end else if
             else if ("unix".equals(family))
             {
                 match = OsVersion.IS_UNIX;
-            }
-        }
+            }    // end else if
+        }    // end if
 
-        return match && (family != null || name != null || version != null || arch != null);
-    }
+        if (match && (jre != null) && (jre.length() > 0))
+        {
+            match = System.getProperty("java.version").toLowerCase().startsWith(jre);
+        }    // end if
 
+        return match
+                && ((family != null) || (name != null) || (version != null) || (arch != null) || (jre != null));
+    }    // end matchCurrentSystem()
+
+
     /**
      * Extract a list of OS constraints from given element.
-     * 
+     *
      * @param element parent XMLElement
      * @return List of OsConstraint (or empty List if no constraints found)
      */
-    static public List getOsList(XMLElement element)
+    public static List getOsList(XMLElement element)
     {
         // get os info on this executable
         ArrayList osList = new ArrayList();
         Iterator osIterator = element.getChildrenNamed("os").iterator();
+
+
         while (osIterator.hasNext())
         {
             XMLElement os = (XMLElement) osIterator.next();
-            osList.add(new OsConstraint(os.getAttribute("family", null), os.getAttribute("name",
-                    null), os.getAttribute("version", null), os.getAttribute("arch", null)));
-        }
 
+
+            osList.add(new OsConstraint(os.getAttribute("family",
+                    null),
+                    os.getAttribute("name",
+                            null),
+                    os.getAttribute("version",
+                            null),
+                    os.getAttribute("arch",
+                            null),
+                    os.getAttribute("jre",
+                            null)));
+        }    // end while
+
         // backward compatibility: still support os attribute
         String osattr = element.getAttribute("os");
-        if (osattr != null && osattr.length() > 0)
+
+
+        if ((osattr != null) && (osattr.length() > 0))
         {
             // add the "os" attribute as a family constraint
-            osList.add(new OsConstraint(osattr, null, null, null));
-        }
+            osList.add(new OsConstraint(osattr,
+                    null,
+                    null,
+                    null,
+                    null));
+        }    // end if
 
         return osList;
-    }
+    }    // end getOsList()
 
+
     /**
      * Helper function: Scan a list of OsConstraints for a match.
-     * 
+     *
      * @param constraint_list List of OsConstraint to check
-     * 
      * @return true if one of the OsConstraints matched the current system or constraint_list is
-     * null (no constraints), false if none of the OsConstraints matched
+     *         null (no constraints), false if none of the OsConstraints matched
      */
     public static boolean oneMatchesCurrentSystem(List constraint_list)
     {
-        if (constraint_list == null) return true;
+        if (constraint_list == null)
+        {
+            return true;
+        }    // end if
 
         Iterator constraint_it = constraint_list.iterator();
 
         // no constraints at all - matches!
-        if (!constraint_it.hasNext()) return true;
+        if (!constraint_it.hasNext())
+        {
+            return true;
+        }    // end if
 
         while (constraint_it.hasNext())
         {
             OsConstraint osc = (OsConstraint) constraint_it.next();
 
+
             Debug.trace("checking if os constraints " + osc + " match current OS");
 
             // check for match
             if (osc.matchCurrentSystem())
             {
                 Debug.trace("matched current OS.");
-                return true; // bail out on first match
-            }
 
-        }
+                return true;    // bail out on first match
+            }    // end if
+        }    // end while
 
         Debug.trace("no match with current OS!");
+
         // no match found
         return false;
-    }
+    }    // end oneMatchesCurrentSystem()
 
+
     /**
      * Helper function: Check whether the given XMLElement is "suitable" for the current OS.
-     * 
+     *
      * @param el The XMLElement to check for OS constraints.
-     * 
      * @return true if there were no OS constraints or the constraints matched the current OS.
-     * 
      */
     public static boolean oneMatchesCurrentSystem(XMLElement el)
     {
         return oneMatchesCurrentSystem(getOsList(el));
-    }
+    }    // end oneMatchesCurrentSystem()
 
+
     public void setFamily(String f)
     {
         family = f.toLowerCase();
-    }
+    }    // end setFamily()
 
+
     public String getFamily()
     {
         return family;
-    }
+    }    // end getFamily()
 
+
     public void setName(String n)
     {
         name = n.toLowerCase();
-    }
+    }    // end setName()
 
+
     public String getName()
     {
         return name;
-    }
+    }    // end getName()
 
     public void setVersion(String v)
     {
         version = v.toLowerCase();
-    }
+    }    // end setVersion()
 
+
     public String getVersion()
     {
         return version;
-    }
+    }    // end getVersion()
 
+
     public void setArch(String a)
     {
         arch = a.toLowerCase();
-    }
+    }    // end setArch()
 
+
     public String getArch()
     {
         return arch;
-    }
+    }    // end getArch()
 
     public String toString()
     {
         StringBuffer retval = new StringBuffer();
+
+
         retval.append("[Os ");
         retval.append(" family ").append(family);
         retval.append(" name ").append(name);
         retval.append(" version ").append(version);
         retval.append(" arch ").append(arch);
+        retval.append(" jre ").append(jre);
         retval.append(" ]");
+
         return retval.toString();
-    }
-
-}
+    }    // end toString()
+}    // end OsConstraint



More information about the izpack-changes mailing list