public class DefaultNameFactory extends AbstractFactory implements NameFactory
AbstractName
objects.
This factory provides the following methods for creating name instances:
createTypeName(NameSpace, CharSequence)
createMemberName(NameSpace, CharSequence, TypeName)
createLocalName(NameSpace, CharSequence)
createGenericName(NameSpace, CharSequence[])
– for local or scoped namesDefaultNameFactory
instance can be safely used by many threads without synchronization
on the part of the caller. Subclasses should make sure that any overridden methods remain safe to call
from multiple threads.Names
,
DefaultNameSpace
,
DefaultScopedName
,
DefaultLocalName
,
DefaultTypeName
,
DefaultMemberName
Defined in the sis-utility
module
Constructor and Description |
---|
DefaultNameFactory()
Creates a new factory.
|
Modifier and Type | Method and Description |
---|---|
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,
Map<String,?> properties)
Returns a namespace having the given name.
|
TypeName |
createTypeName(NameSpace scope,
CharSequence name)
Creates a type name from the given character sequence.
|
GenericName |
parseGenericName(NameSpace scope,
CharSequence name)
Constructs a generic name from a qualified name.
|
GenericName[] |
toGenericNames(Object value)
Converts the given value to an array of generic names.
|
TypeName |
toTypeName(Class<?> valueClass)
Suggests a type name for the given class.
|
getVendor
public InternationalString createInternationalString(Map<Locale,String> strings)
createInternationalString
in interface NameFactory
strings
- String value for each locale key.Types.toInternationalString(CharSequence)
public NameSpace createNameSpace(GenericName name, Map<String,?> properties)
Recognized properties Property name Purpose "separator"
The separator to insert between parsed names in that namespace. "separator.head"
The separator to insert between the namespace and the head.
If omitted, then the default is the same value than"separator"
.
separator
= ":"
is typically sufficient.separator.head
= "://"
and separator
= "."
.createNameSpace
in interface NameFactory
name
- The name of the namespace to be returned. This argument can be created using
createGenericName(null, namespace)
.properties
- An optional map of properties to be assigned to the namespace, or null
if none.Names.createLocalName(CharSequence, String, CharSequence)
public TypeName createTypeName(NameSpace scope, CharSequence name)
DefaultTypeName
instance.createTypeName
in interface NameFactory
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.toTypeName(Class)
,
Names.createTypeName(CharSequence, String, CharSequence)
public MemberName createMemberName(NameSpace scope, CharSequence name, TypeName attributeType)
DefaultMemberName
instance.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.public LocalName createLocalName(NameSpace scope, CharSequence name)
DefaultLocalName
instance.createLocalName
in interface NameFactory
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.Names.createLocalName(CharSequence, String, CharSequence)
public GenericName createGenericName(NameSpace scope, CharSequence... parsedNames)
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.createGenericName
in interface NameFactory
scope
- The scope of the generic name to be created,
or null
for a global namespace.parsedNames
- The local names as an array of String
or InternationalString
instances.
This array shall contain at least one element.parseGenericName(NameSpace, CharSequence)
public GenericName parseGenericName(NameSpace scope, CharSequence name)
':'
separator if the given scope is null.parseGenericName
in interface NameFactory
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.Names.parseGenericName(CharSequence, String, CharSequence)
public GenericName[] toGenericNames(Object value) throws ClassCastException
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:
GenericName
, to be casted and returned as-is.CharSequence
(usually a String
or an InternationalString
),
to be parsed as a generic name using the ':'
separator.Identifier
, its code to be parsed as a generic name
using the ':'
separator.value
is an array or a collection containing null
elements,
then the corresponding element in the returned array will also be null
.value
- The object to cast into an array of generic names, or null
.null
if the given value
was null.
Note that it may be the value
reference itself casted to GenericName[]
.ClassCastException
- if value
can't be casted.public TypeName toTypeName(Class<?> valueClass)
Class
and TypeName
objects as documented in the DefaultTypeName
javadoc.
In order to protect against potential changes in the Class
↔ TypeName
mapping, users are
encouraged to retrieve the valueClass
by invoking the Names.toClass(TypeName)
method instead
than parsing the name.
valueClass
- The Java class for which to get a type name, or null
.null
if the given class was null.DefaultTypeName.toClass()
,
Names.toClass(TypeName)
Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.