rtm-javatmapi 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/DISCLAIMER +13 -0
  2. data/LICENSE +201 -0
  3. data/README +4 -0
  4. data/lib/rtm/javatmapi.rb +189 -0
  5. data/lib/rtm/javatmapi/aliases.rb +43 -0
  6. data/lib/rtm/javatmapi/base.rb +30 -0
  7. data/lib/rtm/javatmapi/core.rb +16 -0
  8. data/lib/rtm/javatmapi/core/association.rb +71 -0
  9. data/lib/rtm/javatmapi/core/construct.rb +68 -0
  10. data/lib/rtm/javatmapi/core/locator.rb +24 -0
  11. data/lib/rtm/javatmapi/core/name.rb +101 -0
  12. data/lib/rtm/javatmapi/core/occurrence.rb +56 -0
  13. data/lib/rtm/javatmapi/core/reifiable.rb +48 -0
  14. data/lib/rtm/javatmapi/core/role.rb +49 -0
  15. data/lib/rtm/javatmapi/core/scoped.rb +99 -0
  16. data/lib/rtm/javatmapi/core/topic.rb +454 -0
  17. data/lib/rtm/javatmapi/core/topic_map.rb +632 -0
  18. data/lib/rtm/javatmapi/core/topic_map_system.rb +6 -0
  19. data/lib/rtm/javatmapi/core/typed.rb +31 -0
  20. data/lib/rtm/javatmapi/core/variant.rb +19 -0
  21. data/lib/rtm/javatmapi/ext.rb +4 -0
  22. data/lib/rtm/javatmapi/ext/java_util_set.rb +10 -0
  23. data/lib/rtm/javatmapi/inclusion.rb +46 -0
  24. data/lib/rtm/javatmapi/java_implementations.rb +40 -0
  25. data/lib/rtm/javatmapi/javalibs/asm-2.2.3.jar +0 -0
  26. data/lib/rtm/javatmapi/javalibs/asm-commons-2.2.3.jar +0 -0
  27. data/lib/rtm/javatmapi/javalibs/ctm-writer-1.0.0a.jar +0 -0
  28. data/lib/rtm/javatmapi/javalibs/jing.jar +0 -0
  29. data/lib/rtm/javatmapi/javalibs/json_simple.jar +0 -0
  30. data/lib/rtm/javatmapi/javalibs/log4j-1.2.14.jar +0 -0
  31. data/lib/rtm/javatmapi/javalibs/ocutil-2.4.2.jar +0 -0
  32. data/lib/rtm/javatmapi/javalibs/openrdf-sesame-2.2.1-onejar.jar +0 -0
  33. data/lib/rtm/javatmapi/javalibs/poi-3.2-FINAL.jar +0 -0
  34. data/lib/rtm/javatmapi/javalibs/poi-3.5-beta6-20090622.jar +0 -0
  35. data/lib/rtm/javatmapi/javalibs/poi-contrib-3.5-beta6-20090622.jar +0 -0
  36. data/lib/rtm/javatmapi/javalibs/poi-ooxml-3.5-beta6-20090622.jar +0 -0
  37. data/lib/rtm/javatmapi/javalibs/poi-scratchpad-3.2-FINAL.jar +0 -0
  38. data/lib/rtm/javatmapi/javalibs/poi-scratchpad-3.5-beta6-20090622.jar +0 -0
  39. data/lib/rtm/javatmapi/javalibs/semagia-mio-0.9.5.jar +0 -0
  40. data/lib/rtm/javatmapi/javalibs/semagia-mio-ctm-0.9.3-working-draft-2009-02-18.jar +0 -0
  41. data/lib/rtm/javatmapi/javalibs/semagia-mio-jtm-0.9.4.jar +0 -0
  42. data/lib/rtm/javatmapi/javalibs/semagia-mio-ltm-0.9.5.jar +0 -0
  43. data/lib/rtm/javatmapi/javalibs/semagia-mio-snello-0.9.3.jar +0 -0
  44. data/lib/rtm/javatmapi/javalibs/semagia-mio-tmxml-0.9.5.jar +0 -0
  45. data/lib/rtm/javatmapi/javalibs/semagia-mio-xtm-0.9.5.jar +0 -0
  46. data/lib/rtm/javatmapi/javalibs/slf4j-api-1.5.8.jar +0 -0
  47. data/lib/rtm/javatmapi/javalibs/slf4j-log4j12-1.5.8.jar +0 -0
  48. data/lib/rtm/javatmapi/javalibs/tinytim-mio-2.0.0a5.jar +0 -0
  49. data/lib/rtm/javatmapi/javalibs/tmapi-2.0a2.jar +0 -0
  50. data/lib/rtm/javatmapi/javalibs/tmapix-io-0.3.0-snapshot-200910281502.jar +0 -0
  51. data/lib/rtm/javatmapi/javalibs/trove-2.0.4.jar +0 -0
  52. data/lib/rtm/javatmapi/superiseable.rb +74 -0
  53. metadata +118 -0
@@ -0,0 +1,30 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM
5
+
6
+ def self.connect
7
+ @@tmsf = TopicMapSystemFactory.newInstance.newTopicMapSystem
8
+ end
9
+
10
+ def self.create(base_locator)
11
+ @@tmsf.createTopicMap(base_locator)
12
+ end
13
+
14
+
15
+ def self.[](*args)
16
+ if args.size == 0
17
+ return @@tmsf.getLocators.map {|l| @@tmsf.getTopicMap l}
18
+ end
19
+ args.map{|l| @@tmsf.getTopicMap l }
20
+ end
21
+
22
+ # Applications SHOULD call this method when the RTM is no longer required
23
+ def self.close
24
+ if defined?(@@tmsf) && @@tmsf.nil?
25
+ @@tmsf.close
26
+ @@tmsf = nil
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,16 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ require 'rtm/javatmapi/core/topic_map_system'
5
+ require 'rtm/javatmapi/core/construct'
6
+ require 'rtm/javatmapi/core/reifiable'
7
+ require 'rtm/javatmapi/core/topic_map'
8
+ require 'rtm/javatmapi/core/topic'
9
+ require 'rtm/javatmapi/core/name'
10
+ require 'rtm/javatmapi/core/occurrence'
11
+ require 'rtm/javatmapi/core/association'
12
+ require 'rtm/javatmapi/core/role'
13
+ require 'rtm/javatmapi/core/scoped'
14
+ require 'rtm/javatmapi/core/locator'
15
+ require 'rtm/javatmapi/core/variant'
16
+ require 'rtm/javatmapi/core/typed'
@@ -0,0 +1,71 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module Java::OrgTmapiCore::Association
5
+
6
+ extend Superiseable
7
+ #include RTM::Association
8
+
9
+ superised
10
+ # Returns the topic map this association belongs to.
11
+ #
12
+ # :call-seq:
13
+ # parent -> TopicMap
14
+ #
15
+ def parent
16
+ getParent
17
+ end
18
+ alias :topic_map :parent
19
+ alias :reverse_children :parent
20
+
21
+ # Returns all roles parented by this association.
22
+ #
23
+ # :call-seq:
24
+ # children -> Set of Roles
25
+ #
26
+ def children
27
+ getRoles
28
+ end
29
+ alias :reverse_parent :children
30
+
31
+ superised
32
+ # Creates a new role in this association. The optional argument 'type'
33
+ # specifies the role type and
34
+ # 'player' specifies the role player.
35
+ #
36
+ # Type and player may each be topic references.
37
+ #
38
+ # :call-seq:
39
+ # create_role(type, player) -> Role
40
+ #
41
+ def create_role(type, player)
42
+ createRole(topic_map.get!(type),topic_map.get!(player))
43
+ end
44
+
45
+ superised
46
+ # Returns the Roles participating in this Association.
47
+ # The optional identifier specifies the type of
48
+ # the returned Roles.
49
+ #
50
+ # Identifier may be a Topic or Topic-Reference.
51
+ #
52
+ # The result may be empty.
53
+ #
54
+ # :call-seq:
55
+ # roles -> Set of Roles
56
+ # roles(identifier) -> Set of Roles
57
+ #
58
+ def roles(type = :any)
59
+ return getRoles if type == :any
60
+ return java.util.HashSet.new if type == nil
61
+ _topic = topic_map.get(type)
62
+ if _topic.is_a?(Java::OrgTmapiCore::Topic)
63
+ return getRoles(_topic)
64
+ else
65
+ return java.util.HashSet.new
66
+ end
67
+ end
68
+
69
+
70
+ end
71
+
@@ -0,0 +1,68 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module Java::OrgTmapiCore::Construct
5
+
6
+ extend Superiseable
7
+ #include RTM::Construct
8
+
9
+ # Returns the TopicMap instance this Construct belongs to.
10
+ #
11
+ # :call-seq:
12
+ # topic_map -> TopicMap
13
+ #
14
+ def topic_map
15
+ getTopicMap
16
+ end
17
+
18
+ # Returns true if the construct fulfills all constraints defined in the TMDM
19
+ def valid?
20
+ # This is defined in RTM::AR and we test it. I guess from the API perspective, in TMAPI the validness of an object is guaranteed.
21
+ true
22
+ end unless self.method_defined?(:valid?)
23
+
24
+ superised
25
+ # Adds an item identifier to this construct.
26
+ # Identifier may be a String or Locator.
27
+ #
28
+ # :call-seq:
29
+ # item_identifiers=(identifier)
30
+ #
31
+ def add_item_identifier(identifier)
32
+ # TODO Spec
33
+ if identifier.is_a? Java::OrgTmapiCore::Locator
34
+ addItemIdentifier(identifier)
35
+ else
36
+ addItemIdentifier(topic_map.create_locator(identifier))
37
+ end
38
+ end
39
+ alias :item_identifiers= :add_item_identifier
40
+
41
+
42
+ superised
43
+ # Removes an item identifer from this construct,
44
+ # if present.
45
+ #
46
+ # Identifier may be a String or Locator.
47
+ #
48
+ # :call-seq:
49
+ # remove_item_identifier(identifier)
50
+ #
51
+ def remove_item_identifier(identifier)
52
+ identifier = topic_map.create_locator(identifier) if identifier.is_a? String
53
+ removeItemIdentifier(identifier) if identifier.is_a? Java::OrgTmapiCore::Locator
54
+ end
55
+
56
+ # Returns the identifier of this construct.
57
+ # This property has no representation in the Topic Maps - Data Model.
58
+ # The ID can be anything, so long as no other Construct in the
59
+ # same topic map has the same ID.
60
+ #
61
+ # :call_spec:
62
+ # id -> String
63
+ #
64
+ def id
65
+ getId
66
+ end
67
+
68
+ end
@@ -0,0 +1,24 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module Java::OrgTmapiCore::Locator
5
+
6
+ #include RTM::Locator
7
+ extend Superiseable
8
+
9
+ # Returns the external form of the IRI.
10
+ # Any special character will be escaped using the escaping conventions
11
+ # of RFC 3987.
12
+ #
13
+ # :call-seq:
14
+ # value -> String
15
+ #
16
+ def value
17
+ toExternalForm
18
+ end
19
+
20
+ superised
21
+ def to_s
22
+ self.value
23
+ end
24
+ end
@@ -0,0 +1,101 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module Java::OrgTmapiCore::Name
5
+
6
+ #include RTM::Name
7
+ extend Superiseable
8
+
9
+
10
+ # Returns the Topic this Name belongs to.
11
+ #
12
+ # :call-seq:
13
+ # parent -> Topic
14
+ #
15
+ def parent
16
+ getParent
17
+ end
18
+ alias :reverse_children :parent
19
+
20
+ # Returns all Variants defined for this Name.
21
+ #
22
+ # :call-seq:
23
+ # children -> Array of Variants
24
+ #
25
+ def children
26
+ getVariants.to_a
27
+ end
28
+ alias :reverse_parent :children
29
+
30
+ superised
31
+ # Returns the value of this Name.
32
+ #
33
+ # :call-seq:
34
+ # value -> String
35
+ #
36
+ def value
37
+ getValue
38
+ end
39
+
40
+ # Sets the value of this name. The previous value is overridden.
41
+ #
42
+ # Argument is a String.
43
+ #
44
+ # :call-seq:
45
+ # value=(argument)
46
+ #
47
+ def value=(argument)
48
+ setValue(argument)
49
+ end
50
+
51
+ superised
52
+ # Creates a Variant given the value and scope, if value is a Locator or
53
+ # given value, datatype and scope, if the value is a String.
54
+ #
55
+ # Scope may be an Array of Topic/Topic-References and must not be empty.
56
+ #
57
+ # Datatype may be a Topic-Reference (String or Locator).
58
+ #
59
+ # :call-seq:
60
+ # create_variant(value, scope) -> Variant
61
+ # create_variant(value, datatype, scope) -> Variant
62
+ #
63
+ def create_variant(arg1, arg2, arg3 = :nothing)
64
+ if arg1.is_a?(Java::OrgTmapiCore::Locator)
65
+ raise("create_variant(value,scope), value: Locator, scope must be an Array") unless arg2.is_a?(Array)
66
+ if arg2.empty?
67
+ raise("create_variant(value,scope), value: Locator, scope must not be empty")
68
+ end
69
+ arg2.each do |theme|
70
+ raise("create_variant(value,scope), value: Locator, scope must contain Topic/Topic-References") unless (theme.is_a?(Java::OrgTmapiCore::Topic) || theme.is_a?(String) || theme.is_a?(Java::OrgTmapiCore::Locator))
71
+ end
72
+ return createVariant(arg1, topic_map.get!(arg2).to_java(org.tmapi.core.Topic))
73
+ elsif arg1.is_a?(String)
74
+ if arg3 == :nothing
75
+ raise("create_variant(value,scope), value: String, scope must be an Array") unless arg2.is_a?(Array)
76
+ if arg2.empty?
77
+ raise("create_variant(value,scope), value: String, scope must not be empty")
78
+ end
79
+ arg2.each do |theme|
80
+ raise("create_variant(value,scope), value: String, scope must contain Topic/Topic-References") unless (theme.is_a?(Java::OrgTmapiCore::Topic) || theme.is_a?(String) || theme.is_a?(Java::OrgTmapiCore::Locator))
81
+ end
82
+ return createVariant(arg1, topic_map.get!(arg2).to_java(org.tmapi.core.Topic))
83
+ elsif (arg2.is_a?(Locator) || arg2.is_a?(String))
84
+ if ((arg2 == RTM::PSI[:String]) || (arg2 == topic_map.create_locator(RTM::PSI[:String])))
85
+ return createVariant(arg1, topic_map.create_locator(RTM::PSI[:String]), topic_map.get!(arg3))
86
+ elsif ((arg2 == RTM::PSI[:IRI]) || (arg2 == topic_map.create_locator(RTM::PSI[:IRI])))
87
+ return createVariant(arg1, topic_map.create_locator(RTM::PSI[:IRI]), topic_map.get!(arg3))
88
+ elsif ((arg2 == RTM::PSI[:XML]) || (arg2 == topic_map.create_locator(RTM::PSI[:XML])))
89
+ return createVariant(arg1, topic_map.create_locator(RTM::PSI[:XML]), topic_map.get!(arg3))
90
+ else
91
+ raise("create_variant(value,datatype,scope), value: String, unknown datatype")
92
+ end
93
+ else
94
+ raise("create_variant(value,datatype,scope), datatype must be a String (identifier) or Locator")
95
+ end
96
+ else
97
+ raise "create_variant: value not a Locator or String"
98
+ end
99
+ end
100
+
101
+ end
@@ -0,0 +1,56 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module Java::OrgTmapiCore::Occurrence
5
+
6
+ #include RTM::Occurrence
7
+
8
+ # Returns the Topic this Occurrence belongs to.
9
+ #
10
+ # :call-seq:
11
+ # parent -> Topic
12
+ #
13
+ def parent
14
+ getParent
15
+ end
16
+ alias :reverse_children :parent
17
+
18
+ # Returns the lexical representation of the value of the Occurrence.
19
+ #
20
+ # For the datatype String the string itself is returned
21
+ # For the datatype anyURI the Locator.getReference -> String is returned.
22
+ #
23
+ # :call-seq:
24
+ # value -> String
25
+ #
26
+ def value
27
+ getValue
28
+ end
29
+
30
+
31
+ # If argument is a String, this methods sets the string value and
32
+ # the datatype implicitly to xsd:string.
33
+ #
34
+ # If argument is a Locator, this method sets the IRI value and
35
+ # the datatype implicitly to xsd:anyURI.
36
+ #
37
+ # If argument is a Float, this method sets the Float value and
38
+ # the datatype implicitly to xsd:float.
39
+ #
40
+ # If argument is a Fixnum, this method sets Fixnum value and
41
+ # the datatype implicitly to xsd:long.
42
+ #
43
+ # If argument is a Bignum, this method sets Bignum value and
44
+ # the datatype implicitly to xsd:integer.
45
+ #
46
+ # :call-seq:
47
+ # value=(argument)
48
+ #
49
+ def value=(argument)
50
+ setValue(argument)
51
+ end
52
+
53
+
54
+
55
+
56
+ end
@@ -0,0 +1,48 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module Java::OrgTmapiCore::Reifiable
5
+
6
+ #include RTM::Reifiable
7
+ extend Superiseable
8
+
9
+ # Returns the reifier (Topic) of this Reifiable
10
+ # or nil if the Reifiable is not reified.
11
+ #
12
+ # :call-seq:
13
+ # reifier -> Topic
14
+ #
15
+ def reifier
16
+ getReifier
17
+ end
18
+
19
+ # Returns the reifier (Topic) of this Reifiable.
20
+ # If there is no current reifier, then a reifier will be generated.
21
+ #
22
+ # :call-seq:
23
+ # reifier! -> Topic
24
+ #
25
+ def reifier!
26
+ self.reifier ||= self.topic_map.create_topic
27
+ end
28
+
29
+ superised
30
+ # Sets the reifier of this reifiable Construct.
31
+ # The specified reifier MUST NOT reify another information item.
32
+ #
33
+ # Identifier may be a Topic or Topic-Reference or nil,
34
+ # if an existing reifier should be removed.
35
+ #
36
+ # :call-seq:
37
+ # reifier = identifier
38
+ # reifier = ()
39
+ #
40
+ def reifier=(identifier=nil)
41
+ unless identifier
42
+ setReifier(identifier)
43
+ return
44
+ end
45
+ raise("reifier=: identifier muss be a Topic, Locator or String; not given or nil") unless identifier.is_a?(Java::OrgTmapiCore::Topic) || identifier.is_a?(Java::OrgTmapiCore::Locator) || identifier.is_a?(String)
46
+ setReifier(topic_map.get!(identifier))
47
+ end
48
+ end
@@ -0,0 +1,49 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module Java::OrgTmapiCore::Role
5
+
6
+ #include RTM::Role
7
+ extend Superiseable
8
+
9
+ # Returns the Association to which this Role belongs.
10
+ #
11
+ # :call-seq:
12
+ # parent -> Association
13
+ #
14
+ def parent
15
+ getParent
16
+ end
17
+ alias :reverse_children :parent
18
+
19
+ # Returns the Topic playing the current Role.
20
+ #
21
+ # :call-seq:
22
+ # player -> Topic
23
+ #
24
+ def player
25
+ getPlayer
26
+ end
27
+
28
+ superised
29
+ # Sets the role player. Any previous role player will be overriden.
30
+ #
31
+ # Identifier may be a Topic or Topic-Reference.
32
+ #
33
+ # :call-seq:
34
+ # player=(identifier)
35
+ #
36
+ def player=(identifier)
37
+ setPlayer(topic_map.get!(identifier))
38
+ end
39
+
40
+ # Returns the identifier of the current Role.
41
+ # This property has no representation in the Topic Maps - Data Model.
42
+ #
43
+ # :call-seq:
44
+ # id -> String
45
+ #
46
+ def id
47
+ getId
48
+ end
49
+ end