示例#1
0
文件: convert.py 项目: safvan010/123
    def categorise_object(self, node, suggested_type, **kwargs):

        from xml.dom import Node

        if node is None:
            number_of_nodes = 0
            null_value = True
        elif isinstance(node, types.StringTypes):
            number_of_nodes = -1  # Means "no-node type".
            null_value = not node
        else:
            number_of_nodes = len(node.childNodes)
            null_value = not number_of_nodes

        # This is a bit ambiguous - how on earth are we meant to determine
        # this? We'll see whether an explicit type is given here, otherwise
        # we'll have to just guess.
        if null_value:
            if suggested_type == 'mapping':
                return MAPPING_TYPE
            elif is_array_type(suggested_type):
                return SEQUENCE_TYPE

            # If the suggested type is atomic, then we inform them that
            # it is an atomic object. Some atomic types make sense with
            # no nodes (like an empty string). Some don't, of course
            # (like an integer), but never mind. It's better to inform
            # the caller code that it is an atom if the desired type is
            # an atom - otherwise for empty strings, we will get None
            # instead.
            elif is_java_return_type(suggested_type):
                # We'll assume it is just an atom. It can't be an object
                # without an object ID.
                return ATOM_TYPE

            # Oh well, let's just say it's null then.
            else:
                return NULL_TYPE

        if number_of_nodes == -1:
            return ATOM_TYPE

        if number_of_nodes == 1 and node.firstChild.nodeType == Node.TEXT_NODE:
            return ATOM_TYPE

        if number_of_nodes and node.firstChild.nodeName == 'ENTRY':
            return SEQUENCE_TYPE

        if suggested_type == 'mapping':
            return MAPPING_TYPE

        return OBJECT_TYPE
示例#2
0
    def categorise_object(self, node, suggested_type, **kwargs):

        from xml.dom import Node

        if node is None:
            number_of_nodes = 0
            null_value = True
        elif isinstance(node, types.StringTypes):
            number_of_nodes = -1 # Means "no-node type".
            null_value = not node
        else:
            number_of_nodes = len(node.childNodes)
            null_value = not number_of_nodes

        # This is a bit ambiguous - how on earth are we meant to determine
        # this? We'll see whether an explicit type is given here, otherwise
        # we'll have to just guess.
        if null_value:
            if suggested_type == 'mapping':
                return MAPPING_TYPE
            elif is_array_type(suggested_type):
                return SEQUENCE_TYPE

            # If the suggested type is atomic, then we inform them that
            # it is an atomic object. Some atomic types make sense with
            # no nodes (like an empty string). Some don't, of course
            # (like an integer), but never mind. It's better to inform
            # the caller code that it is an atom if the desired type is
            # an atom - otherwise for empty strings, we will get None
            # instead.
            elif is_java_return_type(suggested_type):
                # We'll assume it is just an atom. It can't be an object
                # without an object ID.
                return ATOM_TYPE

            # Oh well, let's just say it's null then.
            else:
                return NULL_TYPE

        if number_of_nodes == -1:
            return ATOM_TYPE

        if number_of_nodes == 1 and node.firstChild.nodeType == Node.TEXT_NODE:
            return ATOM_TYPE

        if number_of_nodes and node.firstChild.nodeName == 'ENTRY':
            return SEQUENCE_TYPE

        if suggested_type == 'mapping':
            return MAPPING_TYPE

        return OBJECT_TYPE
示例#3
0
文件: convert.py 项目: safvan010/123
def is_azureus_return_type(java_type):
    return is_java_return_type(java_type) or \
        is_azureus_return_class(java_type)
示例#4
0
def is_azureus_return_type(java_type):
    return is_java_return_type(java_type) or \
        is_azureus_return_class(java_type)