Class JavaClass::ClassList::ClassEntry
In: lib/javaclass/classlist/class_entry.rb
Parent: Object

An entry in the list. A ClassEntry belongs to a PackageEntry and has a list of versions it exists in.

Author:Peter Kofler

Methods

Attributes

full_name  [R] 
name  [R]  Return the short (simple) name of this class.
version  [R]  Return the list of versions this class exists.

Public Class methods

Create a new entry. parent must provide a version field to compare against. vers is the base version of this class.

[Source]

# File lib/javaclass/classlist/class_entry.rb, line 17
      def initialize(parent, full_name, is_public, vers)
        @parent = parent
        @full_name = full_name.to_javaname.to_classname
        @name = @full_name.simple_name
        @is_public = is_public
        @version = [vers]
      end

Public Instance methods

Sorts by simple name inside the package.

[Source]

# File lib/javaclass/classlist/class_entry.rb, line 50
      def <=>(other)
        @name.casecmp other.name
      end

[Source]

# File lib/javaclass/classlist/class_entry.rb, line 25
      def public?
        @is_public
      end

Return a string containing the full qualified name together with first and last version of this class. Ignore package versions, but obey minversion and maxversion . Print all versions, first to last, but skip first<=minversion and last>=maxversion.

[Source]

# File lib/javaclass/classlist/class_entry.rb, line 61
      def to_full_qualified_s(minversion, maxversion)
        format_version(@full_name, minversion, maxversion)
      end

Return a string containing the simple name and the version, if it is different from the package version.

[Source]

# File lib/javaclass/classlist/class_entry.rb, line 66
      def to_package_shortcut_s
        vp = @parent.version
        format_version("   #{@name}", vp.first, vp.last)
      end

[Source]

# File lib/javaclass/classlist/class_entry.rb, line 54
      def to_s
        @full_name
      end

Update the version this class also exists in.

[Source]

# File lib/javaclass/classlist/class_entry.rb, line 30
      def update(version, is_public=@is_public)
        raise "update class #{@name} is older than its last version: latest version=#{@version.last}, new version=#{version}" if version <= @version.last
        # check for holes in versions
        if version > @version.last+1
          warn "#{@full_name} last in version #{@version.last}, not in #{@version.last+1}, but again in #{version}"
        end
        @version << version

        if !is_public && @is_public
          warn "#{@full_name} changed from public to package in version #{version}"
          @is_public = is_public
          @version = [version] # skip older versions
        elsif is_public && ! @is_public
          puts "#{@full_name} changed from package to public in version #{version}"
          @is_public = is_public
          @version = [version] # skip older versions
        end
      end

[Validate]