Module JavaClass::PackageLogic
In: lib/javaclass/java_name.rb

Mixin with logic to work with Java package names. The "mixer" needs to declare a String field @package.

Author:Peter Kofler

Methods

Public Instance methods

Is this package or class in the JDK? Return the first JDK package this is inside or nil.

[Source]

# File lib/javaclass/java_name.rb, line 28
    def in_jdk?
      if @package && @package != ''
        package_dot = @package + JavaLanguage::SEPARATOR
        JavaLanguage::JDK_PACKAGES_REGEX.find { |package| package_dot =~ package }
      else
        # default package is never in JDK
        false
      end
    end

Return the package name of a classname or the name of the package. Return an empty String if default package. This returns just the plain String.

[Source]

# File lib/javaclass/java_name.rb, line 12
    def package
      @package
    end

Return true if this class is in same or in a subpackage of the given Java packages or if this package is same or a subpackage (with .).

[Source]

# File lib/javaclass/java_name.rb, line 18
    def same_or_subpackage_of?(packages)
      packages.find {|pkg| @package == pkg } != nil || subpackage_of?(packages)
    end

Return true if this class is in a subpackage of the given Java packages .

[Source]

# File lib/javaclass/java_name.rb, line 23
    def subpackage_of?(packages)
      packages.find {|pkg| @package =~ /^#{Regexp.escape(pkg)}#{JavaLanguage::SEPARATOR_REGEX}/ } != nil
    end

[Validate]