Class: JavaClass::JavaClassFileName
- Includes:
- JavaQualifiedNameDelegation
- Defined in:
- lib/javaclass/java_name.rb
Overview
A Java class file name from the file system. That is a/b/C.class
. These names are read from the FolderClasspath.
- Author
-
Peter Kofler
Constant Summary collapse
- SEPARATOR =
'/'
- SEPARATOR_REGEX =
/\/|\\/
- VALID_REGEX =
/^ (?: #{JavaLanguage::IDENTIFIER_REGEX}#{SEPARATOR_REGEX} )* #{JavaLanguage::IDENTIFIER_REGEX} #{JavaLanguage::CLASS_REGEX} /x
Constants inherited from String
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
The plain file name of this class file.
Class Method Summary collapse
-
.valid?(string) ⇒ Boolean
Is string a valid class file name?.
Instance Method Summary collapse
-
#initialize(string, qualified = nil) ⇒ JavaClassFileName
constructor
Create a new class file name string with optional qualified class which may be available.
- #to_class_file ⇒ Object
- #to_classname ⇒ Object
- #to_java_file ⇒ Object
- #to_jvmname ⇒ Object
Methods included from JavaQualifiedNameDelegation
Methods included from DelegateDirective
Methods inherited from String
#byte_at, #double, #hexdump, #number_bytes, #same_bytes_as?, #single, #strip_non_printable, #to_javaname, #u1, #u2, #u2rep, #u4, #u8
Constructor Details
#initialize(string, qualified = nil) ⇒ JavaClassFileName
Create a new class file name string with optional qualified class which may be available.
296 297 298 299 300 301 302 303 304 305 |
# File 'lib/javaclass/java_name.rb', line 296 def initialize(string, qualified=nil) super string if string =~ VALID_REGEX @file_name = string.gsub(SEPARATOR_REGEX, SEPARATOR) else raise ArgumentError, "#{string} is no valid class file name" end @qualified_name = qualified @jvm_name = nil end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
The plain file name of this class file.
293 294 295 |
# File 'lib/javaclass/java_name.rb', line 293 def file_name @file_name end |
Class Method Details
.valid?(string) ⇒ Boolean
Is string a valid class file name?
288 289 290 |
# File 'lib/javaclass/java_name.rb', line 288 def self.valid?(string) string =~ VALID_REGEX end |
Instance Method Details
#to_class_file ⇒ Object
333 334 335 |
# File 'lib/javaclass/java_name.rb', line 333 def to_class_file self end |
#to_classname ⇒ Object
307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/javaclass/java_name.rb', line 307 def to_classname return @qualified_name if @qualified_name new_val = JavaQualifiedName.new( @file_name.gsub(SEPARATOR_REGEX, JavaLanguage::SEPARATOR).sub(JavaLanguage::CLASS_REGEX, ''), nil, self) if frozen? new_val else @qualified_name = new_val end end |
#to_java_file ⇒ Object
329 330 331 |
# File 'lib/javaclass/java_name.rb', line 329 def to_java_file @file_name.sub(JavaLanguage::CLASS_REGEX, JavaLanguage::SOURCE) end |
#to_jvmname ⇒ Object
319 320 321 322 323 324 325 326 327 |
# File 'lib/javaclass/java_name.rb', line 319 def to_jvmname return @jvm_name if @jvm_name new_val = JavaVMName.new(@file_name.sub(JavaLanguage::CLASS_REGEX, ''), @qualified_name) if frozen? new_val else @jvm_name = new_val end end |