Class JarFile

java.lang.Object
com.norconex.commons.lang.jar.JarFile
All Implemented Interfaces:
Comparable<JarFile>

public class JarFile extends Object implements Comparable<JarFile>
Simple Jar file representation holding name and version information.
Since:
1.10.0
  • Field Details

  • Constructor Details

    • JarFile

      public JarFile(@NonNull @NonNull File jarFile)
  • Method Details

    • toFile

      public File toFile()
      Returns this jar file as a File.
      Returns:
      file
      Since:
      3.0.0
    • getPath

      @Deprecated(since="3.0.0") public File getPath()
      Deprecated.
      Use toFile() instead.
      Gets this jar file as a File.
      Returns:
      a file
    • getFullName

      public String getFullName()
    • getBaseName

      public String getBaseName()
    • getVersion

      public String getVersion()
    • getLastModified

      public Date getLastModified()
    • isVersionGreaterThan

      public boolean isVersionGreaterThan(JarFile file)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isSameVersion

      @Deprecated(since="3.0.0") public boolean isSameVersion(JarFile jarFile)
      Deprecated.
      Gets whether this Jar has the same name and version as the provided jar.
      Parameters:
      jarFile - jar file
      Returns:
      true if the jar names and versions are the same.
      Since:
      1.13.0
    • isDuplicateOf

      public boolean isDuplicateOf(JarFile jarFile)
      Gets whether a jar file is considered a duplicate of this one. Two jar files are duplicates if they share the same base name, regardless of their version or last modified dates. Equivalent jars are always duplicates, but duplicates are not always equivalent.
      Parameters:
      jarFile - the jar file to test
      Returns:
      true if the jar file is a duplicate
      Since:
      3.0.0
      See Also:
    • isSameVersionAndTime

      @Deprecated(since="3.0.0") public boolean isSameVersionAndTime(JarFile jarFile)
      Deprecated.
      Gets whether this Jar has the same name and version as the provided jar, as well as the same last modified date.
      Parameters:
      jarFile - jar file
      Returns:
      true if the jar names, versions and last modified dates are the same.
      Since:
      1.13.0
    • isEquivalentTo

      public boolean isEquivalentTo(JarFile other)
      Gets whether this jar file is equivalent to the other if they both have the same semantic version and last modified date. An equivalent jar is always considered a duplicates (same base names), but duplicates are not always equivalent.
      Parameters:
      other - other jar file we are comparing to
      Returns:
      true if this jar file is equivalent to the other
      See Also:
    • isGreaterThan

      public boolean isGreaterThan(JarFile other)
      Gets whether this jar file is greater than the other, by comparing semantic versions and last modified dates.
      Parameters:
      other - other jar file we are comparing to
      Returns:
      true if this jar file is greater than the other
    • isGreaterOrEquivalentTo

      public boolean isGreaterOrEquivalentTo(JarFile other)
      Gets whether this jar file is greater or equivalent to the other, by comparing semantic versions and last modified dates.
      Parameters:
      other - other jar file we are comparing to
      Returns:
      true if this jar file is greater or equivalent to the other
    • isLowerThan

      public boolean isLowerThan(JarFile other)
      Gets whether this jar file lower than the other, by comparing semantic versions and last modified dates.
      Parameters:
      other - other jar file we are comparing to
      Returns:
      true if this jar file is lower than the other
    • isLowerOrEquivalentTo

      public boolean isLowerOrEquivalentTo(JarFile other)
      Gets whether this jar file is lower or equivalent to the other.
      Parameters:
      other - other jar file we are comparing to
      Returns:
      true if this jar file is lower or equivalent to the other
    • compareTo

      public int compareTo(JarFile o)
      Specified by:
      compareTo in interface Comparable<JarFile>
    • toJarFiles

      public static List<JarFile> toJarFiles(Collection<Path> jarPaths)
      Returns the supplied paths as a list of JarFile. The paths can be any combination of jar files or directories of jar files (does not recurse). A jar file is interpreted to be a file with the ".jar" extension. Files with different extensions are ignored.
      Parameters:
      jarPaths - paths to jar files or directories containing jar files
      Returns:
      a list of jar files or an empty list, never null.
      Throws:
      UncheckedIOException - if a problem occurs while accessing files
      Since:
      3.0.0
    • toJarFiles

      public static List<JarFile> toJarFiles(Path... jarPaths)
      Returns the supplied paths as a list of JarFile. The paths can be any combination of jar files or directories of jar files (does not recurse). A jar file is interpreted to be a file with the ".jar" extension. Files with different extensions are ignored.
      Parameters:
      jarPaths - paths to jar files or directories containing jar files
      Returns:
      a list of jar files or an empty list, never null.
      Throws:
      UncheckedIOException - if a problem occurs while accessing files
      Since:
      3.0.0
    • toJarFiles

      public static List<JarFile> toJarFiles(File... jarPaths)
      Returns the supplied paths as a list of JarFile. The paths can be any combination of jar files or directories of jar files (does not recurse). A jar file is interpreted to be a file with the ".jar" extension. Files with different extensions are ignored.
      Parameters:
      jarPaths - paths to jar files or directories containing jar files
      Returns:
      a list of jar files or an empty list, never null.
      Throws:
      UncheckedIOException - if a problem occurs while accessing files
      Since:
      3.0.0
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object