Module: Java::OrgTmapiCore::DatatypeAware

Extended by:
Superiseable
Includes:
RTM::DatatypeAware
Defined in:
lib/rtm/javatmapi/core/datatype_aware.rb

Overview

Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. License: Apache License, Version 2.0

Instance Method Summary collapse

Methods included from Superiseable

method_added, register_java_implementation, superised, superising

Instance Method Details

#datatype=(datatype) ⇒ Object Also known as: set_datatype

Sets the datatype of this occurrence without changing its value.

The datatype must be a String or Locator.

:call-seq:

datatype = datatype


55
56
57
# File 'lib/rtm/javatmapi/core/datatype_aware.rb', line 55

def datatype=(datatype)
  self.value = self.value, datatype
end

#value=(args) ⇒ Object

Changes the value (and if given, the datatype) of this Occurrence.

The datatype must be a String or Locator.

If value is a String, this methods sets the string value and the datatype implicitly to xsd:string.

If argument is a Locator, this method sets the IRI value and the datatype implicitly to xsd:anyURI.

If argument is a Float, this method sets the Float value and the datatype implicitly to xsd:float.

If argument is a Fixnum, this method sets Fixnum value and the datatype implicitly to xsd:long.

If argument is a Bignum, this method sets Bignum value and the datatype implicitly to xsd:integer.

:call-seq:

value = value
value = value, datatype


33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rtm/javatmapi/core/datatype_aware.rb', line 33

def value=(args)
  if args.is_a?(Array)
    raise("value=(value) or value=(value,datatype)") unless args.size == 2
    datatype = topic_map.create_locator(args.last)
    value = args.first.to_s
    if datatype.reference == RTM::PSI[:IRI]
      setValue(topic_map.create_locator(value))
    else
      setValue(value, datatype)
    end
  else
    setValue(args)
  end
end