Class: JavaClass::MemberRefConstant

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, class_name_index = nil, name_and_type_index = nil) ⇒ MemberRefConstant

コンストラクタ

*java_class::constantの所有者であるJavaクラス *tag::constantの種類を示すタグ *class_name_index::フィールドorメソッドを持つクラス名を示すconstant_poolのインデックス *name_and_type_index::フィールドorメソッドの名前とディスクリプタを示すconstant_poolのインデックス



85
86
87
88
89
# File 'lib/javaclass/constant.rb', line 85

def initialize( java_class, tag=nil, class_name_index=nil, name_and_type_index=nil )
  super(java_class, tag)
  @class_name_index    = class_name_index
  @name_and_type_index = name_and_type_index
end

Instance Attribute Details

#class_name_indexObject

Returns the value of attribute class_name_index.



111
112
113
# File 'lib/javaclass/constant.rb', line 111

def class_name_index
  @class_name_index
end

#name_and_type_indexObject

Returns the value of attribute name_and_type_index.



112
113
114
# File 'lib/javaclass/constant.rb', line 112

def name_and_type_index
  @name_and_type_index
end

Instance Method Details

#class_nameObject

フィールドorメソッドを持つクラスのconstantを取得する

戻り値::フィールドorメソッドを持つクラスのconstant



95
96
97
# File 'lib/javaclass/constant.rb', line 95

def class_name
  @java_class.get_constant(@class_name_index)
end

#name_and_typeObject

フィールドorメソッドの名前とディスクリプタを示すconstantを取得する

戻り値::フィールドorメソッドの名前とディスクリプタを示すconstantを取得する



103
104
105
# File 'lib/javaclass/constant.rb', line 103

def name_and_type
  @java_class.get_constant(@name_and_type_index)
end

#to_bytesObject



106
107
108
109
110
# File 'lib/javaclass/constant.rb', line 106

def to_bytes()
  bytes = super
  bytes += to_byte( @class_name_index, 2 )
  bytes += to_byte( @name_and_type_index, 2 )
end