class JavaClass::JavaQualifiedName

A full qualified class name. That is like a.b.C. Care has to be taken if this is used as hash key. String is treated special and the additional fields are lost when the key is retrieved from the Hash (because it is frozen).

Author

Peter Kofler

Constants

VALID_REGEX

Public Class Methods

new(string, jvmname=nil, classname=nil) click to toggle source

Create a new qualified name string with optional jvmname and classname classes which may be available.

Calls superclass method
# File lib/javaclass/java_name.rb, line 114
def initialize(string, jvmname=nil, classname=nil)
  super string
  if string =~ VALID_REGEX
    @package = $1 || ''
    @simple_name = $2
    @full_name = string
  else
    # TODO Implement qualified name logic for inner classes (e.g. CollectionUtils$IChecker)
    raise ArgumentError, "#{string} is no valid qualified name"
  end
  package_remove_trailing_dot!
  
  @jvm_name = jvmname
  @class_name = classname
end
valid?(string) click to toggle source

Is string a valid qualified name?

# File lib/javaclass/java_name.rb, line 109
def self.valid?(string)
  string =~ VALID_REGEX
end

Public Instance Methods

full_name() click to toggle source

Full normalized class name of this class. This returns just the plain String.

# File lib/javaclass/java_name.rb, line 131
def full_name
  @full_name
end
to_class_file() click to toggle source

Return the Java class file name of this class, e.g. java/lang/Object.class.

# File lib/javaclass/java_name.rb, line 161
def to_class_file
  return @class_name if @class_name
  new_val = JavaClassFileName.new(@full_name.gsub(JavaLanguage::SEPARATOR, JavaClassFileName::SEPARATOR) + JavaLanguage::CLASS, self)
  if frozen?
    new_val
  else 
    @class_name = new_val
  end 
end
to_classname() click to toggle source

Return the full classname of this class, e.g. java.lang.Object.

# File lib/javaclass/java_name.rb, line 140
def to_classname
  self
end
to_java_file() click to toggle source

Return the Java source file name of this class, e.g. java/lang/Object.java. This is a plain String.

# File lib/javaclass/java_name.rb, line 156
def to_java_file
  @full_name.gsub(JavaLanguage::SEPARATOR, JavaClassFileName::SEPARATOR) + JavaLanguage::SOURCE
end
to_javaname() click to toggle source
# File lib/javaclass/java_name.rb, line 135
def to_javaname
  self
end
to_jvmname() click to toggle source

Return the VM name of this class, e.g. java/lang/Object.

# File lib/javaclass/java_name.rb, line 145
def to_jvmname
  return @jvm_name if @jvm_name
  new_val = JavaVMName.new(@full_name.gsub(JavaLanguage::SEPARATOR, JavaVMName::SEPARATOR), self)
  if frozen?
    new_val
  else
    @jvm_name = new_val
  end
end