Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.owasp.dependencycheck.utils
Class DependencyVersion

    java.lang.Object
      org.owasp.dependencycheck.utils.DependencyVersion

All Implemented Interfaces:
  Comparable<DependencyVersion>, Iterable

    public class DependencyVersion

extends Object
implements Iterable, Comparable<DependencyVersion>

Simple object to track the parts of a version number. The parts are contained in a List such that version 1.2.3 will be stored as: `versionParts[0] = 1; versionParts[1] = 2; versionParts[2] = 3;`

Note, the parser contained in this class expects the version numbers to be separated by periods. If a different separator is used the parser will likely fail.

Author:
  Jeremy Long (jeremy.long@owasp.org)

Constructor Summary
`DependencyVersion()` Constructor for a empty DependencyVersion.
`DependencyVersion(String version)` Constructor for a DependencyVersion that will parse a version string.

Method Summary
`int` | `compareTo(DependencyVersion version)`
`boolean` | `equals(Object obj)` Compares the equality of this object to the one passed in as a parameter.
`List<String>` | `getVersionParts()` Get the value of versionParts.
`int` | `hashCode()` Calculates the hashCode for this object.
`Iterator` | `iterator()` Retrieves an iterator for the version parts.
`boolean` | `matchesAtLeastThreeLevels(DependencyVersion version)` Determines if the three most major major version parts are identical.
`void` | `parseVersion(String version)` Parses a version string into its sub parts: major, minor, revision, build, etc.
`void` | `setVersionParts(List<String> versionParts)` Set the value of versionParts.
`String` | `toString()` Reconstructs the version string from the split version parts.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DependencyVersion

    public DependencyVersion()

  Constructor for a empty DependencyVersion.

### DependencyVersion

    public DependencyVersion(String version)

  Constructor for a DependencyVersion that will parse a version string. Note, this should only be used when the version passed in is already known to be a well formated version number. Otherwise, DependencyVersionUtil.parseVersion() should be used instead.

  Parameters:
    `version` - the well formated version number to parse

Method Detail

### parseVersion

    public final void parseVersion(String version)

  Parses a version string into its sub parts: major, minor, revision, build, etc. Note, this should only be used to parse something that is already known to be a version number.

  Parameters:
    `version` - the version string to parse

### getVersionParts

    public List<String> getVersionParts()

  Get the value of versionParts.

  Returns:
    the value of versionParts

### setVersionParts

    public void setVersionParts(List<String> versionParts)

  Set the value of versionParts.

  Parameters:
    `versionParts` - new value of versionParts

### iterator

    public Iterator iterator()

  Retrieves an iterator for the version parts.

  Specified by:
    `iterator` in interface `Iterable`
  Returns:
    an iterator for the version parts

### toString

    public String toString()

  Reconstructs the version string from the split version parts.

  Overrides:
    `toString` in class `Object`
  Returns:
    a string representing the version.

### equals

    public boolean equals(Object obj)

  Compares the equality of this object to the one passed in as a parameter.

  Overrides:
    `equals` in class `Object`
  Parameters:
    `obj` - the object to compare equality
  Returns:
    returns true only if the two objects are equal, otherwise false

### hashCode

    public int hashCode()

  Calculates the hashCode for this object.

  Overrides:
    `hashCode` in class `Object`
  Returns:
    the hashCode

### matchesAtLeastThreeLevels

    public boolean matchesAtLeastThreeLevels(DependencyVersion version)

  Determines if the three most major major version parts are identical. For instances, if version 1.2.3.4 was compared to 1.2.3 this function would return true.

  Parameters:
    `version` - the version number to compare
  Returns:
    true if the first three major parts of the version are identical

### compareTo

    public int compareTo(DependencyVersion version)

  Specified by:
    `compareTo` in interface `Comparable<DependencyVersion>`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012-2013 OWASP. All Rights Reserved.