Class: R2CORBA::CORBA::TypeCode::Sequence
- Inherits:
-
R2CORBA::CORBA::TypeCode
- Object
- R2CORBA::CORBA::TypeCode
- R2CORBA::CORBA::TypeCode::Sequence
- Defined in:
- lib/corba/cbase/Typecode.rb,
lib/corba/jbase/Typecode.rb,
lib/corba/common/Typecode.rb
Overview
Fixed
Constant Summary
Constants inherited from R2CORBA::CORBA::TypeCode
LongLongRange, LongRange, OctetRange, ShortRange, ULongLongRange, ULongRange, UShortRange
Instance Attribute Summary
Attributes inherited from R2CORBA::CORBA::TypeCode
Instance Method Summary collapse
- #get_type ⇒ Object
-
#initialize(*args) ⇒ Sequence
constructor
A new instance of Sequence.
- #inspect ⇒ Object
- #needs_conversion(val) ⇒ Object
- #validate(val) ⇒ Object
Methods inherited from R2CORBA::CORBA::TypeCode
_tc, _wrap_native, #concrete_base_type, #content_type, #default_index, #discriminator_type, #equal?, #equivalent?, #fixed_digits, #fixed_scale, from_native, #get_compact_typecode, get_primitive_tc, #id, #is_recursive_tc?, #kind, #length, #member_count, #member_label, #member_name, #member_type, #member_visibility, #name, native_kind, register_id_type, #resolved_tc, #type_modifier, typecode_for_id, typecodes_for_name
Constructor Details
#initialize(*args) ⇒ Sequence
Returns a new instance of Sequence.
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/corba/cbase/Typecode.rb', line 97 def initialize(*args) if CORBA::Native::TypeCode === args.first @tc_ = args.first else element_tc, bound = args raise ArgumentError, 'expected CORBA::TypeCode' unless element_tc.is_a?(CORBA::TypeCode) begin @tc_ = CORBA::Native::TypeCode.create_tc(TK_SEQUENCE, bound.to_i, element_tc.tc_) rescue ::NativeException CORBA::Exception.native2r($!) end end end |
Instance Method Details
#get_type ⇒ Object
518 519 520 |
# File 'lib/corba/common/Typecode.rb', line 518 def get_type self.content_type.kind == TK_OCTET || self.content_type.kind == TK_CHAR ? ::String : ::Array end |
#inspect ⇒ Object
562 563 564 565 566 |
# File 'lib/corba/common/Typecode.rb', line 562 def inspect "#{self.class.name}: "+ "length=#{if self.length.nil? then ""; else self.length.to_s; end}; "+ "content=#{self.content_type.inspect}" end |
#needs_conversion(val) ⇒ Object
554 555 556 557 558 559 560 |
# File 'lib/corba/common/Typecode.rb', line 554 def needs_conversion(val) if self.content_type.kind == TK_OCTET || self.content_type.kind == TK_CHAR !(::String === val) else !(::Array === val) ? true : val.any? { |el| self.content_type.needs_conversion(el) } end end |
#validate(val) ⇒ Object
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
# File 'lib/corba/common/Typecode.rb', line 522 def validate(val) return val if val.nil? super(val) unless val.respond_to?(:to_str) || val.respond_to?(:to_ary) val = if self.content_type.kind == TK_OCTET || self.content_type.kind == TK_CHAR if val.respond_to?(:to_str) ::String === val ? val : val.to_str else s = '' val.to_ary.each { |e| s << (e.respond_to?(:to_int) ? e.to_int.chr : e.to_str) } s end elsif val.respond_to?(:to_ary) ::Array === val ? val : val.to_ary else a = [] val.to_str.each_byte { |c| a << c } a end raise ::CORBA::MARSHAL.new( "sequence size exceeds bound: #{self.length.to_s}", 1, ::CORBA::COMPLETED_NO) unless (self.length==0 || val.size<=self.length) if ::Array === val if val.any? { |e| self.content_type.needs_conversion(e) } val.collect { |e| self.content_type.validate(e) } else val.each { |e| self.content_type.validate(e) } end else val end end |