PengZheng commented on code in PR #721:
URL: https://github.com/apache/celix/pull/721#discussion_r1466403043


##########
libs/utils/include/celix_filter.h:
##########
@@ -54,15 +55,53 @@
  * Apache Celix filters can be used to match a set of Apache Celix properties 
and such Apache Celix filters should be
  * used together with a set of properties.
  *
- * Internally attribute values will be parsed to a long, double, boolean and 
Apache Celix version if
- * possible during creation. And these typed attribute values will be used in 
the to-be-matched property value,
- * if the property value is of the same type.
+ * #Filter matching and property value types
+ * When matching a filter the attribute type of a filter node is used to 
determine the type of the property value and
+ * this type is used to compare the property value with the filter attribute 
value.
+ * If the property value is of a type that the filter attribute value can be 
parsed to, the filter attribute value the
+ * comparison is done with the matching type. If the property value is not of 
a type that the filter attribute value
+ * can be parsed to, the comparison is done with the string representation of 
the property value.
  *
+ * Internally attribute values will be parsed to a long, double, boolean, 
Apache Celix version and array list of
+ * longs, doubles, booleans, Apache Celix versions and string if possible 
during creation.
+ * And these typed attribute values will be used in the to-be-matched property 
value.
+ *
+ * Example: The filter "(key>20)" and a property set with a long value 3 for 
key "key", will match and the same
+ * filter but with a property set which has a string value "3" for key "key", 
will not match.

Review Comment:
   If the above understanding is correct (it could be wrong), then for string 
value "3", the filter operation `>` should be string comparison.



##########
libs/utils/include/celix_filter.h:
##########
@@ -54,15 +55,53 @@
  * Apache Celix filters can be used to match a set of Apache Celix properties 
and such Apache Celix filters should be
  * used together with a set of properties.
  *
- * Internally attribute values will be parsed to a long, double, boolean and 
Apache Celix version if
- * possible during creation. And these typed attribute values will be used in 
the to-be-matched property value,
- * if the property value is of the same type.
+ * #Filter matching and property value types
+ * When matching a filter the attribute type of a filter node is used to 
determine the type of the property value and
+ * this type is used to compare the property value with the filter attribute 
value.
+ * If the property value is of a type that the filter attribute value can be 
parsed to, the filter attribute value the
+ * comparison is done with the matching type. If the property value is not of 
a type that the filter attribute value
+ * can be parsed to, the comparison is done with the string representation of 
the property value.

Review Comment:
   I found this paragraph quite confusing. A filter is created from a string, 
which carries no type information. On the other hand, JAVA properties (or 
recent version of Celix properties) does carry type information. How to use the 
attribute type of a filter node, which is absent in the string representation 
of LDAP filter, to determine the type of the property value?
   
   Each well-known property like "CELIX_FRAMEWORK_SERVICE_ID" has well-defined 
type. The basic assumption is that each well-known property is set to its 
well-defined type. When matching a properties against a LDAP filter, we should 
assume the type information carried in properties is correct, and use that to 
determine the attribute type of a filter node. 
   
   "If the property value is not of a type that the filter attribute value can 
be parsed to", the matching should simply failed, because we assume the type 
information in properties is always correct.
   
   I may need to find some time to check OSGi Java implementation like Felix.



##########
libs/utils/include/celix_filter.h:
##########
@@ -54,15 +55,53 @@
  * Apache Celix filters can be used to match a set of Apache Celix properties 
and such Apache Celix filters should be
  * used together with a set of properties.
  *
- * Internally attribute values will be parsed to a long, double, boolean and 
Apache Celix version if
- * possible during creation. And these typed attribute values will be used in 
the to-be-matched property value,
- * if the property value is of the same type.
+ * #Filter matching and property value types
+ * When matching a filter the attribute type of a filter node is used to 
determine the type of the property value and
+ * this type is used to compare the property value with the filter attribute 
value.
+ * If the property value is of a type that the filter attribute value can be 
parsed to, the filter attribute value the
+ * comparison is done with the matching type. If the property value is not of 
a type that the filter attribute value
+ * can be parsed to, the comparison is done with the string representation of 
the property value.
  *
+ * Internally attribute values will be parsed to a long, double, boolean, 
Apache Celix version and array list of
+ * longs, doubles, booleans, Apache Celix versions and string if possible 
during creation.
+ * And these typed attribute values will be used in the to-be-matched property 
value.
+ *
+ * Example: The filter "(key>20)" and a property set with a long value 3 for 
key "key", will match and the same

Review Comment:
   (key, 3) can not match `(key>20)`, since `3 < 20`.



##########
libs/utils/include/celix_filter.h:
##########
@@ -54,15 +55,53 @@
  * Apache Celix filters can be used to match a set of Apache Celix properties 
and such Apache Celix filters should be
  * used together with a set of properties.
  *
- * Internally attribute values will be parsed to a long, double, boolean and 
Apache Celix version if
- * possible during creation. And these typed attribute values will be used in 
the to-be-matched property value,
- * if the property value is of the same type.
+ * #Filter matching and property value types
+ * When matching a filter the attribute type of a filter node is used to 
determine the type of the property value and
+ * this type is used to compare the property value with the filter attribute 
value.
+ * If the property value is of a type that the filter attribute value can be 
parsed to, the filter attribute value the
+ * comparison is done with the matching type. If the property value is not of 
a type that the filter attribute value
+ * can be parsed to, the comparison is done with the string representation of 
the property value.
  *
+ * Internally attribute values will be parsed to a long, double, boolean, 
Apache Celix version and array list of
+ * longs, doubles, booleans, Apache Celix versions and string if possible 
during creation.
+ * And these typed attribute values will be used in the to-be-matched property 
value.
+ *
+ * Example: The filter "(key>20)" and a property set with a long value 3 for 
key "key", will match and the same
+ * filter but with a property set which has a string value "3" for key "key", 
will not match.
+ *
+ * #Filter matching and property value arrays
+ * If a filter matches a property set entry which has an array value (either a 
long, boolean, double, string or version
+ * array) the filter match will check if the array contains a single entry 
which matches the filter attribute value using
+ * the aforementioned "Filter matching and property value types" rules.
+ *
+ * Filter matching with array is supported for the following operands: "=" 
(including substring), ">=", "<=", ">", "<"
+ * and "~=".
+ *
+ * Example: The filter "(key=3)" will match the property set entry with key 
"key" and a long array list value of
+ *  [1,2,3].
+ *
+ * #Substring filter operand
+ * The substring filter operand is used to match a string value with a filter 
attribute value. The filter attribute
+ * value can contain a `*` to match any character sequence. The filter 
attribute value can also contain a `*` at the
+ * start or end of the string to match any character sequence at the start or 
end of the string.
+ *
+ * A substring filter operand uses the string representation of the property 
value to match with the filter attribute
+ * or if the property value is an string array the substring filter operand 
will match if any of the string array values.
+ *
+ * Example: The filter "(key=*Smith)" will match the property set entry with 
key "key" and a string value "John Smith".
+ *
+ * #Approx filter operand
+ * The approx filter operand is used to check if the filter attribute value is 
a substring of the property value.
+ * A approx filter operand uses the string representation of the property 
value to match with the filter attribute or
+ * if the property value is an string array the approx filter operand will 
match if any of the string array values.

Review Comment:
   The OSGi spec says "the evaluation of the approximate match ('~=') filter 
type is implementation specific but should at least ignore case and white space 
differences. Codes such as Soundex or other smart closeness comparisons could 
be used. " I didn't expect it to be a substring.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to