Class: Rex::Java::Serialization::Model::LongUtf
- Defined in:
- lib/rex/java/serialization/model/long_utf.rb
Overview
This class provides a Long Utf string representation
Instance Attribute Summary
Attributes inherited from Utf
Attributes inherited from Element
Instance Method Summary collapse
-
#decode(io) ⇒ self
Deserializes a Rex::Java::Serialization::Model::LongUtf.
-
#encode ⇒ String
Serializes the Rex::Java::Serialization::Model::LongUtf.
Methods inherited from Utf
Methods inherited from Element
Constructor Details
This class inherits a constructor from Rex::Java::Serialization::Model::Utf
Instance Method Details
#decode(io) ⇒ self
Deserializes a Rex::Java::Serialization::Model::LongUtf
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rex/java/serialization/model/long_utf.rb', line 15 def decode(io) raw_length = io.read(8) if raw_length.nil? || raw_length.length != 8 raise Rex::Java::Serialization::DecodeError, 'Failed to unserialize LongUtf' end self.length = raw_length.unpack('Q>')[0] if length == 0 self.contents = '' else self.contents = io.read(length) if contents.nil? || contents.length != length raise Rex::Java::Serialization::DecodeError, 'Failed to unserialize LongUtf' end end self end |
#encode ⇒ String
Serializes the Rex::Java::Serialization::Model::LongUtf
37 38 39 40 41 42 |
# File 'lib/rex/java/serialization/model/long_utf.rb', line 37 def encode encoded = [length].pack('Q>') encoded << contents encoded end |