Пример #1
0
  @Override
  public final boolean matches(final MatchInfo matchInfo)
      throws UnknownHostException, SocketException, MalformedURLException {
    Optional<Boolean> overridden = tryOverrideValidation(matchInfo);
    if (overridden.isPresent()) {
      return overridden.get();
    } else {
      int uriPort = matchInfo.getPort();
      if (uriPort != MatchInfo.ANY_PORT && this.port > 0 && uriPort != this.port) {
        return false;
      }

      if (this.pathRegex != null && matchInfo.getPath() != MatchInfo.ANY_PATH) {
        Matcher matcher = Pattern.compile(this.pathRegex).matcher(matchInfo.getPath());
        if (!matcher.matches()) {
          LOGGER.debug("pathRegex '{}' is not matching '{}'", this.pathRegex, matchInfo.getPath());
          return false;
        }
      }
      return true;
    }
  }
Пример #2
0
  public static MatchInfo deserialize(String serialized) {
    String[] serTokens = serialized.trim().split("#");
    MatchInfo mI = new MatchInfo();

    mI.matchId = serTokens[0];
    mI.northPlayerId = serTokens[1];
    mI.northPlayerName = serTokens[2];
    mI.northPlayerRating = serTokens[3];
    mI.northPlayerRD = serTokens[4];
    mI.southPlayerId = serTokens[5];
    mI.southPlayerName = serTokens[6];
    mI.southPlayerRating = serTokens[7];
    mI.southPlayerRD = serTokens[8];
    mI.state = serTokens[9];
    mI.moveIndex = serTokens[10];
    mI.userIdOfWhoseTurnItIs = serTokens[11];
    mI.startDate = serTokens[12];
    mI.action = serTokens[13];

    return mI;
  }