def javaHazardEventToPyHazardEvent(obj, customConverter=None): if PyJavaUtil.isSubclass(obj, IHazardEvent): return True, HazardEvent(obj) elif PyJavaUtil.isSubclass(obj, IReadableHazardEvent): return True, ReadableHazardEvent(obj) else: return False, obj
def javaHydrographToPyHydrograph(obj, customConverter=None): if PyJavaUtil.isSubclass(obj, HydrographForecast): hydrograph = PyHydrographForecast(obj) elif PyJavaUtil.isSubclass(obj, HydrographObserved): hydrograph = PyHydrographObserved(obj) elif PyJavaUtil.isSubclass(obj, HydrographPrecip): hydrograph = PyHydrographPrecip(obj) else: return False, obj return True, hydrograph
def javaSHEFToPySHEF(obj, customConverter=None): if PyJavaUtil.isSubclass(obj, SHEFForecast): shef = PySHEFForecast(obj) elif PyJavaUtil.isSubclass(obj, SHEFObserved): shef = PySHEFObserved(obj) elif PyJavaUtil.isSubclass(obj, SHEFPrecip): shef = PySHEFPrecip(obj) else: return False, obj return True, shef
def javaCollectionToPyCollection(obj, customConverter=None): ''' Method registered with JUtil for conversion of Java collections to Python collections. ''' if hasattr(obj, 'java_name'): classname = obj.java_name if classname in javaCollections : return True, javaCollections[classname](obj, customConverter) elif PyJavaUtil.isArray(obj): return True, _fromJavaArray(obj, customConverter) else : # we have some fallback capability, if we don't specifically handle a class, we # want to try some of the more common types and see if those are available for # conversion for javaClass in fallbackCollections : if PyJavaUtil.isSubclass(obj, javaClass): return True, fallbackCollections[javaClass](obj, customConverter) elif isinstance(obj, JEP_ARRAY_TYPE): return True, _fromJepArray(obj, customConverter) return False, obj
def javaVisualFeaturesToPyVisualFeatures(obj, customConverter = None): if obj is None: return True, None if PyJavaUtil.isSubclass(obj, VisualFeaturesList): # Convert the Java objects to JSON. asJson = VisualFeaturesListJsonConverter.toJson(obj) # Convert the JSON to a list of dictionaries. return True, VisualFeatures(json.loads(asJson, cls = VisualFeaturesListJsonDecoder)) return False, obj
def javaGenericSessionObjectManagerToPyGenericSessionObjectManager(obj, customConverter = None): if PyJavaUtil.isSubclass(obj, JavaGenericSessionObjectManager): return True, GenericSessionObjectManager(obj) return False, obj
def _isJavaConvertible(obj): return PyJavaUtil.isSubclass(obj, RiverForecastPoint)
def _isJavaConvertible(obj): return PyJavaUtil.isSubclass(obj, ProductPart)
def jtsToShapely(obj, customConverter=None): if PyJavaUtil.isSubclass(obj, Geometry): return True, _toShapely(obj) return False, obj
def _isJavaConvertible(obj): return PyJavaUtil.isSubclass(obj, KeyInfo)
def javaAdvancedGeometryToPyAdvancedGeometry(obj, customConverter = None): if PyJavaUtil.isSubclass(obj, IAdvancedGeometry): return True, AdvancedGeometry(obj) return False, obj