class Android::Resource::ResTableType

Attributes

config[R]
entry_count[R]
entry_start[R]
id[R]
keys[R]

Public Class Methods

new(data, offset, pkg) click to toggle source
Calls superclass method Android::Resource::Chunk::new
# File lib/android/resource.rb, line 296
def initialize(data, offset, pkg)
  @pkg = pkg
  super(data, offset)
end

Public Instance Methods

[](index) click to toggle source

@param [String] index key name @param [Fixnum] index key index @return [ResTableEntry] @return [ResTableMapEntry] @return nil if entry index is NO_ENTRY(0xFFFFFFFF)

# File lib/android/resource.rb, line 305
def [](index)
  @entries[index]
end
inspect() click to toggle source
# File lib/android/resource.rb, line 335
def inspect
  "<ResTableType offset:0x#{@offset.to_s(16)}, id:#{@id}, " +
  "count:#{@entry_count}, start:0x#{@entry_start.to_s(16)}>"
end

Private Instance Methods

parse() click to toggle source
Calls superclass method Android::Resource::ChunkHeader#parse
# File lib/android/resource.rb, line 309
def parse
  super
  @id = read_int8
  res0 = read_int8   # must be 0.(maybe 4byte align)
  res1 = read_int16  # must be 0.(maybe 4byte align)
  @entry_count = read_int32
  @entry_start = read_int32
  @config = ResTableConfig.new(@data, current_position)
  @data_io.seek(@config.size, IO::SEEK_CUR)

  @entries = []
  @keys = {}
  @entry_count.times do |i|
    entry_index = read_int32
    if entry_index == ResTableEntry::NO_ENTRY
      @entries << nil
    else
      entry = ResTableEntry.read_entry(@data, @offset + @entry_start + entry_index)
      @entries << entry
      @keys[@pkg.key(entry.key)] = i
    end
  end
end