Class: Rex::Java::Serialization::Model::NewArray
- Includes:
- Contents
- Defined in:
- lib/rex/java/serialization/model/new_array.rb
Overview
This class provides a NewArray (Java Array) representation
Constant Summary
Constants included from Rex::Java::Serialization
BASE_WIRE_HANDLE, OBJECT_TYPE_CODES, PRIMITIVE_TYPE_CODES, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, TC_ARRAY, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING, TYPE_CODES
Instance Attribute Summary collapse
-
#array_description ⇒ Java::Serialization::Model::ClassDesc
The description of the array.
-
#type ⇒ String
The type of the array values.
-
#values ⇒ Array
The contents of the java array.
Attributes inherited from Element
Instance Method Summary collapse
-
#decode(io) ⇒ self
Deserializes a Rex::Java::Serialization::Model::NewArray.
-
#encode ⇒ String
Serializes the Rex::Java::Serialization::Model::NewArray.
-
#initialize(stream = nil) ⇒ NewArray
constructor
A new instance of NewArray.
-
#to_s ⇒ String
Creates a print-friendly string representation.
Methods included from Contents
#decode_content, #encode_content, #print_class, #print_content
Methods inherited from Element
Constructor Details
#initialize(stream = nil) ⇒ NewArray
Returns a new instance of NewArray.
23 24 25 26 27 28 |
# File 'lib/rex/java/serialization/model/new_array.rb', line 23 def initialize(stream = nil) super(stream) self.array_description = nil self.type = '' self.values = [] end |
Instance Attribute Details
#array_description ⇒ Java::Serialization::Model::ClassDesc
Returns The description of the array.
14 15 16 |
# File 'lib/rex/java/serialization/model/new_array.rb', line 14 def array_description @array_description end |
#type ⇒ String
Returns The type of the array values.
17 18 19 |
# File 'lib/rex/java/serialization/model/new_array.rb', line 17 def type @type end |
#values ⇒ Array
Returns The contents of the java array.
20 21 22 |
# File 'lib/rex/java/serialization/model/new_array.rb', line 20 def values @values end |
Instance Method Details
#decode(io) ⇒ self
Deserializes a Rex::Java::Serialization::Model::NewArray
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rex/java/serialization/model/new_array.rb', line 35 def decode(io) self.array_description = ClassDesc.decode(io, stream) stream.add_reference(self) unless stream.nil? self.type = array_type values_length = decode_values_length(io) values_length.times do value = decode_value(io) self.values << value end self end |
#encode ⇒ String
Serializes the Rex::Java::Serialization::Model::NewArray
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rex/java/serialization/model/new_array.rb', line 54 def encode unless array_description.class == ClassDesc raise ::RuntimeError, 'Failed to serialize NewArray' end encoded = '' encoded << array_description.encode encoded << [values.length].pack('N') values.each do |value| encoded << encode_value(value) end encoded end |
#to_s ⇒ String
Creates a print-friendly string representation
74 75 76 77 78 |
# File 'lib/rex/java/serialization/model/new_array.rb', line 74 def to_s str = "#{type}, " values_data = values.collect {|v| "#{v}"} str << "#{values_data}" end |