Package omero.util
Class IceMapper
- java.lang.Object
-
- ome.util.ContextFilter
-
- ome.util.ModelMapper
-
- omero.util.IceMapper
-
- All Implemented Interfaces:
ome.util.Filter,ome.util.ReverseModelMapper
- Direct Known Subclasses:
RoiI.RoiResultMapper,RTypeMapper
public class IceMapper extends ome.util.ModelMapper implements ome.util.ReverseModelMapperResponsible for the mapping of ome.* types to omero.* types and back again. Not all types are bidirectional, rather only those mappings are needed that actually appear in the blitz API. As of Beta3.1, anIceMapperinstance can also be configured to handle return value mapping, though by default an exception will be thrown ifmapReturnValue(Object)is called.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceIceMapper.ReturnMapping
-
Field Summary
Fields Modifier and Type Field Description static IceMapper.ReturnMappingFILTERABLEstatic IceMapper.ReturnMappingFILTERABLE_ARRAYstatic IceMapper.ReturnMappingFILTERABLE_COLLECTIONstatic IceMapper.ReturnMappingFILTERABLE_PRIMITIVE_MAPstatic IceMapper.ReturnMappingLISTOBJECTARRAY_TO_RTYPESEQSEQstatic IceMapper.ReturnMappingOBJECT_TO_RTYPEstatic IceMapper.ReturnMappingOBJECTARRAY_TO_RTYPESEQstatic IceMapper.ReturnMappingPRIMITIVEstatic IceMapper.ReturnMappingPRIMITIVE_FILTERABLE_COLLECTION_MAPstatic IceMapper.ReturnMappingPRIMITIVE_MAPstatic IceMapper.ReturnMappingRTYPEDICTstatic IceMapper.ReturnMappingSTRING_TO_RSTRINGprotected java.util.Map<java.lang.Object,java.lang.Object>target2modelstatic IceMapper.ReturnMappingUNMAPPEDSpecifies a return type which should not be parsed.static IceMapper.ReturnMappingVOID
-
Constructor Summary
Constructors Constructor Description IceMapper()IceMapper(IceMapper.ReturnMapping mapping)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Mapc2c()booleancanMapReturnValue()True if this instance has aIceMapper.ReturnMappingome.parameters.QueryParameterconvert(java.lang.String key, java.lang.Object o)static RTimeconvert(java.util.Date date)static Permissionsconvert(ome.model.internal.Permissions p)static EventContextconvert(ome.system.EventContext ctx)static Rolesconvert(ome.system.Roles roles)static RGBBufferconvert(omeis.providers.re.RGBBuffer buffer)static ome.model.internal.Permissionsconvert(Permissions p)omeis.providers.re.codomain.CodomainMapContextconvert(CodomainMapContext ctx)Converts the passed Ice Object and returns the converted object.static omeis.providers.re.data.PlaneDefconvert(PlaneDef def)Converts the passed Ice Object and returns the converted object.static java.sql.Timestampconvert(RTime time)static ome.parameters.Filterconvert(Filter f)static ome.parameters.Optionsconvert(Options o)ome.parameters.Parametersconvert(Parameters params)static ome.system.Principalconvert(Principal old)static java.util.List<NamedValue>convertMapPairs(java.util.List<ome.xml.model.MapPair> map)static java.util.List<NamedValue>convertNamedValueList(java.util.List<ome.model.internal.NamedValue> map)static java.util.Map<java.lang.String,RString>convertStringStringMap(java.util.Map<java.lang.String,java.lang.String> map)Convert a String→String map's values toRStrings.static ServerErrorfillServerError(ServerError se, java.lang.Throwable t)ome.util.Filterablefilter(java.lang.String fieldId, ome.util.Filterable source)java.util.CollectionfindCollection(java.util.Collection source)Overrides the findCollection logic ofModelMapper, since allCollections should beLists in Ice.java.lang.ObjectfromRType(RType rt)Uses the omero.rtypes hierarchy to properly convert anyRTypeto its internal representation.Ice.UserExceptionhandleException(java.lang.Throwable t, ome.system.OmeroContext ctx)java.lang.ObjecthandleInput(java.lang.Class<?> p, java.lang.Object arg)java.lang.ObjecthandleOutput(java.lang.Class type, java.lang.Object o)ServerErrorhandleServerError(java.lang.Throwable t, ome.system.OmeroContext ctx)wraps any non-ServerError returned byhandleException(Throwable, OmeroContext)in anInternalException.protected booleanhasntSeen(java.lang.Object o)booleanisImmutable(java.lang.Object obj)protected static booleanisNullablePrimitive(java.lang.Class<?> p)protected booleanisPrimitive(java.lang.Class<?> p)booleanisVoid()Returns true only if the current mapping is theVOIDmapping.protected static booleanisWrapperArray(java.lang.Class<?> p)java.util.Listmap(ome.util.Filterable[] array)java.lang.ObjectmapReturnValue(java.lang.Object value)Convert the given Object via the setIceMapper.ReturnMapping.static java.lang.Class<? extends ome.model.IObject>omeroClass(java.lang.String className, boolean strict)java.lang.Objectreverse(java.lang.Object source)java.util.Collectionreverse(java.util.Collection source)Copied fromModelMapper.findCollection(Collection)This could be unified in that a method findCollection(Collection, Map) was added withModelMappercallingfindCollection(source, model2target)andreverseCollection(Collection)callingfindCollection(source,target2model).java.util.Collectionreverse(java.util.Collection source, java.lang.Class targetType)Creates a collection assignable to the given type.java.util.Mapreverse(java.util.Map map)ome.util.Filterablereverse(ome.model.ModelBased source)Copied fromReverseModelMapper.java.lang.Object[]reverseArray(java.util.List list, java.lang.Class type)Supports the separate case of reversing for arrays.static java.util.List<ome.model.internal.NamedValue>reverseNamedList(java.util.List<NamedValue> map)static java.util.Map<java.lang.String,java.lang.String>reverseStringStringMap(java.util.Map<java.lang.String,RString> rMap)Reverse a String→String map's values fromRStrings.voidstore(java.lang.Object source, java.lang.Object target)RTypetoRType(java.lang.Object o)-
Methods inherited from class ome.util.ModelMapper
event2timestamp, filter, filter, findClass, findCollectionTarget, findKeyTarget, findMap, findTarget, map, map, map, nullSafeDouble, nullSafeFloat, nullSafeInt, nullSafeLong, stackAsString
-
-
-
-
Field Detail
-
VOID
public static final IceMapper.ReturnMapping VOID
-
FILTERABLE
public static final IceMapper.ReturnMapping FILTERABLE
-
FILTERABLE_ARRAY
public static final IceMapper.ReturnMapping FILTERABLE_ARRAY
-
FILTERABLE_COLLECTION
public static final IceMapper.ReturnMapping FILTERABLE_COLLECTION
-
OBJECTARRAY_TO_RTYPESEQ
public static final IceMapper.ReturnMapping OBJECTARRAY_TO_RTYPESEQ
-
LISTOBJECTARRAY_TO_RTYPESEQSEQ
public static final IceMapper.ReturnMapping LISTOBJECTARRAY_TO_RTYPESEQSEQ
-
OBJECT_TO_RTYPE
public static final IceMapper.ReturnMapping OBJECT_TO_RTYPE
-
STRING_TO_RSTRING
public static final IceMapper.ReturnMapping STRING_TO_RSTRING
-
UNMAPPED
public static final IceMapper.ReturnMapping UNMAPPED
Specifies a return type which should not be parsed. This should only be used for objects unknown to the Mapper, and should not be used for any types which contain by transitivity any ome.model.* types!
-
PRIMITIVE
public static final IceMapper.ReturnMapping PRIMITIVE
-
PRIMITIVE_MAP
public static final IceMapper.ReturnMapping PRIMITIVE_MAP
-
FILTERABLE_PRIMITIVE_MAP
public static final IceMapper.ReturnMapping FILTERABLE_PRIMITIVE_MAP
-
PRIMITIVE_FILTERABLE_COLLECTION_MAP
public static final IceMapper.ReturnMapping PRIMITIVE_FILTERABLE_COLLECTION_MAP
-
RTYPEDICT
public static final IceMapper.ReturnMapping RTYPEDICT
-
target2model
protected java.util.Map<java.lang.Object,java.lang.Object> target2model
-
-
Constructor Detail
-
IceMapper
public IceMapper()
-
IceMapper
public IceMapper(IceMapper.ReturnMapping mapping)
-
-
Method Detail
-
isVoid
public boolean isVoid()
Returns true only if the current mapping is theVOIDmapping.
-
canMapReturnValue
public boolean canMapReturnValue()
True if this instance has aIceMapper.ReturnMapping
-
mapReturnValue
public java.lang.Object mapReturnValue(java.lang.Object value) throws Ice.UserExceptionConvert the given Object via the setIceMapper.ReturnMapping. Throws aNullPointerExceptionif no mapping is set.- Throws:
Ice.UserException
-
fillServerError
public static ServerError fillServerError(ServerError se, java.lang.Throwable t)
-
omeroClass
public static java.lang.Class<? extends ome.model.IObject> omeroClass(java.lang.String className, boolean strict) throws ApiUsageException- Throws:
ApiUsageException
-
toRType
public RType toRType(java.lang.Object o) throws ApiUsageException
- Throws:
ApiUsageException
-
fromRType
public java.lang.Object fromRType(RType rt) throws ApiUsageException
Uses the omero.rtypes hierarchy to properly convert anyRTypeto its internal representation. This requires that the instance properly implementrtypes.Conversionotherwise ApiUsageException will be thrown.- Parameters:
rt- the wrapped value- Returns:
- the value unwrapped
- Throws:
ApiUsageException- if the given value is not wrapped
-
convert
public static EventContext convert(ome.system.EventContext ctx)
-
convert
public static RGBBuffer convert(omeis.providers.re.RGBBuffer buffer)
-
convert
public omeis.providers.re.codomain.CodomainMapContext convert(CodomainMapContext ctx)
Converts the passed Ice Object and returns the converted object.- Parameters:
ctx- The object to convert- Returns:
- See above.
- Throws:
ApiUsageException- Thrown if the slice is unknown.
-
convert
public static omeis.providers.re.data.PlaneDef convert(PlaneDef def) throws ApiUsageException
Converts the passed Ice Object and returns the converted object.- Parameters:
def- The object to convert- Returns:
- See above.
- Throws:
ApiUsageException- Thrown if the slice is unknown.
-
convert
public static ome.system.Principal convert(Principal old)
-
convert
public static Roles convert(ome.system.Roles roles)
-
convert
public static RTime convert(java.util.Date date)
-
convert
public static java.sql.Timestamp convert(RTime time)
-
convert
public ome.parameters.Parameters convert(Parameters params) throws ApiUsageException
- Throws:
ApiUsageException
-
convert
public ome.parameters.QueryParameter convert(java.lang.String key, java.lang.Object o) throws ApiUsageException- Throws:
ApiUsageException
-
convert
public static ome.parameters.Options convert(Options o)
-
convert
public static ome.parameters.Filter convert(Filter f)
-
convertNamedValueList
public static java.util.List<NamedValue> convertNamedValueList(java.util.List<ome.model.internal.NamedValue> map)
-
convertMapPairs
public static java.util.List<NamedValue> convertMapPairs(java.util.List<ome.xml.model.MapPair> map)
-
convertStringStringMap
public static java.util.Map<java.lang.String,RString> convertStringStringMap(java.util.Map<java.lang.String,java.lang.String> map)
Convert a String→String map's values toRStrings.nullvalues are dropped completely.- Parameters:
map- a map- Returns:
- the converted map, or
nullifmap == null
-
findCollection
public java.util.Collection findCollection(java.util.Collection source)
Overrides the findCollection logic ofModelMapper, since allCollections should beLists in Ice.- Overrides:
findCollectionin classome.util.ModelMapper
-
map
public java.util.List map(ome.util.Filterable[] array)
-
convert
public static Permissions convert(ome.model.internal.Permissions p)
-
convert
public static ome.model.internal.Permissions convert(Permissions p)
-
isImmutable
public boolean isImmutable(java.lang.Object obj)
-
reverse
public java.lang.Object reverse(java.lang.Object source) throws ApiUsageException- Throws:
ApiUsageException
-
reverse
public java.util.Collection reverse(java.util.Collection source)
Copied fromModelMapper.findCollection(Collection)This could be unified in that a method findCollection(Collection, Map) was added withModelMappercallingfindCollection(source, model2target)andreverseCollection(Collection)callingfindCollection(source,target2model).- Specified by:
reversein interfaceome.util.ReverseModelMapper- Parameters:
source- the wrappedCollection- Returns:
- the
Collectionunwrapped
-
reverse
public java.util.Collection reverse(java.util.Collection source, java.lang.Class targetType)Creates a collection assignable to the given type. Currently onlySetandListare supported, andHashSets andArrayLists will be returned. The need for this arose from the decision to have noSets in the Ice Java mapping.- See Also:
- Trac ticket #684
-
reverseArray
public java.lang.Object[] reverseArray(java.util.List list, java.lang.Class type) throws ServerErrorSupports the separate case of reversing for arrays. Seereverse(Collection, Class)andmap(Filterable[]).- Throws:
ServerError
-
reverse
public java.util.Map reverse(java.util.Map map)
-
reverse
public ome.util.Filterable reverse(ome.model.ModelBased source)
Copied fromReverseModelMapper.- Specified by:
reversein interfaceome.util.ReverseModelMapper
-
reverseStringStringMap
public static java.util.Map<java.lang.String,java.lang.String> reverseStringStringMap(java.util.Map<java.lang.String,RString> rMap)
Reverse a String→String map's values fromRStrings.nullvalues are dropped completely.- Parameters:
rMap- a map- Returns:
- the reversed map, or
nullifrMap == null
-
reverseNamedList
public static java.util.List<ome.model.internal.NamedValue> reverseNamedList(java.util.List<NamedValue> map)
-
store
public void store(java.lang.Object source, java.lang.Object target)
-
c2c
protected java.util.Map c2c()
- Specified by:
c2cin classome.util.ModelMapper
-
filter
public ome.util.Filterable filter(java.lang.String fieldId, ome.util.Filterable source)- Specified by:
filterin interfaceome.util.Filter- Overrides:
filterin classome.util.ModelMapper
-
hasntSeen
protected boolean hasntSeen(java.lang.Object o)
- Overrides:
hasntSeenin classome.util.ContextFilter
-
isPrimitive
protected boolean isPrimitive(java.lang.Class<?> p)
-
isNullablePrimitive
protected static boolean isNullablePrimitive(java.lang.Class<?> p)
-
isWrapperArray
protected static boolean isWrapperArray(java.lang.Class<?> p)
-
handleInput
public java.lang.Object handleInput(java.lang.Class<?> p, java.lang.Object arg) throws ServerError- Throws:
ServerError
-
handleOutput
public java.lang.Object handleOutput(java.lang.Class type, java.lang.Object o) throws ServerError- Throws:
ServerError
-
handleServerError
public ServerError handleServerError(java.lang.Throwable t, ome.system.OmeroContext ctx)
wraps any non-ServerError returned byhandleException(Throwable, OmeroContext)in anInternalException.
-
handleException
public Ice.UserException handleException(java.lang.Throwable t, ome.system.OmeroContext ctx)
-
-