org.geotoolkit.naming
Class DefaultNameFactory

Object
  extended by Factory
      extended by DefaultNameFactory
All Implemented Interfaces:
Factory, NameFactory

@ThreadSafe
public class DefaultNameFactory
extends Factory
implements NameFactory

A factory for AbstractName objects.

Since:
2.1
Version:
3.20
Author:
Martin Desruisseaux (Geomatys)
See Also:
FactoryFinder.getNameFactory(Hints)
Module:
metadata/geotk-metadata (download)    View source code for this class

Nested Class Summary
 
Nested classes/interfaces inherited from class Factory
Factory.Availability, Factory.Organizer
 
Field Summary
 
Fields inherited from class Factory
EMPTY_HINTS, hints
 
Constructor Summary
DefaultNameFactory()
          Creates a new factory.
 
Method Summary
 GenericName createGenericName(NameSpace scope, CharSequence... parsedNames)
          Creates a local or scoped name from an array of parsed names.
 InternationalString createInternationalString(Map<Locale,String> strings)
          Creates an international string from a set of strings in different locales.
 LocalName createLocalName(NameSpace scope, CharSequence name)
          Creates a local name from the given character sequence.
 MemberName createMemberName(NameSpace scope, CharSequence name, TypeName attributeType)
          Creates a member name from the given character sequence and attribute type.
 NameSpace createNameSpace(GenericName name)
          Deprecated. Replaced by createNameSpace(GenericName, Map).
 NameSpace createNameSpace(GenericName name, Map<String,?> properties)
          Creates a namespace having the given name.
 TypeName createTypeName(NameSpace scope, CharSequence name)
          Creates a type name from the given character sequence.
 Citation getVendor()
          Returns the implementor of this factory, which is GEOTOOLKIT.
 GenericName parseGenericName(NameSpace scope, CharSequence name)
          Constructs a generic name from a qualified name.
 GenericName[] toArray(Object value)
          Converts the given value to an array of generic names.
 
Methods inherited from class Factory
availability, dispose, equals, getImplementationHints, hasCompatibleHints, hashCode, setOrdering, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultNameFactory

public DefaultNameFactory()
Creates a new factory. Users should not invoke this constructor directly. Use FactoryFinder.getNameFactory(Hints) instead.

Method Detail

getVendor

public Citation getVendor()
Returns the implementor of this factory, which is GEOTOOLKIT.

Specified by:
getVendor in interface Factory
Since:
3.19

createInternationalString

public InternationalString createInternationalString(Map<Locale,String> strings)
Creates an international string from a set of strings in different locales.

Specified by:
createInternationalString in interface NameFactory

createNameSpace

public NameSpace createNameSpace(GenericName name,
                                 Map<String,?> properties)
Creates a namespace having the given name. Despite the "create" name, this method tries to returns an existing instance when possible.

This method can receive an optional map of properties. Recognized entries are:

Property name Purpose
 "separator"  The separator to insert between parsed names in that namespace. For HTTP namespace, it is ".". For URN namespace, it is typically ":".
 "separator.head"  The separator to insert between the namespace and the head. For HTTP namespace, it is "://". For URN namespace, it is typically ":". If this entry is omitted, then the default is the same value than the "separator" entry.

Specified by:
createNameSpace in interface NameFactory
Parameters:
name - The name of the namespace to be returned. This argument can be created using createGenericName(null, parsedNames).
properties - An optional map of properties to be assigned to the namespace, or null if none.
Returns:
A namespace having the given name and separator.
Since:
3.01

createNameSpace

@Deprecated
public NameSpace createNameSpace(GenericName name)
Deprecated. Replaced by createNameSpace(GenericName, Map).

Creates a namespace having the given name and using the default separator.

Parameters:
name - The name of the namespace to be returned. This argument can be created using createGenericName(null, parsedNames).
Returns:
A namespace having the given name and separator.
Since:
3.00

createTypeName

public TypeName createTypeName(NameSpace scope,
                               CharSequence name)
Creates a type name from the given character sequence. The default implementation returns a new or an existing DefaultTypeName instance.

Specified by:
createTypeName in interface NameFactory
Parameters:
scope - The scope of the type name to be created, or null for a global namespace.
name - The type name as a string or an international string.
Returns:
The type name for the given character sequence.
Throws:
NullArgumentException - If the name argument is null.
Since:
3.04

createMemberName

public MemberName createMemberName(NameSpace scope,
                                   CharSequence name,
                                   TypeName attributeType)
Creates a member name from the given character sequence and attribute type. The default implementation returns a new or an existing DefaultMemberName instance.

Specified by:
createMemberName in interface NameFactory
Parameters:
scope - The scope of the member name to be created, or null for a global namespace.
name - The member name as a string or an international string.
attributeType - The type of the data associated with the record member.
Returns:
The member name for the given character sequence.
Throws:
NullArgumentException - If the name or attributeType argument is null.
Since:
3.17

createLocalName

public LocalName createLocalName(NameSpace scope,
                                 CharSequence name)
Creates a local name from the given character sequence. The default implementation returns a new or an existing DefaultLocalName instance.

Specified by:
createLocalName in interface NameFactory
Parameters:
scope - The scope of the local name to be created, or null for a global namespace.
name - The local name as a string or an international string.
Returns:
The local name for the given character sequence.
Throws:
NullArgumentException - If the name argument is null.
Since:
3.00

createGenericName

public GenericName createGenericName(NameSpace scope,
                                     CharSequence... parsedNames)
Creates a local or scoped name from an array of parsed names. The default implementation returns an instance of DefaultLocalName if the length of the parsedNames array is 1, or an instance of DefaultScopedName if the length of the array is 2 or more.

Specified by:
createGenericName in interface NameFactory
Parameters:
scope - The scope of the generic name to be created, or null for a global namespace.
parsedNames - The local names as an array of strings or international strings. This array must contains at least one element.
Returns:
The generic name for the given parsed names.
Throws:
NullArgumentException - If the given array is empty.
Since:
3.00

parseGenericName

public GenericName parseGenericName(NameSpace scope,
                                    CharSequence name)
Constructs a generic name from a qualified name. This method splits the given name around a separator inferred from the given scope, or the default separator if the given scope is null.

Specified by:
parseGenericName in interface NameFactory
Parameters:
scope - The scope of the generic name to be created, or null for a global namespace.
name - The qualified name, as a sequence of names separated by a scope-dependent separator.
Returns:
A name parsed from the given string.

toArray

public GenericName[] toArray(Object value)
                      throws ClassCastException
Converts the given value to an array of generic names. If the given value is an instance of GenericName, String or any other type enumerated below, then it is converted and returned in an array of length 1. If the given value is an array or a collection, then an array of same length is returned where each element has been converted. Allowed types or element types are:

Parameters:
value - The object to cast into an array of generic names.
Returns:
The generic names. May be a direct reference to value.
Throws:
NullArgumentException - if value is null.
ClassCastException - if value can't be casted.


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.