Class: ArticleTools::ArticleSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/sentra/opr.rb

Instance Method Summary collapse

Constructor Details

#initializeArticleSerializer

Returns a new instance of ArticleSerializer.



39
40
41
# File 'lib/sentra/opr.rb', line 39

def initialize
  @simpleFormat = OprData::SimpleFormat.new(OprData::Article)
end

Instance Method Details

#read_from_xml_string(str) ⇒ Object



51
52
53
54
55
# File 'lib/sentra/opr.rb', line 51

def read_from_xml_string str
  java_str = java.lang.String.new(str)
  input = java.io.ByteArrayInputStream.new(java_str.getBytes("UTF-8"))
  @simpleFormat.parse(input)
end

#write_to_xml_string(article) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/sentra/opr.rb', line 43

def write_to_xml_string article

  out = java.io.ByteArrayOutputStream.new()
  @simpleFormat.format(out, article)
  out.close()
  out.toString("UTF-8")
end