Sha256: 4977f64be3ee2ba03ab018196ab12f4e1acafa267cadb727e5b4cb1156c5047c

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

require_relative '../sequence_type'

module Saxon
  module XPath
    # Represents an XPath variable declaration in the static context of a
    # compiled XPath, providing an idiomatic Ruby way to deal with these.
    class VariableDeclaration
      # @return [Saxon::QName]
      attr_reader :qname
      # @return [Saxon::SequenceType]
      attr_reader :sequence_type

      # @param qname [Saxon::QName] the name of the variable
      # @param sequence_type [Saxon::SequenceType] the SequenceType of the
      #   variable
      def initialize(qname, sequence_type)
        @qname = qname
        @sequence_type = sequence_type || Saxon.SequenceType('item()*')
      end

      # VariableDeclarations compare equal if their qname and sequence_type are equal
      # @param other [Saxon::VariableDeclaration]
      # @return [Boolean]
      def ==(other)
        VariableDeclaration === other && qname == other.qname && sequence_type == other.sequence_type
      end

      # @api private
      # return the arguments XPathCompiler.declareVariable expects
      def compiler_args
        [qname.to_java, sequence_type.item_type.to_java, sequence_type.occurrence_indicator.to_java]
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
saxon-rb-0.8.3-java lib/saxon/xpath/variable_declaration.rb
saxon-rb-0.8.2-java lib/saxon/xpath/variable_declaration.rb
saxon-rb-0.8.1-java lib/saxon/xpath/variable_declaration.rb
saxon-rb-0.8.0-java lib/saxon/xpath/variable_declaration.rb
saxon-rb-0.7.3-java lib/saxon/xpath/variable_declaration.rb
saxon-rb-0.7.2-java lib/saxon/xpath/variable_declaration.rb
saxon-rb-0.7.1-java lib/saxon/xpath/variable_declaration.rb
saxon-rb-0.7.0-java lib/saxon/xpath/variable_declaration.rb
saxon-rb-0.6.0-java lib/saxon/xpath/variable_declaration.rb
saxon-rb-0.5.0-java lib/saxon/xpath/variable_declaration.rb