Ejemplo n.º 1
0
    def literal(self, value):
        """
        Constructs an expression with the given literal value.

        Args:
            value (any): The literal value to use.
        Returns:
            An Expression with the given literal value.
        """
        if isinstance(value, datetime):
            # Convert the date to a string
            value = value.strftime("%Y-%m-%dT%H:%M:%S")
        if isinstance(value, str):
            # Prevent Py4J from assuming the string matches up with the char variant method
            filter_factory_class = self._java_ref.getClass()
            object_class = reflection_util.classForName("java.lang.Object")
            class_array = java_gateway.new_array(java_pkg.java.lang.Class, 1)
            class_array[0] = object_class
            method = filter_factory_class.getMethod("literal", class_array)
            objects_array = java_gateway.new_array(java_pkg.java.lang.Object, 1)
            objects_array[0] = value
            return method.invoke(self._java_ref, objects_array)
        if isinstance(value, BaseGeometry):
            return self._java_ref.literal(GeometryType().to_java(value))
        return self._java_ref.literal(value)
Ejemplo n.º 2
0
def _invoke_filter_method_by_name(j_filter_factory, name, filter):
    filter_factory_class = j_filter_factory.getClass()
    filter_class = reflection_util.classForName("org.opengis.filter.Filter")
    class_array = java_gateway.new_array(java_pkg.java.lang.Class, 1)
    class_array[0] = filter_class
    method = filter_factory_class.getMethod(name, class_array)
    objects_array = java_gateway.new_array(java_pkg.java.lang.Object, 1)
    objects_array[0] = filter
    return method.invoke(j_filter_factory, objects_array)
Ejemplo n.º 3
0
def _invoke_filter_list_method_by_name(j_filter_factory, name, filters):
    filter_factory_class = j_filter_factory.getClass()
    list_class = reflection_util.classForName("java.util.List")
    class_array = java_gateway.new_array(java_pkg.java.lang.Class, 1)
    class_array[0] = list_class
    method = filter_factory_class.getMethod(name, class_array)
    filter_list = java_pkg.java.util.ArrayList()
    for filter in filters:
        filter_list.append(filter)
    objects_array = java_gateway.new_array(java_pkg.java.lang.Object, 1)
    objects_array[0] = filter_list
    return method.invoke(j_filter_factory, objects_array)
Ejemplo n.º 4
0
 def __init__(self, attribute_type, is_nilable, descriptor, j_attribute=None):
     if not isinstance(attribute_type, AttributeDescriptor.Type):
         raise AttributeDescriptor.UnknownTypeError("Invalid argument to `attribute_type`. Must be one of defined types in AttributeDescriptor.Type")
     self.field = attribute_type.value()
     self.is_nilable = is_nilable
     self.descriptor = descriptor
     if j_attribute is None:
         j_builder = java_pkg.org.geotools.feature.AttributeTypeBuilder()
         j_type_cls = reflection_util.classForName(self.field.binding)
         j_builder.binding(j_type_cls)
         j_builder.nillable(is_nilable)
         j_attribute = j_builder.buildDescriptor(descriptor)
     super().__init__(j_attribute)