Class: StixRuby::Marshall::StixNamespaceMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_stix/marshall.rb

Instance Method Summary collapse

Constructor Details

#initialize(mappings = {}) ⇒ StixNamespaceMapper

Returns a new instance of StixNamespaceMapper.



147
148
149
150
# File 'lib/ruby_stix/marshall.rb', line 147

def initialize(mappings = {})
  super()
  @mappings = mappings
end

Instance Method Details

#getPreDeclaredNamespaceUrisObject



164
165
166
# File 'lib/ruby_stix/marshall.rb', line 164

def getPreDeclaredNamespaceUris
  StixRuby::NAMESPACE_MAPPINGS.keys + [StixRuby.id_namespace_uri, ''].compact + @mappings.keys
end

#getPreferredPrefix(uri, suggestion, require_prefix) ⇒ Object



152
153
154
155
156
157
158
159
160
161
162
# File 'lib/ruby_stix/marshall.rb', line 152

def getPreferredPrefix(uri, suggestion, require_prefix)
  if @mappings[uri]
    @mappings[uri]
  elsif uri == StixRuby.id_namespace_uri
    return StixRuby.id_namespace_prefix
  elsif StixRuby::NAMESPACE_MAPPINGS[uri]
    return StixRuby::NAMESPACE_MAPPINGS[uri]
  else
    return suggestion
  end
end