Class: JavaClass::Member

Inherits:
Object
  • Object
show all
Includes:
Base, Converters, Item
Defined in:
lib/javaclass/member.rb

Overview

Field,Methodの基底クラス

Direct Known Subclasses

Field, Method

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Item

#annotations, #deprecated?, #signature

Methods included from Converters

convert_code, convert_field_descriptor, convert_method_descriptor

Methods included from Base

#==, #===, #dump, #eql?, #hash, #to_byte

Constructor Details

#initialize(java_class) ⇒ Member

コンストラクタ

*java_class::メンバーの所有者であるJavaクラス



18
19
20
21
# File 'lib/javaclass/member.rb', line 18

def initialize( java_class )
  @java_class = java_class
  @attributes = {}
end

Instance Attribute Details

#access_flagObject

アクセスフラグ



51
52
53
# File 'lib/javaclass/member.rb', line 51

def access_flag
  @access_flag
end

#attributesObject

属性名をキーとする属性のハッシュ



57
58
59
# File 'lib/javaclass/member.rb', line 57

def attributes
  @attributes
end

#descriptor_indexObject

ディスクリプタを示すconstant_poolのインデックス



55
56
57
# File 'lib/javaclass/member.rb', line 55

def descriptor_index
  @descriptor_index
end

#java_classObject

JavaClass



49
50
51
# File 'lib/javaclass/member.rb', line 49

def java_class
  @java_class
end

#name_indexObject

名前を示すconstant_poolのインデックス



53
54
55
# File 'lib/javaclass/member.rb', line 53

def name_index
  @name_index
end

Instance Method Details

#descriptorObject

ディスクリプタを取得する。

戻り値::ディスクリプタ



35
36
37
# File 'lib/javaclass/member.rb', line 35

def descriptor
  @java_class.get_constant_value(@descriptor_index)
end

#nameObject

名前を取得する。

戻り値::名前



27
28
29
# File 'lib/javaclass/member.rb', line 27

def name
  @java_class.get_constant_value(@name_index)
end

#to_bytesObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/javaclass/member.rb', line 38

def to_bytes()
  bytes = @access_flag.to_bytes()
  bytes += to_byte( @name_index, 2)
  bytes += to_byte( @descriptor_index, 2)
  bytes += to_byte( @attributes.size, 2)
  @attributes.keys.sort!.each {|k| 
    bytes += @attributes[k].to_bytes()
  }
  return bytes
end