Module: RTM::IO::TmapiXFrom::TopicMap
- Defined in:
- lib/rtm/io/tmapix_from.rb
Instance Method Summary collapse
- #from_anything(reader_class, *args) ⇒ Object
-
#from_ctm(*args) ⇒ Object
Reads a Topic Map from an CTM File whose location is given as String parameter.
-
#from_jtm(*args) ⇒ Object
Reads a JSON Topic Maps (JTM) File whose location is given as String parameter.
-
#from_ltm(*args) ⇒ Object
Reads a Topic Map from an LTM File whose location is given as String parameter.
-
#from_n3(filename, vocab) ⇒ Object
Reads a Notation3 (N3) File whose location is given as String .
-
#from_rdfxml(filename, vocab) ⇒ Object
Reads a RDF/XML File whose location is given as String The source vocabulary must provide the mapping vocabulary.
-
#from_tmxml(*args) ⇒ Object
Reads a Friendly Topic Maps XML (TM/XML) File independent of the version whose location is given as String parameter.
-
#from_xtm(*args) ⇒ Object
(also: #from_xtm21, #from_xtm20, #from_xtm2, #from_xtm10, #from_xtm1)
Reads a XML Topic Maps (XTM) File independent of the version whose location is given as String parameter.
Instance Method Details
#from_anything(reader_class, *args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rtm/io/tmapix_from.rb', line 12 def from_anything(reader_class, *args) raise "Only supported for TMAPI backends!!" unless self.kind_of?(Java::OrgTmapiCore::TopicMap) || self.kind_of?(Java::OrgTmapiCore::TopicMapSystem) params = {} # See if we got a params hash. It must be at the end, if it is given. # Take it off, so it won't be unshifted later. params = args.pop if args.last.is_a?(Hash) # Take the source as next (i.e. second after the writer) positional parameter or from hash. # Leave nil if neither found. source = args.shift || params[:source] # Take the base_iri as next (i.e. third after the file) positional parameter or from the hash. # Use the topic maps's base_iri if neither found. base_iri = args.shift || params[:base_iri] unless base_iri if self.kind_of?(RTM::TopicMap) base_iri = self.base_iri else base_iri = "imported:FIXME" end end if self.kind_of?(RTM::TopicMap) topic_map = self else topic_map = create(base_iri) end # TODO catch java.io.FileNotFoundException reader = reader_class.new(topic_map, java.io.File.new(source), base_iri) if reader_class == Java::OrgTmapixIo::LTMTopicMapReader reader.setLegacyMode(true) end reader.read topic_map end |
#from_ctm(*args) ⇒ Object
Reads a Topic Map from an CTM File whose location is given as String parameter.
:call-seq:
from_ctm(filename)
66 67 68 |
# File 'lib/rtm/io/tmapix_from.rb', line 66 def from_ctm(*args) from_anything(Java::OrgTmapixIo::CTMTopicMapReader, *args) end |
#from_jtm(*args) ⇒ Object
Reads a JSON Topic Maps (JTM) File whose location is given as String parameter.
:call-seq:
from_jtm(filename)
76 77 78 |
# File 'lib/rtm/io/tmapix_from.rb', line 76 def from_jtm(*args) from_anything(Java::OrgTmapixIo::JTMTopicMapReader, *args) end |
#from_ltm(*args) ⇒ Object
Reads a Topic Map from an LTM File whose location is given as String parameter.
:call-seq:
from_ltm(filename)
56 57 58 |
# File 'lib/rtm/io/tmapix_from.rb', line 56 def from_ltm(*args) from_anything(Java::OrgTmapixIo::LTMTopicMapReader, *args) end |
#from_n3(filename, vocab) ⇒ Object
Reads a Notation3 (N3) File whose location is given as String . The source vocabulary must provide the mapping vocabulary. The syntax of the vocabulary is guessed.
:call-seq:
from_n3(filename, source vocabulary)
116 117 118 119 120 121 |
# File 'lib/rtm/io/tmapix_from.rb', line 116 def from_n3(filename, vocab) raise "Only supported for TMAPI backends!!" unless self.kind_of? Java::OrgTmapiCore::TopicMap reader = Java::OrgTmapixIo::N3TopicMapReader.new self, java.io.File.new(filename) reader.setMappingSource(java.io.File.new(vocab)) reader.read end |
#from_rdfxml(filename, vocab) ⇒ Object
Reads a RDF/XML File whose location is given as String The source vocabulary must provide the mapping vocabulary. The syntax of the vocabulary is guessed.
:call-seq:
from_rdfxml(filename, source vocabulary)
132 133 134 135 136 137 |
# File 'lib/rtm/io/tmapix_from.rb', line 132 def from_rdfxml(filename, vocab) raise "Only supported for TMAPI backends!!" unless self.kind_of? Java::OrgTmapiCore::TopicMap reader = Java::OrgTmapixIo::RDFXMLTopicMapReader.new self, java.io.File.new(filename) reader.setMappingSource(java.io.File.new(vocab)) reader.read end |
#from_tmxml(*args) ⇒ Object
Reads a Friendly Topic Maps XML (TM/XML) File independent of the version whose location is given as String parameter.
:call-seq:
from_tmxml(filename)
87 88 89 |
# File 'lib/rtm/io/tmapix_from.rb', line 87 def from_tmxml(*args) from_anything(Java::OrgTmapixIo::TMXMLTopicMapReader, *args) end |
#from_xtm(*args) ⇒ Object Also known as: from_xtm21, from_xtm20, from_xtm2, from_xtm10, from_xtm1
Reads a XML Topic Maps (XTM) File independent of the version whose location is given as String parameter.
:call-seq:
from_xtm(filename)
98 99 100 |
# File 'lib/rtm/io/tmapix_from.rb', line 98 def from_xtm(*args) from_anything(Java::OrgTmapixIo::XTMTopicMapReader, *args) end |