コード例 #1
0
 public static function exactMatch2()
 {
     if (self::$exactMatch2 === null) {
         self::$exactMatch2 = self::infix('===', 'IS');
     }
     return self::$exactMatch2;
 }
コード例 #2
0
 public static function fieldValueFilter($scheme, $pattern, EarthIT_Schema_Field $field, EarthIT_Schema_ResourceClass $rc)
 {
     switch ($scheme) {
         case 'not':
             // Oh look this is kind of a silly way to do it:
             $toBeNegated = self::parsePattern($field->getName(), $pattern, $rc);
             return new EarthIT_Storage_Filter_NegatedItemFilter($toBeNegated);
         case 'is':
             if ($pattern === 'null') {
                 $comparisonOp = EarthIT_Storage_Filter_ComparisonOps::exactMatch2();
                 $vExp = EarthIT_Storage_Filter_NullValueExpression::getInstance();
             } else {
                 throw new Exception("'is:' operator only supports 'null' pattern; given: " . var_export($pattern, true));
             }
             break;
         case 'eq':
             $value = EarthIT_Storage_Util::cast($pattern, $field->getType()->getPhpTypeName());
             return new EarthIT_Storage_Filter_ExactMatchFieldValueFilter($field, $rc, $value);
         case 'in':
             $values = array();
             if ($pattern === '') {
                 $pattern = array();
             }
             $patternValues = is_array($pattern) ? $pattern : explode(',', $pattern);
             foreach ($patternValues as $p) {
                 $values[] = EarthIT_Storage_Util::cast($p, $field->getType()->getPhpTypeName());
             }
             if (count($values) == 0) {
                 return new EarthIT_Storage_Filter_OredItemFilter(array());
             }
             $comparisonOp = EarthIT_Storage_Filter_InListComparisonOp::getInstance();
             $vExp = new EarthIT_Storage_Filter_ListValueExpression($values);
             break;
         case 'lt':
         case 'le':
         case 'ge':
         case 'gt':
             $comparisonOp = EarthIT_Storage_Filter_ComparisonOps::get($scheme);
             $value = EarthIT_Storage_Util::cast($pattern, $field->getType()->getPhpTypeName());
             $vExp = new EarthIT_Storage_Filter_ScalarValueExpression($value);
             break;
         case 'like':
             return new EarthIT_Storage_Filter_PatternFieldValueFilter($field, $rc, $pattern, true);
         default:
             throw new Exception("Unrecognized pattern scheme: '{$scheme}'");
     }
     return new EarthIT_Storage_Filter_FieldValueComparisonFilter($field, $rc, $comparisonOp, $vExp);
 }