Ejemplo n.º 1
0
 public void fillBody(String newMessage) {
   info("Fill body: [" + StringUtils.left(newMessage, 100) + "...]");
   getMainBodyArea().clear();
   for (String token : Splitter.fixedLength(100).split(newMessage)) {
     getMainBodyArea().sendKeys(token);
   }
 }
Ejemplo n.º 2
0
 private void fillTopicBody(String body) {
   info("Filling topic body: [" + StringUtils.left(body, 100) + "...]");
   getMainBodyArea().clear();
   for (String token : Splitter.fixedLength(100).split(body)) {
     getMainBodyArea().sendKeys(token);
   }
 }
Ejemplo n.º 3
0
  /**
   * @Title: resolveCinema @Description: TODO
   *
   * @param @param cinema
   * @return void
   * @throws
   */
  public void resolveCinema(Cinema cinema) {
    String cityCode = StringUtils.left(cinema.getCinemaCode().toString(), 4);
    String provinceCode = StringUtils.left(cityCode, 2);
    String cityString = StringUtils.rightPad(cityCode, cityCode.length() + 2, "0");
    CityCode province =
        generalDAO.findById(
            CityCode.class, StringUtils.rightPad(provinceCode, provinceCode.length() + 4, "0"));
    CityCode city = generalDAO.findById(CityCode.class, cityString);
    if (province != null && city != null) {
      String proName = province.getName() + province.getSuffix();
      String cityName = city.getName() + city.getSuffix();

      String newName = removeSymbolList(cinema.getCinemaName());
      if (proName.equals(cityName)) {
        one(province, cinema, newName);
      } else {
        two(province, city, cinema, newName);
      }
    }
  }
Ejemplo n.º 4
0
 @BotCommand
 public String len(String values) {
   char first = StringUtils.left(values, 1).charAt(0);
   char last = StringUtils.right(values, 1).charAt(0);
   return String.format(
       "%d char / %d bytes ('%s' %s ~ '%s' %s)",
       values.length(),
       values.getBytes(Charset.forName("UTF-8")).length,
       first,
       Character.getName(first),
       last,
       Character.getName(last));
 }
Ejemplo n.º 5
0
  public static void main(String[] args) {
    // StringUtils
    print(StringUtils.abbreviate("javajava", 10));
    print(StringUtils.repeat("java", 20));
    print(StringUtils.leftPad("java", 10));
    print(StringUtils.left("long-long-long-java-string", 10));

    // ArrayUtils
    // Add element to an array
    int[] ids = new int[] {1, 3, 5, 7};
    print(Arrays.toString(ArrayUtils.add(ids, 9)));

    // StringUtils
    // Get a string by joining all elements
    print(StringUtils.join("a", "b", "c"));
  }
Ejemplo n.º 6
0
  /**
   * 현재 사용자가 선호하는 언어를 갱신한다.
   *
   * <p>쿠키나 Accept-Language HTTP 헤더에 선호하는 언어가 설정되어 있는 경우, 그것을 현재 로그인한 사용자가 선호하는 언어로 설정한다.
   */
  public static void updatePreferredLanguage() {
    Http.Request request = Http.Context.current().request();
    User user = UserApp.currentUser();

    if (user.isAnonymous()) {
      return;
    }

    if (request.acceptLanguages().isEmpty() && request.cookie(Play.langCookieName()) == null) {
      return;
    }

    String code = StringUtils.left(Http.Context.current().lang().code(), 255);

    if (!code.equals(user.lang)) {
      user.lang = code;
      user.update();
    }
  }
Ejemplo n.º 7
0
 private static <T> Pair<T, BoundType> parseLowerBoundary(
     String lower, Function<String, T> parser) {
   BoundType bound;
   String value;
   if (lower.length() > 1) {
     String boundChar = StringUtils.left(lower, 1);
     if ("(".equals(boundChar) || "[".equals(boundChar)) {
       bound = BoundType.CLOSED;
       value = StringUtils.substring(lower, 1);
     } else if (")".equals(boundChar) || "]".equals(boundChar)) {
       bound = BoundType.OPEN;
       value = StringUtils.substring(lower, 1);
     } else {
       bound = BoundType.CLOSED;
       value = lower;
     }
   } else {
     bound = BoundType.CLOSED;
     value = lower;
   }
   return Pair.of(parser.apply(value), bound);
 }
Ejemplo n.º 8
0
 public void fillCodeReviewFields(CodeReview codeReview) {
   info("Filling code review title: [" + StringUtils.left(codeReview.getTitle(), 100) + "...]");
   getSubjectField().sendKeys(codeReview.getTitle());
   fillBody(codeReview.getContent());
 }
Ejemplo n.º 9
0
 private String trimValue(Object param) {
   return maxPropLen <= 0 ? param.toString() : StringUtils.left(param.toString(), maxPropLen);
 }