saker.nest Documentation TaskDoc JavaDoc Packages
public final class BundleDependencyInformation implements Externalizable
Contains immutable information about bundle dependencies.

This class encloses BundleIdentifiers mapped to their respective BundleDependencyLists. Each bundle identifier is associated with a dependency list that contains the kinds of dependencies, allowed version ranges, and meta-datas.

The dependencies in the class are contained in an ordered map, meaning that serializing and deserializing won't change the dependency iteration order.

Use create(Map<BundleIdentifier, ? extends BundleDependencyList>) to create a new instance or readFrom(InputStream, BundleIdentifier) to read from an input stream.

Fields
public static final BundleDependencyInformation
Singleton instance contanining no dependencies.
Methods
public static BundleDependencyInformation
create(Map<BundleIdentifier, ? extends BundleDependencyList> dependencies)
Creates a new dependency information object that contains the dependencies specified in the argument.
public boolean
Indicates whether some other object is "equal to" this one.
public BundleDependencyInformation
filter(BiFunction<super BundleIdentifier, ? super BundleDependencyList, ? extends BundleDependencyList> transformation)
Creates a new dependency information by filtering the dependencies in this instance.
public Map<BundleIdentifier, ? extends BundleDependencyList>
Gets the dependencies in this information.
public BundleDependencyList
Gets the dependency list for the argument bundle identifier.
public boolean
Checks if this information contains any optional dependencies.
public int
Returns a hash code value for the object.
public boolean
Checks if this information has any dependencies.
public void
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.
public static BundleDependencyInformation
readFrom(InputStream is, BundleIdentifier declaringbundleid)
Parses the bundle dependencies from the argument input stream in the format defined by this function.
public String
Returns a string representation of the object.
public BundleDependencyInformation
Gets a dependency information object that contains the same dependencies as this, but without the optional dependencies.
public void
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
public void
Writes this dependency information to the argument output stream in the format specified by readFrom(InputStream, BundleIdentifier).
Inherited methods
From: Object
Singleton instance contanining no dependencies.
Creates a new dependency information object that contains the dependencies specified in the argument.
dependenciesThe dependencies.
The new dependency information object.
NullPointerExceptionIf the argument or any elements of it are null.
IllegalArgumentExceptionIf any of the bundle identifier keys in the argument contains version qualifier or duplicate bundle identifiers are encountered.
public boolean equals(Object obj)
Overridden from: Object
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

objthe reference object with which to compare.
true if this object is the same as the obj argument; false otherwise.
Creates a new dependency information by filtering the dependencies in this instance.

The arugment transformation function will be called for all dependency present in this instance. The function may modify or omit the dependency passed to it.

If the function returns null, the passed dependency will not be part of the result. In other cases, the returned dependency list will be added to the result.

transformationThe transformation function.
The dependency information that is the result of the filtering.
NullPointerExceptionIf the transformation function is null, and this is not empty.
Gets the dependencies in this information.

The keys in the returned map will have no version qualifiers.

The unmodifiable map of dependencies.
Gets the dependency list for the argument bundle identifier.
bundleidThe bundle identifier.
The associated dependency list or null if none.
public boolean hasOptional()
Checks if this information contains any optional dependencies.
true if there is at least one optional BundleDependency.
public int hashCode()
Overridden from: Object
Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the Object.equals(Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

a hash code value for this object.
public boolean isEmpty()
Checks if this information has any dependencies.
true if this information is empty.
Overridden from: Externalizable
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
inthe stream to read data from in order to restore the object
IOExceptionif I/O errors occur
ClassNotFoundExceptionIf the class for an object being restored cannot be found.
Parses the bundle dependencies from the argument input stream in the format defined by this function.

The dependencies are declared in 3 levels of white-space indented lines.

The first level contains the name of the bundle identifier that the dependency is declared on:

 my.bundle
     ...
 second.dependency.bundle-q1-q2
     ....
 
The bundle identifiers may contain qualifiers, but no meta-qualifiers. Each bundle identifier may only occurr once. All dependency information for a bundle is written in the block following the bundle identifier.

In each indented block, the indentation characters must be the same. You can use one or more tabs or spaces, but make sure to use the same indentation throughout an indented block.

A dependency on a bundle consists of one or multiple dependency kinds, a version range, and optional meta-data:

 my.bundle
     classpath: 1.0
     kind2, kind3,, kind4: [0)
 
The above shows two dependency declarations. The kind classpath is applied with the version range of 1.0. The dependency with kinds kind2, kind3, kind4 is applied with the version range of [0).

A dependency declaration syntax consists of a dependency kind and version range separated by a colon character (:). Multiple kinds can be present separated by commas. Extraneous commas are ignored.

In the above, both dependency declarations are indented with 4 spaces. As mentioned above, this must stay consistend in a given block.

Dependency meta-datas can be declared for a given declaration:

 my.bundle
     classpath: 1.0
         optional: true
         meta2: custom-value
         with-spaces: hello world
         empty:
         quoted: "123"
         quoted: ""word""
         multi-line: "1
 2"
         eol-quote-escape: "1"\
 2"
         slash: \
         slash-in-str: "\"
 
There's two way the value of a meta-data declaration can be specified. As simple unquoted characters, or in quotes. Without any quotation, the value will be considered to start from the colon (:) and last until the end of the line. Any white-space will be trimmed from it.

With quotes, the contents of the meta-data value will be all the characters until the first quote that is found at the end of a line. Intermediate quotes don't need to be escaped. If the value needs to have quotes at the end of a line and still continue, the backslash (\) character needs to be appended to continue parsing the value.

See the following for multi-line escaping examples:

 meta1: "1st
 2nd"
 
 meta2: "some"intermediate
 "quoted"
 
 meta3: "quotes
 at"\
 line\\
 end"
 
In the above, the meta-data entries will be the following, with new lines as \n:
  • meta1: 1st\n2nd
  • meta2: some"intermediate\n"quoted
  • meta3: quotes\nat"\nline\\nend
If a backslash character is found at the end of a line in a multi-line quoted string value, then it will be omitted by the parser. Line endings are normalized to \n.

As a convenience feature, the parser allows version ranges to contain the this identifier. If found, then it will be substituted by the version number of the declaring bundle identifier parameter (if any) for dependencies that have the same name as the declaring bundle.

E.g. if the declaring bundle is my.bundle-v1.0 then the following:

 my.bundle-q1
     classpath: [this]
 
Will be parsed as if it was the following:
 my.bundle-q1
     classpath: [1.0]
 
Note that the this identifier will not be substituted if it is declared on a dependency that doesn't have the same name as the declaring bundle. The following will result in a parsing error:
 other.bundle
     classpath: [this]
 
The error occurs as other.bundle has a different name than my.bundle.
isThe input stream to parse. UTF-8 encoding is used.
declaringbundleidThe declaring bundle identifier to substitute "this" tokens in version ranges. May be null.
The parsed dependency information.
NullPointerExceptionIf the input stream is null.
IllegalArgumentExceptionIf the input has invalid format.
IOExceptionIn case of I/O error.
public String toString()
Overridden from: Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
a string representation of the object.
Gets a dependency information object that contains the same dependencies as this, but without the optional dependencies.
The dependency information without optionals.
public void writeExternal(ObjectOutput out) throws IOException
Overridden from: Externalizable
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
outthe stream to write the object to
IOExceptionIncludes any I/O exceptions that may occur
Writes this dependency information to the argument output stream in the format specified by readFrom(InputStream, BundleIdentifier).
osThe output stream.
NullPointerExceptionIf the output is null.
IOExceptionIn case of I/O error.