class Rex::Java::Serialization::Model::Annotation
This class provides an annotation representation. It's used for both class annotations (classAnnotation) and object annotations (objectAnnotation).
Attributes
contents[RW]
@!attribute contents
@return [Array] The annotation contents
Public Class Methods
new(stream = nil)
click to toggle source
@param stream [Rex::Java::Serialization::Model::Stream] the stream where it belongs to
Calls superclass method
# File lib/rex/java/serialization/model/annotation.rb, line 17 def initialize(stream = nil) super(stream) self.contents = [] end
Public Instance Methods
decode(io)
click to toggle source
Deserializes a Rex::Java::Serialization::Model::Annotation
@param io [IO] the io to read from @return [self] if deserialization succeeds @raise [Rex::Java::Serialization::DecodeError] if deserialization doesn't succeed
# File lib/rex/java/serialization/model/annotation.rb, line 27 def decode(io) loop do content = decode_content(io, stream) self.contents << content return self if content.kind_of?(EndBlockData) end self end
encode()
click to toggle source
Serializes the Rex::Java::Serialization::Model::Annotation
@return [String] if serialization suceeds @raise [Rex::Java::Serialization::EncodeError] if serialization doesn't succeed
# File lib/rex/java/serialization/model/annotation.rb, line 41 def encode raise Rex::Java::Serialization::EncodeError, 'Failed to serialize Annotation with empty contents' if contents.empty? encoded = '' contents.each do |content| encoded << encode_content(content) end encoded end
to_s()
click to toggle source
Creates a print-friendly string representation
@return [String]
# File lib/rex/java/serialization/model/annotation.rb, line 56 def to_s str = '[ ' contents_data = contents.collect {|content| "#{print_content(content)}"} str << contents_data.join(', ') str << ' ]' str end