Class: JavaClass::EnclosingMethodAttribute

Inherits:
Attribute
  • Object
show all
Defined in:
lib/javaclass/attribute.rb

Overview

クラスを同封するメソッドの属性

Instance Attribute Summary collapse

Attributes inherited from Attribute

#java_class, #name_index

Instance Method Summary collapse

Methods inherited from Attribute

#name

Methods included from Base

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

Constructor Details

#initialize(java_class, name_index, class_index, method_index) ⇒ EnclosingMethodAttribute

コンストラクタ

*java_class::属性の所有者であるJavaクラス *name_index::名前を示すconstant_poolのインデックス *enclosing_class_index::クラスを同封するメソッドを持つクラスの情報を示すconstant_poolのインデックス *enclosing_method_index::クラスを同封するメソッドの情報を示すconstant_poolのインデックス



235
236
237
238
239
# File 'lib/javaclass/attribute.rb', line 235

def initialize( java_class, name_index, class_index, method_index )
  super( java_class, name_index)
  @enclosing_class_index = class_index
  @enclosing_method_index = method_index
end

Instance Attribute Details

#enclosing_class_indexObject

クラスを同封するメソッドを持つクラスの情報を示すconstant_poolのインデックス



267
268
269
# File 'lib/javaclass/attribute.rb', line 267

def enclosing_class_index
  @enclosing_class_index
end

#enclosing_method_indexObject

クラスを同封するメソッドの情報を示すconstant_poolのインデックス



269
270
271
# File 'lib/javaclass/attribute.rb', line 269

def enclosing_method_index
  @enclosing_method_index
end

Instance Method Details

#enclosing_classObject

クラスを同封するメソッドを持つクラスの情報を取得する。

戻り値::クラスを同封するメソッドを持つクラスの情報



245
246
247
# File 'lib/javaclass/attribute.rb', line 245

def enclosing_class
  @java_class.get_constant( @enclosing_class_index )
end

#enclosing_methodObject

クラスを同封するメソッドの情報を取得する。

戻り値::クラスを同封するメソッドの情報



253
254
255
# File 'lib/javaclass/attribute.rb', line 253

def enclosing_method
  @java_class.get_constant( @enclosing_method_index )
end

#to_bytesObject



259
260
261
262
263
264
# File 'lib/javaclass/attribute.rb', line 259

def to_bytes
  bytes = super
  bytes += to_byte( 4, 4 )
  bytes += to_byte( @enclosing_class_index, 2 )
  bytes += to_byte( @enclosing_method_index, 2 )
end

#to_sObject



256
257
258
# File 'lib/javaclass/attribute.rb', line 256

def to_s
  "// enclosed by #{enclosing_class.name}##{enclosing_method.name}"
end