@@ -, +, @@ Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. * Common functionality used by VLOOKUP, HLOOKUP, LOOKUP and MATCH */ private static final class SheetVector implements ValueVector { private final RefEval _re; private final int _size; public SheetVector(RefEval re) { _size = re.getNumberOfSheets(); _re = re; } public ValueEval getItem(int index) { if(index >= _size) { throw new ArrayIndexOutOfBoundsException("Specified index (" + index + ") is outside the allowed range (0.." + (_size-1) + ")"); } int sheetIndex = _re.getFirstSheetIndex() + index; return _re.getInnerValueEval(sheetIndex); } public int getSize() { return _size; } } public static final CompareResult valueOf(boolean matches) { if(matches) { return EQUAL ; } return LESS_THAN; } private static final class StringLookupComparer extends LookupValueComparerBase { private String _value; private final Pattern _wildCardPattern; private boolean _matchExact; private boolean _isMatchFunction; private Double _doublevalue; private boolean _isconverted; protected StringLookupComparer(StringEval se, boolean matchExact, boolean isMatchFunction) { _wildCardPattern = Countif.StringMatcher.getWildCardPattern(_value); _matchExact = matchExact; _isMatchFunction = isMatchFunction; StringEval se = (StringEval) other; String stringValue = se.getStringValue(); if (_wildCardPattern != null) { Matcher matcher = _wildCardPattern.matcher(stringValue); boolean matches = matcher.matches(); if (_isMatchFunction || !_matchExact) { return CompareResult.valueOf(matches); } } return CompareResult.valueOf(_value.compareToIgnoreCase(stringValue)); //TODO eventually here return a WildcardStringLookupComparer