Package org.apache.sis.internal.jaxb
Class TypeRegistration
java.lang.Object
org.apache.sis.internal.jaxb.TypeRegistration
- Direct Known Subclasses:
MetadataTypes,ProfileTypes,ReferencingTypes
Declares the classes of objects to be marshalled using a default
MarshallerPool.
This class is not strictly necessary for marshalling a SIS object using JAXB, but makes
the job easier by allowing MarshallerPool to configure the JAXB context automatically.
To allow such automatic configuration, modules must declare instances of this interface in the
following file:
- Since:
- 0.3
- Version:
- 1.0
- Author:
- Martin Desruisseaux (Geomatys)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringUndocumented (for now) marshaller property for specifying conversions to apply on root objects before marshalling. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected UnaryOperator<Object> If some objects need to be converted before marshalling, the converter for performing those conversions.getPrivateInfo(Map<String, ?> properties) Completes the given properties with an entry forROOT_ADAPTERSif not already present.static voidgetRenameFileLoader(boolean export, Set<Class<?>> addTo) Adds in the given set the classes to use for loading"RenameOnImport.lst"and/or"RenameOnExport.lst"files.static JAXBContextReturns the sharedJAXBContextfor the set of classes returned byload(boolean).protected abstract voidgetTypes(Collection<Class<?>> addTo) Adds to the given collection every types that should be given to the initial JAXB context.protected booleanhasRenameFile(boolean export) Returnstrueif"RenameOnImport.lst"and/or"RenameOnExport.lst"files are provided.
-
Field Details
-
ROOT_ADAPTERS
Undocumented (for now) marshaller property for specifying conversions to apply on root objects before marshalling. Conversions are applied byUnaryOperatorinstances.- See Also:
-
-
Constructor Details
-
TypeRegistration
protected TypeRegistration()For subclasses constructors.
-
-
Method Details
-
getTypes
Adds to the given collection every types that should be given to the initial JAXB context. The types added by this method include only implementation classes having JAXB annotations. If the module can also marshal arbitrary implementations of some interfaces (e.g. GeoAPI), then thebeforeMarshal()method should be overridden.- Parameters:
addTo- the collection in which to add new types.
-
beforeMarshal
If some objects need to be converted before marshalling, the converter for performing those conversions. The converterapply(Object)method may returnnullif the value class is not recognized, orvalueif the class is recognized but the value does not need to be changed. Implementations will typically perform aninstanceofcheck, then invoke one of thecastOrCopy(…)static methods defined in various Apache SIS classes.- Returns:
- converter for the value to marshal, or
nullif there are no values to convert. - Since:
- 0.8
-
hasRenameFile
protected boolean hasRenameFile(boolean export) Returnstrueif"RenameOnImport.lst"and/or"RenameOnExport.lst"files are provided. Iftrue, then those files shall be located in the same directory than thisTypeRegistrationsubclass.- Parameters:
export-truefor"RenameOnImport.lst",falsefor"RenameOnImport.lst".- Returns:
- whether
"RenameOnImport.lst"and/or"RenameOnExport.lst"files are provided.
-
getRenameFileLoader
Adds in the given set the classes to use for loading"RenameOnImport.lst"and/or"RenameOnExport.lst"files. The given set should preserve insertion order, since the order in which files are loaded may matter.- Parameters:
export-truefor"RenameOnImport.lst",falsefor"RenameOnImport.lst".addTo- where to add the classes to use for loading the resource files.
-
getPrivateInfo
Completes the given properties with an entry forROOT_ADAPTERSif not already present. If aROOT_ADAPTERSentry is already present, then the map is returned unchanged.This method stores a reference to the internal
TypeRegistration[]array in a copy of the given map. That array shall not be modified. This method is currently for Apache SIS internal usage only, because theTypeRegistrationclass is not part of public API. However if we add this functionality in a future SIS release (probably as an interface rather than exposingTypeRegistrationitself), then we may consider removing this method.- Parameters:
properties- the properties to complete.- Returns:
- the given properties with the
ROOT_ADAPTERSentry added. - Since:
- 0.8
-