Gets the first mapped element along with the generated elements of wrapped constraint.
@param match current pattern match
@param ind mapped indices
@return first mapped element along with the generated elements of wrapped constraint
181973
@Override
	public Collection<BioPAXElement> generate(Match match, int... ind)
	{
		Collection<BioPAXElement> gen = con.generate(match, ind);
		gen.add(match.get(ind[selfIndex]));
		return gen;
	}
865594
public static int indexOfIgnoreCase(String text, String str, int startIndex) {
        Matcher m = Pattern.compile(Pattern.quote(str), Pattern.CASE_INSENSITIVE).matcher(text);
        return m.find(startIndex) ? m.start() : -1;
    }
975383
protected void adjustIndexMap(Iterable<? extends Element> elements) {
        for (Element element : elements) {
            if (shouldAddToIndexMap(element)) {
                String name = utils.isPackage(element)
                        ? utils.getPackageName((PackageElement)element)
                        : utils.getSimpleName(element);
                char ch = (name.length() == 0) ?
                          '*' :
                          Character.toUpperCase(name.charAt(0));
                Character unicode = ch;
                SortedSet<Element> list = indexmap.computeIfAbsent(unicode,
                        c -> new TreeSet<>(comparator));
                list.add(element);
            }
        }
    }
81378
def init(match)
    self.match = match
    match = match[0] if match.kind_of?(Array) && match.length == 1
    case match
    when String then    init_string match
    when Regexp then    init_regex match
    when Symbol then    init_rule match
    when PatternElementHash then      init_hash match
    when Array then     init_array match
    else                raise "invalid pattern type: #{match.inspect}"
    end
  end
104957
public static boolean matches(Pattern patternMatcher, Object... elements)
    {
        if (patternMatcher == null) {
            return true;
        }

        for (Object element : elements) {
            if (matches(patternMatcher, element)) {
                return true;
            }
        }

        return false;
    }
819591
public NamedPatternMatch<E> match(final String string) {
        final Matcher matcher = pattern.matcher(string);
        while (matcher.find()) {

            final int start = matcher.start();
            final int end = matcher.end();

            if (start == 0 && end == string.length()) {
                final Map<E, String> resultMap = new EnumMap<>(groupEnum);
                final Set<Entry<E, Integer>> entries = groupIndexes.entrySet();
                for (final Entry<E, Integer> entry : entries) {
                    final E group = entry.getKey();
                    final Integer groupIndex = entry.getValue();
                    final String result = matcher.group(groupIndex);
                    resultMap.put(group, result);
                }
                return new NamedPatternMatch<>(resultMap);
            }
        }

        return null;
    }
321089
@Pure
	public P getElementAt(int index) {
		if (index >= 0 && index < this.referenceElementCount) {
			int idx = 0;
			for (final GridCellElement<P> element : this.elements) {
				if (element.isReferenceCell(this)) {
					if (idx == index) {
						return element.get();
					}
					++idx;
				}
			}
		}
		throw new IndexOutOfBoundsException();
	}
647979
@Override
	public Collection<BioPAXElement> generate(Match match, int... ind)
	{
		Collection<BioPAXElement> result = new HashSet<BioPAXElement>();

		PhysicalEntity pe = (PhysicalEntity) match.get(ind[0]);

		for (Interaction inter : pe.getParticipantOf())
		{
			if (inter instanceof Conversion)
			{
				Conversion cnv = (Conversion) inter;
				ConversionDirectionType dir = getDirection(cnv);

				// do not get blacklisted small molecules
				if (blacklist != null && blacklist.isUbique(pe, cnv, dir, type)) continue;

				if (dir == ConversionDirectionType.REVERSIBLE)
				{
					result.add(cnv);
				}
				else if (dir == ConversionDirectionType.RIGHT_TO_LEFT &&
					(type == RelType.INPUT ? cnv.getRight().contains(pe) : cnv.getLeft().contains(pe)))
				{
					result.add(cnv);
				}
				// Note that null direction is treated as if LEFT_TO_RIGHT. This is not a best
				// practice, but it is a good approximation.
				else if ((dir == ConversionDirectionType.LEFT_TO_RIGHT || dir == null) &&
					(type == RelType.INPUT ? cnv.getLeft().contains(pe) : cnv.getRight().contains(pe)))
				{
					result.add(cnv);
				}
			}
		}

		return result;
	}
834179
public static String delFirst(Pattern pattern, CharSequence content) {
		if (null == pattern || StrUtil.isBlank(content)) {
			return StrUtil.str(content);
		}

		return pattern.matcher(content).replaceFirst(StrUtil.EMPTY);
	}
118795
protected boolean runFirstMatch(List /* <PatternPair> */ pairs) throws Exception {
        MatchResult firstResult = null;
        PatternPair firstPair = null;
        int pairIndex = -1;

        ListIterator iter = pairs.listIterator();
        while (iter.hasNext()) {
            PatternPair pair = (PatternPair) iter.next();
            Pattern pattern = pair.getPattern();

            // reset input to begining
            input.setCurrentOffset(input.getBeginOffset());

            if (matcher.contains(input, pattern)) {
                MatchResult result = matcher.getMatch();
                if (firstResult == null || result.beginOffset(0) < firstResult.beginOffset(0)) {
                    firstResult = result;
                    firstPair = pair;
                    pairIndex = iter.previousIndex(); // TODO confirm this
                }
            }
        }

        if (firstResult == null)
            return false; // didn't find anything

        // Found something
        //input's offset are illegal at this phase
        //input.setCurrentOffset(input.getBeginOffset());
        logger.trace("Using a result for " + firstPair.getPattern().getPattern());
        ExpectState state = prepareClosure(pairIndex, firstResult);
        Closure closure = firstPair.getClosure();

        try {
            if (closure != null)
                closure.run(state);
        } catch (Exception e) {
            throw e;
        } finally {
            g_state = state;
        }
        return true;
    }
1272958
public static void setIndex(Matcher matcher, int idx) {
        int count = getCount(matcher);
        if (idx < -count || idx >= count) {
            throw new IndexOutOfBoundsException("index is out of range " + (-count) + ".." + (count - 1) + " (index = " + idx + ")");
        }
        if (idx == 0) {
            matcher.reset();
        } else if (idx > 0) {
            matcher.reset();
            for (int i = 0; i < idx; i++) {
                matcher.find();
            }
        } else if (idx < 0) {
            matcher.reset();
            idx += getCount(matcher);
            for (int i = 0; i < idx; i++) {
                matcher.find();
            }
        }
    }
254723
public IContextMapping<INode> filter(IContextMapping<INode> mapping) throws MappingFilterException {
        //add the first mapping element for the root to the mappings result
        if (0 < mapping.size()) {

            IContext sourceContext = mapping.getSourceContext();
            IContext targetContext = mapping.getTargetContext();

            sourceIndex = new ArrayList<Integer>();
            targetIndex = new ArrayList<Integer>();

            defautlMappings = mapping;

            spsmMapping = mappingFactory.getContextMappingInstance(sourceContext, targetContext);

            spsmMapping.setSimilarity(computeSimilarity(mapping));
            log.info("Similarity: " + spsmMapping.getSimilarity());

            if (isRelated(sourceContext.getRoot(), targetContext.getRoot(), IMappingElement.EQUIVALENCE) ||
                    isRelated(sourceContext.getRoot(), targetContext.getRoot(), IMappingElement.LESS_GENERAL) ||
                    isRelated(sourceContext.getRoot(), targetContext.getRoot(), IMappingElement.MORE_GENERAL)) {

                setStrongestMapping(sourceContext.getRoot(), targetContext.getRoot());
                filterMappingsOfChildren(sourceContext.getRoot(), targetContext.getRoot(), IMappingElement.EQUIVALENCE);
                filterMappingsOfChildren(sourceContext.getRoot(), targetContext.getRoot(), IMappingElement.MORE_GENERAL);
                filterMappingsOfChildren(sourceContext.getRoot(), targetContext.getRoot(), IMappingElement.LESS_GENERAL);
            }

            return spsmMapping;
        }

        return mapping;
    }
576040
public static List<Match> search(Match m, Pattern pattern)
	{
		assert pattern.getStartingClass().isAssignableFrom(m.get(0).getModelInterface());

		return searchRecursive(m, pattern.getConstraints(), 0);
	}
274718
private int getMatchingPoint(String pattern, String itemName) {
        int index = pattern.indexOf('*');
        if (index == -1) {
            return -1;
        }

        String firstPart = pattern.substring(0, index);
        int indexFirstPart = itemName.indexOf(firstPart, 0);
        if (indexFirstPart == -1) {
            return -1;
        }

        String secondPart = pattern.substring(index + 1);
        int indexSecondPart = itemName.indexOf(secondPart, index + 1);
        if (indexSecondPart == -1) {
            return -1;
        }

        return firstPart.length() + secondPart.length();
    }
1279243
public static String get(String regex, CharSequence content, int groupIndex) {
		if (null == content || null == regex) {
			return null;
		}

		// Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
		final Pattern pattern = PatternPool.get(regex, Pattern.DOTALL);
		return get(pattern, content, groupIndex);
	}
966437
public static int indexAny(String target, Integer fromIndex, List<String> indexWith) {
		if (isNull(target)) {
			return INDEX_NONE_EXISTS;
		}
		
		return matcher(target).indexs(fromIndex, checkNotNull(indexWith).toArray(new String[indexWith.size()]));
	}
1039720
private List<Match> expandWithIgnoreItem(int docId, Match match) {
    List<Match> list = new ArrayList<>();
    try {
      Set<Integer> ignoreList = ignoreItem.getFullEndPositionList(docId,
          match.endPosition);
      if (ignoreList != null) {
        for (Integer endPosition : ignoreList) {
          list.add(new Match(match.startPosition, endPosition));
        }
      }
    } catch (IOException e) {
      log.debug(e);
    }
    return list;
  }