omero.util
Class IceMapper

java.lang.Object
  extended by ome.util.ContextFilter
      extended by ome.util.ModelMapper
          extended by omero.util.IceMapper
All Implemented Interfaces:
ome.util.Filter, ome.util.ReverseModelMapper
Direct Known Subclasses:
RoiI.RoiResultMapper

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, an IceMapper instance can also be configured to handle return value mapping, though by default an exception will be thrown if mapReturnValue(Object) is called.


Nested Class Summary
static interface IceMapper.ReturnMapping
           
 
Field Summary
static IceMapper.ReturnMapping FILTERABLE
           
static IceMapper.ReturnMapping FILTERABLE_ARRAY
           
static IceMapper.ReturnMapping FILTERABLE_COLLECTION
           
static IceMapper.ReturnMapping FILTERABLE_PRIMITIVE_MAP
           
static IceMapper.ReturnMapping OBJECT_TO_RTYPE
           
static IceMapper.ReturnMapping PRIMITIVE
           
static IceMapper.ReturnMapping PRIMITIVE_FILTERABLE_COLLECTION_MAP
           
static IceMapper.ReturnMapping PRIMITIVE_MAP
           
static IceMapper.ReturnMapping STRING_TO_RSTRING
           
protected  Map target2model
           
static IceMapper.ReturnMapping UNMAPPED
          Specifies a return type which should not be parsed.
static IceMapper.ReturnMapping VOID
           
 
Fields inherited from class ome.util.ModelMapper
model2target
 
Fields inherited from class ome.util.ContextFilter
_cache, _context
 
Constructor Summary
IceMapper()
           
IceMapper(IceMapper.ReturnMapping mapping)
           
 
Method Summary
protected  Map c2c()
           
 boolean canMapReturnValue()
          True if this instance has a IceMapper.ReturnMapping
static omero.RTime convert(Date date)
           
static omero.sys.EventContext convert(EventContext ctx)
           
static ome.parameters.Filter convert(omero.sys.Filter f)
           
static ome.parameters.Options convert(omero.sys.Options o)
           
 ome.parameters.Parameters convert(omero.sys.Parameters params)
           
 ome.model.internal.Permissions convert(omero.model.Permissions p)
           
static PlaneDef convert(omero.romio.PlaneDef def)
           
static Principal convert(omero.sys.Principal old)
           
static omero.romio.RGBBuffer convert(RGBBuffer buffer)
           
static omero.sys.Roles convert(Roles roles)
           
static Timestamp convert(omero.RTime time)
           
 ome.parameters.QueryParameter convert(String key, Object o)
           
static omero.ServerError fillServerError(omero.ServerError se, Throwable t)
           
 ome.util.Filterable filter(String fieldId, ome.util.Filterable source)
           
 Collection findCollection(Collection source)
          Overrides the findCollection logic of ModelMapper, since all Collections should be Lists in Ice.
 Object fromRType(omero.RType rt)
          Uses the omero.rtypes hierarchy to properly convert any RType to its internal representation.
 Ice.UserException handleException(Throwable t, OmeroContext ctx)
           
 Object handleInput(Class<?> p, Object arg)
           
 Object handleOutput(Class type, Object o)
           
protected  boolean hasntSeen(Object o)
           
 boolean isImmutable(Object obj)
           
protected static boolean isNullablePrimitive(Class<?> p)
           
protected  boolean isPrimitive(Class<?> p)
           
 boolean isVoid()
          Returns true only if the current mapping is the VOID mapping.
protected static boolean isWrapperArray(Class<?> p)
           
 List map(ome.util.Filterable[] array)
           
 Object mapReturnValue(Object value)
          Convert the given Object via the set IceMapper.ReturnMapping.
static Class<? extends ome.model.IObject> omeroClass(String className, boolean strict)
           
 Collection reverse(Collection source)
          Copied from ModelMapper.findCollection(Collection) This could be unified in that a method findCollection(Collection, Map) was added with ModelMapper calling findCollection(source,model2target) and #reverseCollection(Collection) calling findCollection(source,target2model).
 Collection reverse(Collection source, Class targetType)
          Creates a collection assignable to the given type.
 Map reverse(Map map)
           
 ome.util.Filterable reverse(ome.model.ModelBased source)
          Copied from ReverseModelMapper#map(ModelBased)
 Object reverse(Object source)
           
 Object[] reverseArray(List list, Class type)
          Supports the separate case of reversing for arrays.
static String stackAsString(Throwable t)
           
 void store(Object source, Object target)
           
 omero.RType toRType(Object o)
           
 
Methods inherited from class ome.util.ModelMapper
event2timestamp, filter, filter, findClass, findMap, findTarget, map, map, map, nullSafeDouble, nullSafeFloat, nullSafeInt, nullSafeLong
 
Methods inherited from class ome.util.ContextFilter
addSeen, afterFilter, beforeFilter, currentContext, doFilter, doFilter, doFilter, enter, exit, filter, filter, pop, previousContext, push
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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

target2model

protected Map 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 the VOID mapping.


canMapReturnValue

public boolean canMapReturnValue()
True if this instance has a IceMapper.ReturnMapping


mapReturnValue

public Object mapReturnValue(Object value)
                      throws Ice.UserException
Convert the given Object via the set IceMapper.ReturnMapping. Throws a NullPointException if no mapping is set.

Throws:
Ice.UserException

fillServerError

public static omero.ServerError fillServerError(omero.ServerError se,
                                                Throwable t)

stackAsString

public static String stackAsString(Throwable t)

omeroClass

public static Class<? extends ome.model.IObject> omeroClass(String className,
                                                            boolean strict)
                                                     throws omero.ApiUsageException
Throws:
omero.ApiUsageException

toRType

public omero.RType toRType(Object o)
                    throws omero.ApiUsageException
Throws:
omero.ApiUsageException

fromRType

public Object fromRType(omero.RType rt)
                 throws omero.ApiUsageException
Uses the omero.rtypes hierarchy to properly convert any RType to its internal representation. This requires that the instance properly implement rtypes.Conversion otherwise ApiUsageException will be thrown.

Parameters:
rt -
Returns:
Throws:
omero.ApiUsageException

convert

public static omero.sys.EventContext convert(EventContext ctx)

convert

public static omero.romio.RGBBuffer convert(RGBBuffer buffer)

convert

public static PlaneDef convert(omero.romio.PlaneDef def)
                        throws omero.ApiUsageException
Throws:
omero.ApiUsageException

convert

public static Principal convert(omero.sys.Principal old)

convert

public static omero.sys.Roles convert(Roles roles)

convert

public static omero.RTime convert(Date date)

convert

public static Timestamp convert(omero.RTime time)

convert

public ome.parameters.Parameters convert(omero.sys.Parameters params)
                                  throws omero.ApiUsageException
Throws:
omero.ApiUsageException

convert

public ome.parameters.QueryParameter convert(String key,
                                             Object o)
                                      throws omero.ApiUsageException
Throws:
omero.ApiUsageException

convert

public static ome.parameters.Options convert(omero.sys.Options o)

convert

public static ome.parameters.Filter convert(omero.sys.Filter f)

findCollection

public Collection findCollection(Collection source)
Overrides the findCollection logic of ModelMapper, since all Collections should be Lists in Ice. Originally necessitated by the Map> return value of IContainer#findAnnotations(Class, Set, Set, Map)

Overrides:
findCollection in class ome.util.ModelMapper

map

public List map(ome.util.Filterable[] array)

convert

public ome.model.internal.Permissions convert(omero.model.Permissions p)

isImmutable

public boolean isImmutable(Object obj)

reverse

public Object reverse(Object source)
               throws omero.ApiUsageException
Throws:
omero.ApiUsageException

reverse

public Collection reverse(Collection source)
Copied from ModelMapper.findCollection(Collection) This could be unified in that a method findCollection(Collection, Map) was added with ModelMapper calling findCollection(source,model2target) and #reverseCollection(Collection) calling findCollection(source,target2model).

Specified by:
reverse in interface ome.util.ReverseModelMapper
Parameters:
collection -
Returns:

reverse

public Collection reverse(Collection source,
                          Class targetType)
Creates a collection assignable to the given type. Currently only Set and List are supported, and HashSets and ArrayLists will be returned. The need for this arose from the decision to have no Sets in the Ice Java mapping.

Parameters:
source -
targetType -
Returns:
See Also:
ticket:684

reverseArray

public Object[] reverseArray(List list,
                             Class type)
                      throws omero.ServerError
Supports the separate case of reversing for arrays. See reverse(Collection, Class) and map(Filterable[]).

Parameters:
list -
type -
Returns:
Throws:
omero.ServerError

reverse

public Map reverse(Map map)

reverse

public ome.util.Filterable reverse(ome.model.ModelBased source)
Copied from ReverseModelMapper#map(ModelBased)

Specified by:
reverse in interface ome.util.ReverseModelMapper
Parameters:
source -
Returns:

store

public void store(Object source,
                  Object target)

c2c

protected Map c2c()
Specified by:
c2c in class ome.util.ModelMapper

filter

public ome.util.Filterable filter(String fieldId,
                                  ome.util.Filterable source)
Specified by:
filter in interface ome.util.Filter
Overrides:
filter in class ome.util.ModelMapper

hasntSeen

protected boolean hasntSeen(Object o)
Overrides:
hasntSeen in class ome.util.ContextFilter

isPrimitive

protected boolean isPrimitive(Class<?> p)

isNullablePrimitive

protected static boolean isNullablePrimitive(Class<?> p)

isWrapperArray

protected static boolean isWrapperArray(Class<?> p)

handleInput

public Object handleInput(Class<?> p,
                          Object arg)
                   throws omero.ServerError
Throws:
omero.ServerError

handleOutput

public Object handleOutput(Class type,
                           Object o)
                    throws omero.ServerError
Throws:
omero.ServerError

handleException

public Ice.UserException handleException(Throwable t,
                                         OmeroContext ctx)


OmeroJava Api

Version: Beta-4.1.1-r5927-b91

Copyright © 2009 The University of Dundee. All Rights Reserved.