Class: JavaClass::EnumAnnotationElementValue

Inherits:
AnnotationElementValue show all
Defined in:
lib/javaclass/attribute.rb

Overview

列挙型のアノテーションデータ

Instance Attribute Summary collapse

Attributes inherited from AnnotationElementValue

#tag

Instance Method Summary collapse

Methods included from Converters

convert_code, convert_field_descriptor, convert_method_descriptor

Methods included from Base

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

Constructor Details

#initialize(java_class, tag = nil, type_name_index = nil, const_name_index = nil) ⇒ EnumAnnotationElementValue

コンストラクタ

*java_class::属性の所有者であるJavaクラス *tag::データの種別を示すconstant_poolのインデックス *type_name_index::列挙型の型名を示すconstant_poolのインデックス *const_name_index::列挙型の定数名を示すconstant_poolのインデックス



586
587
588
589
590
# File 'lib/javaclass/attribute.rb', line 586

def initialize( java_class, tag=nil, type_name_index=nil, const_name_index=nil  )
  super( java_class, tag )
  @type_name_index = type_name_index
  @const_name_index = const_name_index
end

Instance Attribute Details

#const_name_indexObject

Returns the value of attribute const_name_index.



607
608
609
# File 'lib/javaclass/attribute.rb', line 607

def const_name_index
  @const_name_index
end

#type_name_indexObject

Returns the value of attribute type_name_index.



606
607
608
# File 'lib/javaclass/attribute.rb', line 606

def type_name_index
  @type_name_index
end

Instance Method Details

#const_nameObject



594
595
596
# File 'lib/javaclass/attribute.rb', line 594

def const_name
  @java_class.get_constant_value(@const_name_index)
end

#to_bytesObject



600
601
602
603
604
# File 'lib/javaclass/attribute.rb', line 600

def to_bytes
  bytes = super
  bytes += to_byte( @type_name_index, 2)
  bytes += to_byte( @const_name_index, 2)
end

#to_sObject



597
598
599
# File 'lib/javaclass/attribute.rb', line 597

def to_s
  convert_field_descriptor(type_name) << "." << const_name.to_s
end

#type_nameObject



591
592
593
# File 'lib/javaclass/attribute.rb', line 591

def type_name
  @java_class.get_constant_value(@type_name_index)
end