Class: JavaClass::ExceptionsAttribute

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, exception_index_table) ⇒ ExceptionsAttribute

コンストラクタ

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



91
92
93
94
# File 'lib/javaclass/attribute.rb', line 91

def initialize( java_class, name_index, exception_index_table )
  super( java_class, name_index)
  @exception_index_table = exception_index_table
end

Instance Attribute Details

#exception_index_tableObject

例外テーブル



118
119
120
# File 'lib/javaclass/attribute.rb', line 118

def exception_index_table
  @exception_index_table
end

Instance Method Details

#exceptionsObject

例外の配列を取得する。

戻り値::例外の配列



100
101
102
103
104
# File 'lib/javaclass/attribute.rb', line 100

def exceptions
  exception_index_table.map() {|index|
    @java_class.get_constant(index)
  }
end

#to_bytesObject



108
109
110
111
112
113
114
115
116
# File 'lib/javaclass/attribute.rb', line 108

def to_bytes
  bytes = super
  bytes += to_byte( 2+(2 * (@exception_index_table.length)), 4)
  bytes += to_byte( @exception_index_table.length, 2)
  @exception_index_table.each {|index|
    bytes += to_byte( index, 2)
  }
  return bytes
end

#to_sObject



105
106
107
# File 'lib/javaclass/attribute.rb', line 105

def to_s
  "throws " << exceptions.map(){|ex| ex.name }.join(", ")
end