Class: JavaClass::ConstantValueAttribute

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, constant_value_index) ⇒ ConstantValueAttribute

コンストラクタ

*java_class::属性の所有者であるJavaクラス *name_index::名前を示すconstant_poolのインデックス *constant_value_index::定数値を示すconstant_poolのインデックス



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

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

Instance Attribute Details

#constant_value_indexObject

定数値を示すconstant_poolのインデックス



77
78
79
# File 'lib/javaclass/attribute.rb', line 77

def constant_value_index
  @constant_value_index
end

Instance Method Details

#to_bytesObject



70
71
72
73
74
# File 'lib/javaclass/attribute.rb', line 70

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

#to_sObject

定数値の文字列表現を取得する。

戻り値::定数値の文字列表現



66
67
68
# File 'lib/javaclass/attribute.rb', line 66

def to_s
  @java_class.get_constant_as_string(@constant_value_index)
end

#valueObject

定数値を取得する。

戻り値::定数値



58
59
60
# File 'lib/javaclass/attribute.rb', line 58

def value
  @java_class.get_constant_value(@constant_value_index)
end