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.



55
56
57
# File 'lib/sentra/opr.rb', line 55

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

Instance Method Details

#read_from_xml_string(str) ⇒ Object



67
68
69
70
71
# File 'lib/sentra/opr.rb', line 67

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



59
60
61
62
63
64
65
# File 'lib/sentra/opr.rb', line 59

def write_to_xml_string article

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