Class: JavaClass::AnnotationElement

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/javaclass/attribute.rb

Overview

アノテーションのデータ

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

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

Constructor Details

#initialize(java_class, name_index = nil, value = nil) ⇒ AnnotationElement

コンストラクタ

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



501
502
503
504
505
# File 'lib/javaclass/attribute.rb', line 501

def initialize( java_class, name_index=nil, value=nil )
  @java_class = java_class
  @name_index = name_index
  @value = value
end

Instance Attribute Details

#name_indexObject

Returns the value of attribute name_index.



517
518
519
# File 'lib/javaclass/attribute.rb', line 517

def name_index
  @name_index
end

#valueObject

Returns the value of attribute value.



518
519
520
# File 'lib/javaclass/attribute.rb', line 518

def value
  @value
end

Instance Method Details

#nameObject



506
507
508
# File 'lib/javaclass/attribute.rb', line 506

def name
  @java_class.get_constant_value(@name_index)
end

#to_bytesObject



512
513
514
515
# File 'lib/javaclass/attribute.rb', line 512

def to_bytes
  bytes = to_byte( @name_index, 2)
  bytes += @value.to_bytes()
end

#to_sObject



509
510
511
# File 'lib/javaclass/attribute.rb', line 509

def to_s
  "#{name} = #{value.to_s}"
end