Class: JavaClass::UTF8Constant

Inherits:
Constant
  • Object
show all
Defined in:
lib/javaclass/constant.rb

Overview

文字列のConstant

Constant Summary

Constants inherited from Constant

Constant::CONSTANT_Class, Constant::CONSTANT_Double, Constant::CONSTANT_Fieldref, Constant::CONSTANT_Float, Constant::CONSTANT_Integer, Constant::CONSTANT_InterfaceMethodref, Constant::CONSTANT_Long, Constant::CONSTANT_Methodref, Constant::CONSTANT_NameAndType, Constant::CONSTANT_String, Constant::CONSTANT_Utf8

Instance Attribute Summary collapse

Attributes inherited from Constant

#java_class, #tag

Instance Method Summary collapse

Methods included from Base

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

Constructor Details

#initialize(java_class, tag = nil, bytes = nil) ⇒ UTF8Constant

コンストラクタ

*java_class::constantの所有者であるJavaクラス *tag::constantの種類を示すタグ *bytes::値



249
250
251
252
# File 'lib/javaclass/constant.rb', line 249

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

Instance Attribute Details

#bytesObject

Returns the value of attribute bytes.



265
266
267
# File 'lib/javaclass/constant.rb', line 265

def bytes
  @bytes
end

Instance Method Details

#to_bytesObject



253
254
255
256
257
258
259
260
261
# File 'lib/javaclass/constant.rb', line 253

def to_bytes()
  tmp = super
  body = []
  @bytes.each_byte {|i|
    body += to_byte( i, 1 )
  }
  tmp += to_byte( body.length, 2 )
  tmp += body
end

#to_sObject



262
263
264
# File 'lib/javaclass/constant.rb', line 262

def to_s
  "\"#{bytes}\""
end