org.redline_rpm.Dependency Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redline Show documentation
Show all versions of redline Show documentation
Redline is a pure Java library for manipulating RPM Package Manager packages.
package org.redline_rpm;
import java.util.LinkedList;
import java.util.List;
/**
* This class represents a RPM dependency.
*
* There are currently four different types known by RPM:
* - requires
* - provides
* - conflicts
* - obsoletes
*
* These can be represented by this class.
*
*/
public class Dependency {
private String name;
private String version;
private Integer flags;
/**
* Creates a new dependency.
* @param name Name (e.g. "httpd")
* @param version Version (e.g. "1.0")
* @param flags Flags, see org.redline_rpm.header.Flags (e.g. "GREATER | EQUAL")
*/
public Dependency(String name, String version, Integer flags) {
this.name = name;
this.version = version;
this.flags = flags;
}
public String getName() {
return name;
}
public String getVersion() {
return version;
}
public Integer getFlags() {
return flags;
}
/**
* Returns an array of String with the name of every dependency from a list of dependencies.
* @param dependencyList List of dependencies
* @return String[] with all names of the dependencies
*/
public static String[] getArrayOfNames(List dependencyList) {
List nameList = new LinkedList();
for (Dependency dependency : dependencyList) {
nameList.add(dependency.getName());
}
return nameList.toArray(new String[nameList.size()]);
}
/**
* Returns an array of String with the version of every dependency from a list of dependencies.
* @param dependencyList List of dependencies
* @return String[] with all versions of the dependencies
*/
public static String[] getArrayOfVersions(List dependencyList) {
List versionList = new LinkedList();
for (Dependency dependency : dependencyList) {
versionList.add(dependency.getVersion());
}
return versionList.toArray(new String[versionList.size()]);
}
/**
* Returns an array of Integer with the flags of every dependency from a list of dependencies.
* @param dependencyList List of dependencies
* @return Integer[] with all flags of the dependencies
*/
public static Integer[] getArrayOfFlags(List dependencyList) {
List flagsList = new LinkedList();
for (Dependency dependency : dependencyList) {
flagsList.add(dependency.getFlags());
}
return flagsList.toArray(new Integer[flagsList.size()]);
}
}