Class: JavaClass::Annotation
- Inherits:
-
Object
- Object
- JavaClass::Annotation
- Includes:
- Base, Converters
- Defined in:
- lib/javaclass/attribute.rb
Overview
アノテーション
Instance Attribute Summary collapse
-
#elements ⇒ Object
Returns the value of attribute elements.
-
#type_index ⇒ Object
Returns the value of attribute type_index.
Instance Method Summary collapse
-
#initialize(java_class, type_index, elements = {}) ⇒ Annotation
constructor
コンストラクタ.
- #to_bytes ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
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, type_index, elements = {}) ⇒ Annotation
コンストラクタ
*java_class::属性の所有者であるJavaクラス*type_index::アノテーションの種別を示すconstant_poolのインデックス*elements::アノテーションのデータペア一覧
461 462 463 464 465 |
# File 'lib/javaclass/attribute.rb', line 461 def initialize( java_class, type_index, elements={} ) @java_class = java_class @type_index = type_index @elements = elements end |
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
486 487 488 |
# File 'lib/javaclass/attribute.rb', line 486 def elements @elements end |
#type_index ⇒ Object
Returns the value of attribute type_index.
485 486 487 |
# File 'lib/javaclass/attribute.rb', line 485 def type_index @type_index end |
Instance Method Details
#to_bytes ⇒ Object
476 477 478 479 480 481 482 483 |
# File 'lib/javaclass/attribute.rb', line 476 def to_bytes bytes = to_byte( @type_index, 2) bytes += to_byte( @elements.size, 2) @elements.each {|k,v| bytes += v.to_bytes() } return bytes end |
#to_s ⇒ Object
469 470 471 472 473 474 475 |
# File 'lib/javaclass/attribute.rb', line 469 def to_s str = "@" << convert_field_descriptor(type) str << "(\n" unless @elements.empty? str << @elements.map {|k,v| " " << v.to_s }.join( ",\n" ) str << "\n)" unless @elements.empty? return str end |
#type ⇒ Object
466 467 468 |
# File 'lib/javaclass/attribute.rb', line 466 def type @java_class.get_constant_value(@type_index) end |