Package org.apache.sis.util.iso
Class DefaultRecordSchema
- Object
-
- DefaultRecordSchema
-
- All Implemented Interfaces:
RecordSchema
public class DefaultRecordSchema extends Object implements RecordSchema
A collection of record types in a given namespace. This class works also as a factory for creatingRecordTypeandRecordinstances. The factory methods are: Subclasses can modify the characteristics of the records to be created by overriding the following methods:DefaultNameFactory.toTypeName(Class)if the factory given to the constructor.
Thread safetyThe sameDefaultRecordSchemainstance can be safely used by many threads without synchronization on the part of the caller if theNameFactorygiven to the constructor is also thread-safe. Subclasses should make sure that any overridden methods remain safe to call from multiple threads.LimitationsThis class is currently not serializable becauseRecordSchemacontain an arbitrary amount of record types in its description map. Since eachRecordTypehas a reference to its schema, serializing a singleRecordTypecould imply serializing all of them. In order to reduce the risk of unexpected behavior, serialization is currently left to subclasses. For example a subclass may define aObject readResolve()method (as documented in theSerializableinterface) returning a system-wide static constant for their schema.- Since:
- 0.5
- See Also:
DefaultRecordType,DefaultRecord
Defined in the
sis-metadatamodule
-
-
Field Summary
Fields Modifier and Type Field Description protected DefaultNameFactorynameFactoryThe factory to use for creating names.
-
Constructor Summary
Constructors Constructor Description DefaultRecordSchema(DefaultNameFactory nameFactory, NameSpace parent, CharSequence schemaName)Creates a new schema of the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RecordTypecreateRecordType(CharSequence typeName, Map<CharSequence,Class<?>> members)Creates a new record type of the given name, which will contain the given members.Map<TypeName,RecordType>getDescription()Returns the dictionary of all (name, record type) pairs in this schema.LocalNamegetSchemaName()Returns the schema name.RecordTypelocate(TypeName name)Returns the record type for the given name.StringtoString()Returns a string representation of this schema for debugging purpose only.
-
-
-
Field Detail
-
nameFactory
protected final DefaultNameFactory nameFactory
The factory to use for creating names. This is the factory given at construction time.Upcoming API change — generalization
This field type will be changed to theNameFactoryinterface when that interface will provide acreateMemberName(…)method (tentatively in GeoAPI 3.1).
-
-
Constructor Detail
-
DefaultRecordSchema
public DefaultRecordSchema(DefaultNameFactory nameFactory, NameSpace parent, CharSequence schemaName)
Creates a new schema of the given name.Upcoming API change — generalization
This type of the first argument will be changed to theNameFactoryinterface when that interface will provide acreateMemberName(…)method (tentatively in GeoAPI 3.1).- Parameters:
nameFactory- the factory to use for creating names, ornullfor the default factory.parent- the parent namespace, ornullif none.schemaName- the name of the new schema.
-
-
Method Detail
-
getSchemaName
public LocalName getSchemaName()
Returns the schema name.- Specified by:
getSchemaNamein interfaceRecordSchema- Returns:
- the schema name.
-
createRecordType
public RecordType createRecordType(CharSequence typeName, Map<CharSequence,Class<?>> members) throws IllegalArgumentException
Creates a new record type of the given name, which will contain the given members. Members are declared in iteration order.- Parameters:
typeName- the record type name.members- the name of each record member, together with the expected value types.- Returns:
- a record type of the given name and members.
- Throws:
IllegalArgumentException- if a record already exists for the given name but with different members.
-
getDescription
public Map<TypeName,RecordType> getDescription()
Returns the dictionary of all (name, record type) pairs in this schema.- Specified by:
getDescriptionin interfaceRecordSchema- Returns:
- all (name, record type) pairs in this schema.
-
locate
public RecordType locate(TypeName name)
Returns the record type for the given name. If the type name is not defined within this schema, then this method returnsnull.- Specified by:
locatein interfaceRecordSchema- Parameters:
name- the name of the type to lookup.- Returns:
- the type for the given name, or
nullif none.
-
-