コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
ファイル: SHEFHandler.py プロジェクト: Unidata/awips2-hazards
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
コード例 #4
0
ファイル: JUtilHandler.py プロジェクト: srcarter3/awips2-core
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
コード例 #5
0
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
コード例 #6
0
def javaGenericSessionObjectManagerToPyGenericSessionObjectManager(obj, customConverter = None):

    if PyJavaUtil.isSubclass(obj, JavaGenericSessionObjectManager):
        return True, GenericSessionObjectManager(obj)

    return False, obj
コード例 #7
0
def _isJavaConvertible(obj):
    return PyJavaUtil.isSubclass(obj, RiverForecastPoint)
コード例 #8
0
def _isJavaConvertible(obj):
    return PyJavaUtil.isSubclass(obj, ProductPart)
コード例 #9
0
def jtsToShapely(obj, customConverter=None):
    if PyJavaUtil.isSubclass(obj, Geometry):
        return True, _toShapely(obj)
    return False, obj
コード例 #10
0
def _isJavaConvertible(obj):
    return PyJavaUtil.isSubclass(obj, KeyInfo)
コード例 #11
0
def javaAdvancedGeometryToPyAdvancedGeometry(obj, customConverter = None):

    if PyJavaUtil.isSubclass(obj, IAdvancedGeometry):
        return True, AdvancedGeometry(obj)

    return False, obj