13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rtm/ontopia/io/to_cxtm.rb', line 13
def to_cxtm(file=nil)
raise("Only supported for Ontopia.") unless self.kind_of?(Java::NetOntopiaTopicmapsImplTmapi2::TopicMapImpl)
if file
if file.is_a?(java.io.OutputStream)
out_stream = file
else
out_stream = java.io.BufferedOutputStream.new(java.io.FileOutputStream.new(file))
end
else
out_stream = java.io.ByteArrayOutputStream.new
end
writer = Java::NetOntopiaTopicmapsXml::CanonicalXTMWriter.new(out_stream)
writer.write(self.wrapped)
out_stream.flush
out_stream.close unless file && file.is_a?(java.io.OutputStream)
out_stream.to_s unless file
end
|