Class: JavaClass::ClassFile::ClassFileAttributes
- Defined in:
- lib/javaclass/classfile/class_file_attributes.rb
Overview
Class file attributes.
- Author
-
Peter Kofler
Instance Method Summary collapse
- #anonymous? ⇒ Boolean
-
#initialize(attributes, this_class) ⇒ ClassFileAttributes
constructor
A new instance of ClassFileAttributes.
- #inner_class? ⇒ Boolean
-
#inner_classes ⇒ Object
List of inner classes
Attributes::InnerClass
with name and access flags. -
#outer_class ⇒ Object
Return outer class name for inner classes, or the current class name.
-
#source_file ⇒ Object
Name of the source file.
-
#static_inner_class? ⇒ Boolean
Defines an accessible inner class, which is a static inner class which is not synthetic.
Constructor Details
#initialize(attributes, this_class) ⇒ ClassFileAttributes
Returns a new instance of ClassFileAttributes.
10 11 12 13 |
# File 'lib/javaclass/classfile/class_file_attributes.rb', line 10 def initialize(attributes, this_class) @attributes = attributes @this_class = this_class end |
Instance Method Details
#anonymous? ⇒ Boolean
46 47 48 |
# File 'lib/javaclass/classfile/class_file_attributes.rb', line 46 def anonymous? inner_class? && @this_class =~ /\$\d+$/ end |
#inner_class? ⇒ Boolean
27 28 29 30 31 32 33 |
# File 'lib/javaclass/classfile/class_file_attributes.rb', line 27 def inner_class? if inner_classes.find { |inner| inner.class_name == @this_class } true else false end end |
#inner_classes ⇒ Object
List of inner classes Attributes::InnerClass
with name and access flags.
22 23 24 25 |
# File 'lib/javaclass/classfile/class_file_attributes.rb', line 22 def inner_classes a = @attributes.with('InnerClasses') if a then a.inner_classes else [] end end |
#outer_class ⇒ Object
Return outer class name for inner classes, or the current class name.
51 52 53 54 55 56 57 |
# File 'lib/javaclass/classfile/class_file_attributes.rb', line 51 def outer_class if inner_class? JavaVMName.new(@this_class[/^[^$]+/]) else @this_class end end |
#source_file ⇒ Object
Name of the source file.
16 17 18 19 |
# File 'lib/javaclass/classfile/class_file_attributes.rb', line 16 def source_file a = @attributes.with('SourceFile') if a then a.source_file else '<not set>' end end |
#static_inner_class? ⇒ Boolean
Defines an accessible inner class, which is a static inner class which is not synthetic.
36 37 38 39 40 41 42 43 44 |
# File 'lib/javaclass/classfile/class_file_attributes.rb', line 36 def static_inner_class? if inner_classes.find { |inner| inner.class_name == @this_class && inner.access_flags.static? && (!inner.access_flags.private? || inner.access_flags.protected?) } true else false end end |