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.ReverseModelMapper
Responsible 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, anIceMapper
instance 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 interface
IceMapper.ReturnMapping
-
Field Summary
Fields Modifier and Type Field Description static IceMapper.ReturnMapping
FILTERABLE
static IceMapper.ReturnMapping
FILTERABLE_ARRAY
static IceMapper.ReturnMapping
FILTERABLE_COLLECTION
static IceMapper.ReturnMapping
FILTERABLE_PRIMITIVE_MAP
static IceMapper.ReturnMapping
LISTOBJECTARRAY_TO_RTYPESEQSEQ
static IceMapper.ReturnMapping
OBJECT_TO_RTYPE
static IceMapper.ReturnMapping
OBJECTARRAY_TO_RTYPESEQ
static IceMapper.ReturnMapping
PRIMITIVE
static IceMapper.ReturnMapping
PRIMITIVE_FILTERABLE_COLLECTION_MAP
static IceMapper.ReturnMapping
PRIMITIVE_MAP
static IceMapper.ReturnMapping
RTYPEDICT
static IceMapper.ReturnMapping
STRING_TO_RSTRING
protected java.util.Map<java.lang.Object,java.lang.Object>
target2model
static IceMapper.ReturnMapping
UNMAPPED
Specifies a return type which should not be parsed.static IceMapper.ReturnMapping
VOID
-
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.Map
c2c()
boolean
canMapReturnValue()
True if this instance has aIceMapper.ReturnMapping
ome.parameters.QueryParameter
convert(java.lang.String key, java.lang.Object o)
static RTime
convert(java.util.Date date)
static Permissions
convert(ome.model.internal.Permissions p)
static EventContext
convert(ome.system.EventContext ctx)
static Roles
convert(ome.system.Roles roles)
static RGBBuffer
convert(omeis.providers.re.RGBBuffer buffer)
static ome.model.internal.Permissions
convert(Permissions p)
omeis.providers.re.codomain.CodomainMapContext
convert(CodomainMapContext ctx)
Converts the passed Ice Object and returns the converted object.static omeis.providers.re.data.PlaneDef
convert(PlaneDef def)
Converts the passed Ice Object and returns the converted object.static java.sql.Timestamp
convert(RTime time)
static ome.parameters.Filter
convert(Filter f)
static ome.parameters.Options
convert(Options o)
ome.parameters.Parameters
convert(Parameters params)
static ome.system.Principal
convert(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 toRString
s.static ServerError
fillServerError(ServerError se, java.lang.Throwable t)
ome.util.Filterable
filter(java.lang.String fieldId, ome.util.Filterable source)
java.util.Collection
findCollection(java.util.Collection source)
Overrides the findCollection logic ofModelMapper
, since allCollection
s should beList
s in Ice.java.lang.Object
fromRType(RType rt)
Uses the omero.rtypes hierarchy to properly convert anyRType
to its internal representation.Ice.UserException
handleException(java.lang.Throwable t, ome.system.OmeroContext ctx)
java.lang.Object
handleInput(java.lang.Class<?> p, java.lang.Object arg)
java.lang.Object
handleOutput(java.lang.Class type, java.lang.Object o)
ServerError
handleServerError(java.lang.Throwable t, ome.system.OmeroContext ctx)
wraps any non-ServerError returned byhandleException(Throwable, OmeroContext)
in anInternalException
.protected boolean
hasntSeen(java.lang.Object o)
boolean
isImmutable(java.lang.Object obj)
protected static boolean
isNullablePrimitive(java.lang.Class<?> p)
protected boolean
isPrimitive(java.lang.Class<?> p)
boolean
isVoid()
Returns true only if the current mapping is theVOID
mapping.protected static boolean
isWrapperArray(java.lang.Class<?> p)
java.util.List
map(ome.util.Filterable[] array)
java.lang.Object
mapReturnValue(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.Object
reverse(java.lang.Object source)
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 withModelMapper
callingfindCollection(source, model2target)
andreverseCollection(Collection)
callingfindCollection(source,target2model)
.java.util.Collection
reverse(java.util.Collection source, java.lang.Class targetType)
Creates a collection assignable to the given type.java.util.Map
reverse(java.util.Map map)
ome.util.Filterable
reverse(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 fromRString
s.void
store(java.lang.Object source, java.lang.Object target)
RType
toRType(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 theVOID
mapping.
-
canMapReturnValue
public boolean canMapReturnValue()
True if this instance has aIceMapper.ReturnMapping
-
mapReturnValue
public java.lang.Object mapReturnValue(java.lang.Object value) throws Ice.UserException
Convert the given Object via the setIceMapper.ReturnMapping
. Throws aNullPointerException
if 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 anyRType
to its internal representation. This requires that the instance properly implementrtypes.Conversion
otherwise 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 toRString
s.null
values are dropped completely.- Parameters:
map
- a map- Returns:
- the converted map, or
null
ifmap == null
-
findCollection
public java.util.Collection findCollection(java.util.Collection source)
Overrides the findCollection logic ofModelMapper
, since allCollection
s should beList
s in Ice.- Overrides:
findCollection
in 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 withModelMapper
callingfindCollection(source, model2target)
andreverseCollection(Collection)
callingfindCollection(source,target2model)
.- Specified by:
reverse
in interfaceome.util.ReverseModelMapper
- Parameters:
source
- the wrappedCollection
- Returns:
- the
Collection
unwrapped
-
reverse
public java.util.Collection reverse(java.util.Collection source, java.lang.Class targetType)
Creates a collection assignable to the given type. Currently onlySet
andList
are supported, andHashSet
s andArrayList
s will be returned. The need for this arose from the decision to have noSet
s 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 ServerError
Supports 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:
reverse
in 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 fromRString
s.null
values are dropped completely.- Parameters:
rMap
- a map- Returns:
- the reversed map, or
null
ifrMap == 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:
c2c
in classome.util.ModelMapper
-
filter
public ome.util.Filterable filter(java.lang.String fieldId, ome.util.Filterable source)
- Specified by:
filter
in interfaceome.util.Filter
- Overrides:
filter
in classome.util.ModelMapper
-
hasntSeen
protected boolean hasntSeen(java.lang.Object o)
- Overrides:
hasntSeen
in 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)
-
-