Class: Saxon::ItemType
- Inherits:
-
Object
- Object
- Saxon::ItemType
- Defined in:
- lib/saxon/item_type.rb
Overview
Represent XDM types abstractly
Defined Under Namespace
Classes: Factory, UnmappedRubyTypeError, UnmappedXSDTypeNameError
Constant Summary collapse
- TYPE_MAPPING =
A mapping of Ruby types to XDM type constants
{ 'String' => :STRING, 'Array' => :ANY_ARRAY, 'Hash' => :ANY_MAP, 'TrueClass' => :BOOLEAN, 'FalseClass' => :BOOLEAN, 'Date' => :DATE, 'DateTime' => :DATE_TIME, 'Time' => :DATE_TIME, 'BigDecimal' => :DECIMAL, 'Integer' => :INTEGER, 'Float' => :FLOAT, 'Numeric' => :NUMERIC }.freeze
- STR_MAPPING =
A mapping of type names/QNames to XDM type constants
{ 'array(*)' => :ANY_ARRAY, 'xs:anyAtomicType' => :ANY_ATOMIC_VALUE, 'item()' => :ANY_ITEM, 'map(*)' => :ANY_MAP, 'node()' => :ANY_NODE, 'xs:anyURI' => :ANY_URI, 'xs:base64Binary' => :BASE64_BINARY, 'xs:boolean' => :BOOLEAN, 'xs:byte' => :BYTE, 'xs:date' => :DATE, 'xs:dateTime' => :DATE_TIME, 'xs:dateTimeStamp' => :DATE_TIME_STAMP, 'xs:dayTimeDuration' => :DAY_TIME_DURATION, 'xs:decimal' => :DECIMAL, 'xs:double' => :DOUBLE, 'xs:duration' => :DURATION, 'xs:ENTITY' => :ENTITY, 'xs:float' => :FLOAT, 'xs:gDay' => :G_DAY, 'xs:gMonth' => :G_MONTH, 'xs:gMonthDay' => :G_MONTH_DAY, 'xs:gYear' => :G_YEAR, 'xs:gYearMonth' => :G_YEAR_MONTH, 'xs:hexBinary' => :HEX_BINARY, 'xs:ID' => :ID, 'xs:IDREF' => :IDREF, 'xs:int' => :INT, 'xs:integer' => :INTEGER, 'xs:language' => :LANGUAGE, 'xs:long' => :LONG, 'xs:Name' => :NAME, 'xs:NCName' => :NCNAME, 'xs:negativeInteger' => :NEGATIVE_INTEGER, 'xs:NMTOKEN' => :NMTOKEN, 'xs:nonNegativeInteger' => :NON_NEGATIVE_INTEGER, 'xs:nonPositiveInteger' => :NON_POSITIVE_INTEGER, 'xs:normalizedString' => :NORMALIZED_STRING, 'xs:NOTATION' => :NOTATION, 'xs:numeric' => :NUMERIC, 'xs:positiveInteger' => :POSITIVE_INTEGER, 'xs:QName' => :QNAME, 'xs:short' => :SHORT, 'xs:string' => :STRING, 'xs:time' => :TIME, 'xs:token' => :TOKEN, 'xs:unsignedByte' => :UNSIGNED_BYTE, 'xs:unsignedInt' => :UNSIGNED_INT, 'xs:unsignedLong' => :UNSIGNED_LONG, 'xs:unsignedShort' => :UNSIGNED_SHORT, 'xs:untypedAtomic' => :UNTYPED_ATOMIC, 'xs:yearMonthDuration' => :YEAR_MONTH_DURATION }.freeze
Class Method Summary collapse
-
.get_type(arg) ⇒ Saxon::ItemType
Get an appropriate ItemType for a Ruby type or given a type name as a string.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
compares two ItemTypes using the underlying Saxon and XDM comparision rules.
- #hash ⇒ Object
-
#initialize(s9_item_type) ⇒ ItemType
constructor
private
A new instance of ItemType.
-
#to_java ⇒ Saxon::S9API::ItemType
The underlying Saxon Java ItemType object.
-
#type_name ⇒ Saxon::QName
Return the QName which represents this type.
Constructor Details
#initialize(s9_item_type) ⇒ ItemType
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ItemType.
128 129 130 |
# File 'lib/saxon/item_type.rb', line 128 def initialize(s9_item_type) @s9_item_type = s9_item_type end |
Class Method Details
.get_type(ruby_class) ⇒ Saxon::ItemType .get_type(type_name) ⇒ Saxon::ItemType
Get an appropriate Saxon::ItemType for a Ruby type or given a type name as a string
88 89 90 |
# File 'lib/saxon/item_type.rb', line 88 def get_type(arg) new(get_s9_type(arg)) end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
compares two Saxon::ItemTypes using the underlying Saxon and XDM comparision rules
147 148 149 150 |
# File 'lib/saxon/item_type.rb', line 147 def ==(other) return false unless other.is_a?(ItemType) s9_item_type.equals(other.to_java) end |
#hash ⇒ Object
154 155 156 |
# File 'lib/saxon/item_type.rb', line 154 def hash @hash ||= s9_item_type.hashCode end |
#to_java ⇒ Saxon::S9API::ItemType
140 141 142 |
# File 'lib/saxon/item_type.rb', line 140 def to_java s9_item_type end |
#type_name ⇒ Saxon::QName
Return the QName which represents this type
135 136 137 |
# File 'lib/saxon/item_type.rb', line 135 def type_name @type_name ||= Saxon::QName.new(s9_item_type.getTypeName) end |