Class: JavaClass::NameAndTypeConstant

Inherits:
Constant
  • Object
show all
Defined in:
lib/javaclass/constant.rb

Overview

名前と型のConstant

Constant Summary

Constants inherited from Constant

Constant::CONSTANT_Class, Constant::CONSTANT_Double, Constant::CONSTANT_Fieldref, Constant::CONSTANT_Float, Constant::CONSTANT_Integer, Constant::CONSTANT_InterfaceMethodref, Constant::CONSTANT_Long, Constant::CONSTANT_Methodref, Constant::CONSTANT_NameAndType, Constant::CONSTANT_String, Constant::CONSTANT_Utf8

Instance Attribute Summary collapse

Attributes inherited from Constant

#java_class, #tag

Instance Method Summary collapse

Methods included from Base

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

Constructor Details

#initialize(java_class, tag = nil, name_index = nil, descriptor_index = nil) ⇒ NameAndTypeConstant

コンストラクタ

*java_class::constantの所有者であるJavaクラス*tag::constantの種類を示すタグ*name_index::名前を示すconstant_poolのインデックス*descriptor_index::ディスクリプタを示すconstant_poolのインデックス



175
176
177
178
179
# File 'lib/javaclass/constant.rb', line 175

def initialize( java_class, tag=nil, name_index=nil, descriptor_index=nil )
  super(java_class, tag)
  @name_index       = name_index
  @descriptor_index = descriptor_index
end

Instance Attribute Details

#descriptor_indexObject

Returns the value of attribute descriptor_index.



202
203
204
# File 'lib/javaclass/constant.rb', line 202

def descriptor_index
  @descriptor_index
end

#name_indexObject

Returns the value of attribute name_index.



201
202
203
# File 'lib/javaclass/constant.rb', line 201

def name_index
  @name_index
end

Instance Method Details

#descriptorObject

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

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



193
194
195
# File 'lib/javaclass/constant.rb', line 193

def descriptor
  @java_class.get_constant_value(@descriptor_index)
end

#nameObject

名前を取得する

戻り値::名前



185
186
187
# File 'lib/javaclass/constant.rb', line 185

def name
  @java_class.get_constant_value(@name_index)
end

#to_bytesObject



196
197
198
199
200
# File 'lib/javaclass/constant.rb', line 196

def to_bytes()
  bytes = super
  bytes += to_byte( @name_index, 2 )
  bytes += to_byte( @descriptor_index, 2 )
end