utility method that wraps given filter with given range

@param   \stubbles\input\Filter              $filter  decorated filter
@param   \stubbles\input\filter\range\Range  $range   range definition
@return  \stubbles\input\Filter
435842
public static function wrap(Filter $filter, Range $range = null)
    {
        if (null === $range) {
            return $filter;
        }

        return new self($filter, $range);
    }
225069
public function setFilter($filter)
    {
        return $this->filter = is_array($filter) ? self::flexiUrl($filter) : $filter;
    }
1012283
public function filter($filter = null)
    {
        if (is_null($filter)) {
            return $this->filter;
        } else {
            $this->filter = $filter;
        }
    }
747235
public function make($filter)
    {
        if ($filter instanceof Filter)
        {
            return clone $filter;
        }
        
        $filter = isset($this->aliases[$filter]) ? $this->aliases[$filter] : $filter;

        if (is_array($filter))
        {
            list($filter, $callback) = array(current($filter), next($filter));
        }

        // If the filter was aliased and the value of the array was a callable closure then
        // we'll return and fire the callback on the filter instance so that any arguments
        // can be set for the filters constructor.
        $filter = new Filter($this->log, $filter, $this->nodePaths, $this->appEnvironment);

        if (isset($callback) and is_callable($callback))
        {
            call_user_func($callback, $filter);
        }

        return $filter;
    }
644005
protected function convertToFilterFormat($filter)
    {
        $filter = trim($filter);
        if (substr($filter, 0, 1) != '(') {
            $filter = '(' . $filter;
        }
        if (substr($filter, -1) != ')') {
            $filter = $filter . ')';
        }
        return $filter;
    }
901295
public function searchRange(Range $range)
    {
        $iterator = $this->getIterator();
        
        // find start
        $start = null;
        $binarySearch = new BinarySearch($this);
        $startHint = $binarySearch->search($range->getMin());
        if ($startHint == null) {
            return new RangeIterator($iterator, Range::getEmptyRange());
            
        }
        $iterator->setOffset($startHint->getOffset(), Parser::HINT_RESULT_BOUNDARY);

        if (! $range->contains($startHint->getKey()) && $startHint->getKey() <= $range->getMin()) {
            // shift $startHint higher
            
            foreach ($iterator as $result) {
                if ($range->contains($result->getKey())) {
                    $start = $result;
                    break;
                    
                }
            }
            
        } else {
            // shift $startHint lower
            
            if ($range->contains($startHint->getKey())) {
                $start = $startHint;
                
            }
            $iterator->setDirection(KeyReader::DIRECTION_BACKWARD);
            foreach ($iterator as $result) {
                // Skip everything which is too big
                if (! $range->contains($result->getKey() && $result->getKey() >= $range->getMax())) {
                    continue;
                    
                }
                
                // shift the start left until no more key is included
                if ($range->contains($result->getKey())) {
                    $start = $result;
                    
                } else {
                    break;
                    
                }
            }
            
        }
        if (is_null($start)) {
            return new RangeIterator($iterator, Range::getEmptyRange());

        }
        
        $iterator = $this->getIterator();
        $iterator->setOffset($start->getOffset(), Parser::HINT_RESULT_BOUNDARY);
        return new RangeIterator($iterator, $range);
    }
185213
public function buildFilterRulesForFilterSetting($filter)
    {
        if (!$this->get('select_filter')) {
            return;
        }

        // Set Filter and co.
        $filterSettings = $this->filterSettingFactory->createCollection($this->get('select_filter'));

        if ($filterSettings) {
            $values       = $_GET;
            $presets      = (array) $this->get('select_filterparams');
            $presetNames  = $filterSettings->getParameters();
            $filterParams = \array_keys($filterSettings->getParameterFilterNames());
            $processed    = [];

            // We have to use all the preset values we want first.
            foreach ($presets as $presetName => $preset) {
                if (\in_array($presetName, $presetNames)) {
                    $processed[$presetName] = $preset['value'];
                }
            }

            // Now we have to use all FrontEnd filter params, that are either:
            // * not contained within the presets
            // * or are overridable.
            foreach ($filterParams as $parameter) {
                // Unknown parameter? - next please.
                if (!\array_key_exists($parameter, $values)) {
                    continue;
                }

                // Not a preset or allowed to override? - use value.
                if ((!\array_key_exists($parameter, $presets)) || $presets[$parameter]['use_get']) {
                    $processed[$parameter] = $values[$parameter];
                }
            }

            $filterSettings->addRules($filter, $processed);
        }
    }
979244
public function add($filter)
    {
        if (is_array($filter)) {
            $this->collection[] = new Filter($filter);
        } elseif (is_object($filter) && $filter instanceof Filter) {
            $this->collection[] = $filter;
        }

        return $this;
    }
1260765
public static void setInputRange(Configuration conf, List<IndexExpression> filter)
    {
        KeyRange range = new KeyRange().setRow_filter(filter);
        conf.set(INPUT_KEYRANGE_CONFIG, thriftToString(range));
    }
586998
def get_value_filter(self, filter_value):
        '''
        
        '''
        self.validate_parameter(filter_value)
        f, t = self._ranges[filter_value]
        limits = {}
        # lt and gte to ensure non-overlapping ranges
        if f is not None:
            limits['gte'] = f
        if t is not None:
            limits['lt'] = t

        return Q('range', **{
            self._params['field']: limits
        })
803505
public function max($max = null, $addFilter = true, $forceInt = false)
    {
        if ($addFilter) {
            $this->addFilter(new RangeFilter(null, $max, $forceInt));
        }

        return $this->attr('max', $max);
    }
18969
public function addFilter($filter)
    {
        if (!($filter instanceof FilterInterface) && !is_callable($filter)) {
            $filter = FilterHelper::create($filter);
        }

        $this->filter->addFilter($filter);

        return $this;
    }
808297
public function setFilter($filter = null)
    {
        $this->filter = is_callable($filter) ? $filter : null;

        return $this;
    }
1345549
public function filter($filter)
    {
        if (is_array($filter)) {
            $filter = new GridFilter($filter);
        }

        if ($filter instanceof FilterSpecification) {
            $filter = new GridFilter($filter->asFilter());
        }

        $this->filter = $filter;

        return $this;
    }
1181997
public function applyFilter(Criteria $criteria, $filter)
    {
        if (is_string($filter) && is_string($this->property)) {
            $criteria->andWhere(
                $criteria->expr()->contains($this->property, $filter)
            );
        }

        if (is_array($filter) && isset($filter[$this->searchKey])) {
            $criteria->andWhere(
                $criteria->expr()->contains($this->property, $filter[$this->searchKey])
            );
        }

        return $criteria;
    }
34892
private static function range(ResponseInterface $response, string $range): ResponseInterface
    {
        $response = $response->withHeader('Accept-Ranges', 'bytes');

        if (empty($range) || !($range = self::parseRangeHeader($range))) {
            return $response;
        }

        list($first, $last) = $range;
        $size = $response->getBody()->getSize();

        if ($last === null) {
            $last = $size - 1;
        }

        return $response
            ->withStatus(206)
            ->withHeader('Content-Length', (string) ($last - $first + 1))
            ->withHeader('Content-Range', sprintf('bytes %d-%d/%d', $first, $last, $size));
    }
154022
public function asDatespan(DatespanRange $range = null)
    {
        return $this->handleFilter(
                function() use($range)
                {
                    return filter\RangeFilter::wrap(
                            filter\DatespanFilter::instance(),
                            $range
                    );
                }
        );
    }