Class: JavaClass::ClassFile::ClassFileAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/javaclass/classfile/class_file_attributes.rb

Overview

Class file attributes.

Author

Peter Kofler

Instance Method Summary collapse

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

Returns:

  • (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

Returns:

  • (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_classesObject

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_classObject

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_fileObject

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.

Returns:

  • (Boolean)


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