Gets the match.

@param content the content
@return the match
@throws IOException Signals that an I/O exception has occurred.
185283
public String getMatch(final byte[] content) throws IOException {
		final ByteBuffer buf = readBuffer(content);
		if (buf == null) {
			return null;
		}
		buf.position(0);
		final boolean matches = match(buf);
		if (matches) {
			final int subLen = this.subEntries.size();
			final String myMimeType = getMimeType();
			if (subLen > 0) {
				String mtype = null;
				for (int k = 0; k < subLen; k++) {
					final MagicMimeEntry me = this.subEntries.get(k);
					mtype = me.getMatch(content);
					if (mtype != null) {
						return mtype;
					}
				}
				if (myMimeType != null) {
					return myMimeType;
				}
			} else {
				return myMimeType;
			}
		}

		return null;
	}
394890
int get() throws IOException {
		int c = in.read();

		if (c >= ' ' || c == '\n' || c == EOF) {
			return c;
		}

		if (c == '\r') {
			return '\n';
		}
		
		return ' ';
	}
1363595
@Override
    public int matches(Replaceable text,
            int[] offset,
            int limit,
            boolean incremental) {

        if (offset[0] == limit) {
            // Strings, if any, have length != 0, so we don't worry
            // about them here.  If we ever allow zero-length strings
            // we much check for them here.
            if (contains(UnicodeMatcher.ETHER)) {
                return incremental ? U_PARTIAL_MATCH : U_MATCH;
            } else {
                return U_MISMATCH;
            }
        } else {
            if (strings.size() != 0) { // try strings first

                // might separate forward and backward loops later
                // for now they are combined

                // TODO Improve efficiency of this, at least in the forward
                // direction, if not in both.  In the forward direction we
                // can assume the strings are sorted.

                boolean forward = offset[0] < limit;

                // firstChar is the leftmost char to match in the
                // forward direction or the rightmost char to match in
                // the reverse direction.
                char firstChar = text.charAt(offset[0]);

                // If there are multiple strings that can match we
                // return the longest match.
                int highWaterLength = 0;

                for (String trial : strings) {
                    //if (trial.length() == 0) {
                    //    return U_MATCH; // null-string always matches
                    //}
                    // assert(trial.length() != 0); // We ensure this elsewhere

                    char c = trial.charAt(forward ? 0 : trial.length() - 1);

                    // Strings are sorted, so we can optimize in the
                    // forward direction.
                    if (forward && c > firstChar) break;
                    if (c != firstChar) continue;

                    int length = matchRest(text, offset[0], limit, trial);

                    if (incremental) {
                        int maxLen = forward ? limit-offset[0] : offset[0]-limit;
                        if (length == maxLen) {
                            // We have successfully matched but only up to limit.
                            return U_PARTIAL_MATCH;
                        }
                    }

                    if (length == trial.length()) {
                        // We have successfully matched the whole string.
                        if (length > highWaterLength) {
                            highWaterLength = length;
                        }
                        // In the forward direction we know strings
                        // are sorted so we can bail early.
                        if (forward && length < highWaterLength) {
                            break;
                        }
                        continue;
                    }
                }

                // We've checked all strings without a partial match.
                // If we have full matches, return the longest one.
                if (highWaterLength != 0) {
                    offset[0] += forward ? highWaterLength : -highWaterLength;
                    return U_MATCH;
                }
            }
            return super.matches(text, offset, limit, incremental);
        }
    }
811955
protected EofMatch findEof(Match matches[]) {
        EofMatch ourEof = null;
        for (int i = 0; i < matches.length; i++) {
            if (matches[i] instanceof EofMatch)
                ourEof = (EofMatch) matches[i];
        }

        if (ourEof == null) {
            // Have to create our own
            ourEof = new EofMatch();
        }

        return ourEof;
    }
1039757
private int get() throws IOException {
        int c = theLookahead;
        theLookahead = EOF;
        if (c == EOF) {
            c = inputStream.read();
        }
        if (c >= ' ' || c == '\n' || c == EOF) {
            return c;
        }
        if (c == '\r') {
            return '\n';
        }
        return ' ';
    }
1161116
private void findMatches(Match match, int n) throws IOException {
    if (n > 0) {
      int largestMatchingEndPosition = match.endPosition();
      Set<Integer> list = ignoreItem.getFullEndPositionList(spans.docID(),
          match.endPosition());
      // try to find matches with existing queue
      if (!queueSpans.isEmpty()) {
        Match span;
        for (int i = 0; i < queueSpans.size(); i++) {
          span = queueSpans.get(i);
          if (match.endPosition() == span.startPosition()
              || (list != null && list.contains(span.startPosition()))) {
            findMatches(new Match(match.startPosition(), span.endPosition()),
                (n - 1));
            largestMatchingEndPosition = Math.max(largestMatchingEndPosition,
                span.endPosition());
          }
        }
      }
      // extend queue if necessary and possible
      while (!lastSpan && (largestMatchingEndPosition >= lastStartPosition)) {
        if (spans.nextStartPosition() == NO_MORE_POSITIONS) {
          lastSpan = true;
        } else {
          Match span = new Match(spans.startPosition(), spans.endPosition());
          queueSpans.add(span);
          lastStartPosition = spans.startPosition();
          // check if this provides new match
          if (match.endPosition() == span.startPosition()
              || (list != null && list.contains(span.startPosition()))) {
            findMatches(new Match(match.startPosition(), span.endPosition()),
                (n - 1));
            largestMatchingEndPosition = Math.max(largestMatchingEndPosition,
                span.endPosition());
          }
        }
      }
    } else {
      // only unique spans
      if (!queueMatches.contains(match)) {
        queueMatches.add(match);
      }
    }
  }
865349
public Vector query(String content)
    {
        if (content == null || content.length() == 0) return null;
        List<Term> termList = NotionalTokenizer.segment(content);
        Vector result = new Vector(dimension());
        int n = 0;
        for (Term term : termList)
        {
            Vector vector = wordVectorModel.vector(term.word);
            if (vector == null)
            {
                continue;
            }
            ++n;
            result.addToSelf(vector);
        }
        if (n == 0)
        {
            return null;
        }
        result.normalize();
        return result;
    }
879272
def matches_content?(element)
      return true if @content.nil?

      case @content
      when String
        element.content == @content
      when Regexp
        element.content =~ @content
      end
    end
731593
public static function detectByContent($content)
    {
        if ( ! class_exists('finfo') || ! is_string($content)) {
            return null;
        }
        try {
            $finfo = new finfo(FILEINFO_MIME_TYPE);

            return $finfo->buffer($content) ?: null;
        // @codeCoverageIgnoreStart
        } catch( ErrorException $e ) {
            // This is caused by an array to string conversion error.
        }
    }
769957
public char match(ISense source, ISense target) throws MatcherLibraryException {
        List<ISense> sourceList = getAncestors(source, depth);
        List<ISense> targetList = getAncestors(target, depth);
        targetList.retainAll(sourceList);
        if (targetList.size() > 0)
            return IMappingElement.EQUIVALENCE;
        else
            return IMappingElement.IDK;
    }
1132916
@Override
    public int read() throws IOException {
        abortIfNeeded();
        int b = in.read();
        if (b == 'x' && !hasRemovedNamespace) {
            lookAheadData[0] = (byte)b;
            in.mark(lookAheadData.length);
            int bytesRead = in.read(lookAheadData, 1, lookAheadData.length - 1);
            in.reset();

            String string = new String(lookAheadData, 0, bytesRead + 1, StringUtils.UTF8);

            int numberCharsMatched = matchXmlNamespaceAttribute(string);
            if (numberCharsMatched > 0) {
                for (int i = 0; i < numberCharsMatched - 1; i++) {
                    in.read();
                }
                b = in.read();
                hasRemovedNamespace = true;
            }
        }

        return b;
    }
321164
private ContentData matchBytes(byte[] bytes, int prevOffset, int level, ContentData contentData) {
		int offset = this.offset;
		if (offsetInfo != null) {
			// offset can be null if we run out of bytes
			Integer maybeOffset = offsetInfo.getOffset(bytes);
			if (maybeOffset == null) {
				return null;
			}
			offset = maybeOffset;
		}
		if (addOffset) {
			offset = prevOffset + offset;
		}
		boolean required = (testValue == null && formatter != null);
		Object val = matcher.extractValueFromBytes(offset, bytes, required);
		if (val == null) {
			return null;
		}
		if (testValue != null) {
			MutableOffset mutableOffset = new MutableOffset(offset);
			val = matcher.isMatch(testValue, andValue, unsignedType, val, mutableOffset, bytes);
			if (val == null) {
				return null;
			}
			offset = mutableOffset.offset;
		}

		if (contentData == null) {
			contentData = new ContentData(name, mimeType, level);
			// default is a child didn't match, set a partial so the matcher will keep looking
			contentData.partial = true;
		}
		if (formatter != null) {
			if (clearFormat) {
				contentData.sb.setLength(0);
			}
			// if we are appending and need a space then prepend one
			if (formatSpacePrefix && contentData.sb.length() > 0) {
				contentData.sb.append(' ');
			}
			matcher.renderValue(contentData.sb, val, formatter);
		}
		logger.trace("matched data: {}: {}", this, contentData);

		if (children == null) {
			// no children so we have a full match and can set partial to false
			contentData.partial = false;
		} else {
			// run through the children to add more content-type details
			boolean allOptional = true;
			for (MagicEntry entry : children) {
				if (!entry.isOptional()) {
					allOptional = false;
				}
				// goes recursive here
				entry.matchBytes(bytes, offset, level + 1, contentData);
				// we continue to match to see if we can add additional children info to the name
			}
			if (allOptional) {
				contentData.partial = false;
			}
		}

		/*
		 * Now that we have processed this entry (either with or without children), see if we still need to annotate the
		 * content information.
		 * 
		 * NOTE: the children will have the first opportunity to set this which makes sense since they are the most
		 * specific.
		 */
		if (name != MagicEntryParser.UNKNOWN_NAME && contentData.name == MagicEntryParser.UNKNOWN_NAME) {
			contentData.name = name;
		}
		/*
		 * Set the mime-type if it is not set already or if we've gotten more specific in the processing of a pattern
		 * and determine that it's actually a different type so we can override the previous mime-type. Example of this
		 * is Adobe Illustrator which looks like a PDF but has extra stuff in it.
		 */
		if (mimeType != null && (contentData.mimeType == null || level > contentData.mimeTypeLevel)) {
			contentData.mimeType = mimeType;
			contentData.mimeTypeLevel = level;
		}
		return contentData;
	}
821761
private boolean findMatches() throws IOException {
    Boolean status = _findMatches();
    while (!(status || (currentPosition == NO_MORE_POSITIONS))) {
      status = _findMatches();
    }
    return status;
  }
772365
public static String decode(String content) {

		// return content;
		if (content == null || content.length() == 0) {
			return content;
		}
		else {
			byte[] decodeQueryString = org.apache.commons.codec.binary.Base64.decodeBase64(content);
			return new String(decodeQueryString);
		}

	}
157152
protected Match<?> match() {
        Match<?> m = result().getMatch();
        if (m == null) {
            throw new IllegalStateException("Match failed");
        }
        return m;
    }
1047610
private boolean findMatches() throws IOException {
    // check for something in queue of matches
    if (!queueMatches.isEmpty()) {
      return true;
    } else {
      while (true) {
        // try to get something in queue of spans
        if (queueSpans.isEmpty() && !collectSpan()) {
          return false;
        }
        // try to get matches with first span in queue
        Match firstMatch = queueSpans.get(0);
        queueSpans.remove(0);
        // create a list of matches with same startposition as firstMatch
        List<Match> matches = new ArrayList<>();
        matches.add(firstMatch);
        // try to collect spans until lastStartPosition not equal to
        // startposition of firstMatch
        while (!lastSpan && (lastStartPosition == firstMatch.startPosition())) {
          collectSpan();
        }
        while (!queueSpans.isEmpty() && (queueSpans.get(0)
            .startPosition() == firstMatch.startPosition())) {
          matches.add(queueSpans.get(0));
          queueSpans.remove(0);
        }
        // construct all matches for this startposition
        for (Match match : matches) {
          // only unique spans
          if (!queueMatches.contains(match)) {
            queueMatches.add(match);
          }
        }
        // check for something in queue of matches
        if (!queueMatches.isEmpty()) {
          return true;
        }
      }
    }
  }
643300
public String match(CharSequence text)
    {
        try
        {
            if (text.length() == 0)
            {
                if (acceptEmpty)
                {
                    return "";
                }
                else
                {
                    throw new SyntaxErrorException("empty string not accepted");
                }
            }
            InputReader reader = Input.getInstance(text);
            int rc = match(reader);
            if (rc == 1 && reader.read() == -1)
            {
                return reader.getString();
            }
            else
            {
                throw new SyntaxErrorException("syntax error"
                        + "\n"
                        + reader.getLineNumber() + ": " + reader.getLine()
                        + "\n"
                        + pointer(reader.getColumnNumber() + 2));
            }
        }
        catch (IOException ex)
        {
            throw new IllegalArgumentException("can't happen");
        }
    }