Package omero.util

Class 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, 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.
    • Method Detail

      • isVoid

        public boolean isVoid()
        Returns true only if the current mapping is the VOID mapping.
      • mapReturnValue

        public java.lang.Object mapReturnValue​(java.lang.Object value)
                                        throws Ice.UserException
        Convert the given Object via the set IceMapper.ReturnMapping. Throws a NullPointerException if no mapping is set.
        Throws:
        Ice.UserException
      • omeroClass

        public static java.lang.Class<? extends ome.model.IObject> omeroClass​(java.lang.String className,
                                                                              boolean strict)
                                                                       throws ApiUsageException
        Throws:
        ApiUsageException
      • fromRType

        public java.lang.Object fromRType​(RType rt)
                                   throws 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 - 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 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 to RStrings. null values are dropped completely.
        Parameters:
        map - a map
        Returns:
        the converted map, or null if map == null
      • findCollection

        public java.util.Collection findCollection​(java.util.Collection source)
        Overrides the findCollection logic of ModelMapper, since all Collections should be Lists in Ice.
        Overrides:
        findCollection in class ome.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.util.Collection reverse​(java.util.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:
        source - the wrapped Collection
        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 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.
        See Also:
        Trac ticket #684
      • reverse

        public java.util.Map reverse​(java.util.Map map)
      • reverse

        public ome.util.Filterable reverse​(ome.model.ModelBased source)
        Copied from ReverseModelMapper.
        Specified by:
        reverse in interface ome.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 from RStrings. null values are dropped completely.
        Parameters:
        rMap - a map
        Returns:
        the reversed map, or null if rMap == 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 class ome.util.ModelMapper
      • filter

        public ome.util.Filterable filter​(java.lang.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​(java.lang.Object o)
        Overrides:
        hasntSeen in class ome.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
      • handleException

        public Ice.UserException handleException​(java.lang.Throwable t,
                                                 ome.system.OmeroContext ctx)