Sha256: ed022ba2035d6f2a56bc2fecac6833f13cba58ffe3c0d24062eff0325da8ecf1

Contents?: true

Size: 1.79 KB

Versions: 13

Compression:

Stored size: 1.79 KB

Contents

# -*- coding: binary -*-

module Rex
  module Java
    module Serialization
      module Model
        # This class provides a NewArray (Java Array) representation
        class NewClass < Element

          include Rex::Java::Serialization::Model::Contents

          # @!attribute array_description
          #   @return [Java::Serialization::Model::ClassDesc] The description of the class
          attr_accessor :class_description

          # @param stream [Rex::Java::Serialization::Model::Stream] the stream where it belongs to
          def initialize(stream = nil)
            super(stream)
            self.class_description = nil
          end

          # Deserializes a Rex::Java::Serialization::Model::NewClass
          #
          # @param io [IO] the io to read from
          # @return [self] if deserialization succeeds
          # @raise [Rex::Java::Serialization::DecodeError] if deserialization doesn't succeed
          def decode(io)
            self.class_description = ClassDesc.decode(io, stream)
            stream.add_reference(self) unless stream.nil?

            self
          end

          # Serializes the Rex::Java::Serialization::Model::NewClass
          #
          # @return [String] if serialization succeeds
          # @raise [Rex::Java::Serialization::EncodeError] if serialization doesn't succeed
          def encode
            unless class_description.kind_of?(ClassDesc)
              raise Rex::Java::Serialization::EncodeError, 'Failed to serialize NewClass'
            end

            encoded = ''
            encoded << class_description.encode
          end

          # Creates a print-friendly string representation
          #
          # @return [String]
          def to_s
            print_content(class_description)
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
rex-java-0.1.7 lib/rex/java/serialization/model/new_class.rb
rex-java-0.1.6 lib/rex/java/serialization/model/new_class.rb
rex-2.0.13 lib/rex/java/serialization/model/new_class.rb
rex-2.0.12 lib/rex/java/serialization/model/new_class.rb
rex-2.0.11 lib/rex/java/serialization/model/new_class.rb
rex-java-0.1.5 lib/rex/java/serialization/model/new_class.rb
rex-java-0.1.4 lib/rex/java/serialization/model/new_class.rb
rex-java-0.1.3 lib/rex/java/serialization/model/new_class.rb
rex-java-0.1.2 lib/rex/java/serialization/model/new_class.rb
rex-java-0.1.1 lib/rex/java/serialization/model/new_class.rb
rex-java-0.1.0 lib/rex/java/serialization/model/new_class.rb
rex-2.0.10 lib/rex/java/serialization/model/new_class.rb
rex-2.0.9 lib/rex/java/serialization/model/new_class.rb