Class: JavaClass::SourceFileAttribute

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, source_file_index) ⇒ SourceFileAttribute

コンストラクタ

*java_class::属性の所有者であるJavaクラス *name_index::名前を示すconstant_poolのインデックス *source_file_index::ソースファイルを示すconstant_poolのインデックス



325
326
327
328
# File 'lib/javaclass/attribute.rb', line 325

def initialize( java_class, name_index, source_file_index )
  super( java_class, name_index)
  @source_file_index = source_file_index
end

Instance Attribute Details

#source_file_indexObject

ソースファイルを示すconstant_poolのインデックス



346
347
348
# File 'lib/javaclass/attribute.rb', line 346

def source_file_index
  @source_file_index
end

Instance Method Details

#source_fileObject

ソースファイル名を取得する。

戻り値::ソースファイル名



334
335
336
# File 'lib/javaclass/attribute.rb', line 334

def source_file
  @java_class.get_constant_value(@source_file_index)
end

#to_bytesObject



340
341
342
343
344
# File 'lib/javaclass/attribute.rb', line 340

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

#to_sObject



337
338
339
# File 'lib/javaclass/attribute.rb', line 337

def to_s
  "// source #{source_file}"
end