Class JavaClass::ClassFile::Constants::SingleReference
In: lib/javaclass/classfile/constants/single_reference.rb
Parent: Base

Superclass of single reference constants like ConstantClass (Class) in the constant pool.

Author:Peter Kofler

Methods

dump   first_value   get   new   to_s  

Attributes

first_index  [R] 

Public Class methods

Define a single reference into pool from data beginning at start

[Source]

# File lib/javaclass/classfile/constants/single_reference.rb, line 15
        def initialize(pool, data, start, name=nil)
          super(name)
          @tag = data.u1(start)

          @enclosing_pool = pool
          @first_index = data.u2(start+1)
        end

Public Instance methods

Return part of debug output.

[Source]

# File lib/javaclass/classfile/constants/single_reference.rb, line 32
        def dump
          super + "##{@first_index};\t//  #{to_s}"
        end

Return the value, which is the referenced value from the pool.

[Source]

# File lib/javaclass/classfile/constants/single_reference.rb, line 24
        def first_value
          get(@first_index)
        end

[Source]

# File lib/javaclass/classfile/constants/single_reference.rb, line 27
        def to_s
          first_value
        end

Protected Instance methods

Get a reference ref from the enclosing_pool

[Source]

# File lib/javaclass/classfile/constants/single_reference.rb, line 39
        def get(ref)
          @enclosing_pool[ref].to_s
        end

[Validate]