Class | JavaClass::ClassList::PackageEntry |
In: |
lib/javaclass/classlist/package_entry.rb
|
Parent: | Object |
A package in the List. A package contains ClassEntry.
Author: | Peter Kofler |
name | [R] | |
version | [R] | Return the list of versions this package exists. This is the sum of all versions of all classes in the package. |
Create a new package with name name and first version vers which is the version of the first class in the package.
# File lib/javaclass/classlist/package_entry.rb, line 15 def initialize(name, vers=0) @name = name @version = [vers] @classes = Hash.new # class_name (most likely String) => ClassEntry end
Sorting in packages is: java.lang, other java.*, javax.* and then others.
# File lib/javaclass/classlist/package_entry.rb, line 34 def <=>(other) if @name =~ /^java\.lang$/ and other.name !~ /^java\.lang$/ -1 elsif @name !~ /^java\.lang$/ and other.name =~ /^java\.lang$/ 1 elsif @name =~ /^java\./ and other.name !~ /^java\./ -1 elsif @name !~ /^java\./ and other.name =~ /^java\./ 1 elsif @name =~ /^javax\./ and other.name !~ /^javax\./ -1 elsif @name !~ /^javax\./ and other.name =~ /^javax\./ 1 else @name <=> other.name end end
# File lib/javaclass/classlist/package_entry.rb, line 21 def add_class(class_name, is_public, version) @version << version unless @version.include? version @version = @version.sort unless @classes.has_key?(class_name) @classes[class_name] = ClassEntry.new(self, class_name, is_public, version) # class_name does not need to be frozen because it's not read from the keys else @classes[class_name].update(version, is_public) end end
Special version of to_s for package shortcut. A package needs minversion and maxversion to determine if the whole package was dropped.
# File lib/javaclass/classlist/package_entry.rb, line 68 def to_package_shortcut_s(minversion, maxversion) "#{@name}#{format_version(minversion, maxversion)} - \n" + classes.collect { |c| c.to_package_shortcut_s }.join end