Class: Rex::Java::Serialization::Model::NewEnum
- Includes:
- Contents
- Defined in:
- lib/rex/java/serialization/model/new_enum.rb
Overview
This class provides a NewEnum (Java Enum) 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
-
#constant_name ⇒ Rex::Java::Serialization::Model::Utf
The constant value in the Java Enum.
-
#enum_description ⇒ Rex::Java::Serialization::Model::ClassDescription
The description of the enum.
Attributes inherited from Element
Instance Method Summary collapse
-
#decode(io) ⇒ self
Deserializes a Rex::Java::Serialization::Model::NewEnum.
-
#encode ⇒ String
Serializes the Rex::Java::Serialization::Model::NewEnum.
-
#initialize(stream = nil) ⇒ NewEnum
constructor
A new instance of NewEnum.
-
#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) ⇒ NewEnum
Returns a new instance of NewEnum.
20 21 22 23 24 |
# File 'lib/rex/java/serialization/model/new_enum.rb', line 20 def initialize(stream = nil) super(stream) self.enum_description = nil self.constant_name = nil end |
Instance Attribute Details
#constant_name ⇒ Rex::Java::Serialization::Model::Utf
Returns The constant value in the Java Enum.
17 18 19 |
# File 'lib/rex/java/serialization/model/new_enum.rb', line 17 def constant_name @constant_name end |
#enum_description ⇒ Rex::Java::Serialization::Model::ClassDescription
Returns The description of the enum.
14 15 16 |
# File 'lib/rex/java/serialization/model/new_enum.rb', line 14 def enum_description @enum_description end |
Instance Method Details
#decode(io) ⇒ self
Deserializes a Rex::Java::Serialization::Model::NewEnum
31 32 33 34 35 36 37 |
# File 'lib/rex/java/serialization/model/new_enum.rb', line 31 def decode(io) self.enum_description = ClassDesc.decode(io, stream) stream.add_reference(self) unless stream.nil? self.constant_name = decode_constant_name(io) self end |
#encode ⇒ String
Serializes the Rex::Java::Serialization::Model::NewEnum
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rex/java/serialization/model/new_enum.rb', line 43 def encode unless enum_description.kind_of?(ClassDesc) && constant_name.kind_of?(Utf) raise Rex::Java::Serialization::EncodeError, 'Failed to serialize EnumDescription' end encoded = '' encoded << enum_description.encode encoded << encode_content(constant_name) encoded end |
#to_s ⇒ String
Creates a print-friendly string representation
58 59 60 |
# File 'lib/rex/java/serialization/model/new_enum.rb', line 58 def to_s constant_name.to_s end |