Class: JavaClass::AnnotationsAttribute

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, annotations = []) ⇒ AnnotationsAttribute

コンストラクタ

*java_class::属性の所有者であるJavaクラス *name_index::名前を示すconstant_poolのインデックス *annotations::アノテーションの配列



427
428
429
430
# File 'lib/javaclass/attribute.rb', line 427

def initialize( java_class, name_index, annotations=[] )
  super( java_class, name_index)
  @annotations = annotations
end

Instance Attribute Details

#annotationsObject

Returns the value of attribute annotations.



444
445
446
# File 'lib/javaclass/attribute.rb', line 444

def annotations
  @annotations
end

Instance Method Details

#to_bytesObject



434
435
436
437
438
439
440
441
442
# File 'lib/javaclass/attribute.rb', line 434

def to_bytes
  bytes = super
  body = to_byte( @annotations.length, 2)
  @annotations.each {|c|
    body += c.to_bytes()
  }
  bytes += to_byte( body.length, 4)
  bytes += body
end

#to_sObject



431
432
433
# File 'lib/javaclass/attribute.rb', line 431

def to_s
  @annotations.map{|a| a.to_s }.join("\n")
end