Package org.apache.commons.lang.math

Examples of org.apache.commons.lang.math.NumberRange


          switch(ctn.getComparator()) {
            case BETWEEN: {
              Object min, max;
              if(checkValue instanceof NumberRange) {
                final NumberRange range = (NumberRange) checkValue;
                min = range.getMinimumNumber();
                max = range.getMaximumNumber();
              }
              else if(checkValue instanceof DateRange) {
                final DateRange range = (DateRange) checkValue;
                min = range.getStartDate();
                max = range.getEndDate();
              }
              else {
                // presume an object array
                final Object[] oarr = (Object[]) checkValue;
                min = oarr[0];
View Full Code Here


        if(checkValue instanceof NumberRange) {
          if(actualValue instanceof Number == false) {
            return false;
          }
          final Number number = (Number) actualValue;
          final NumberRange range = (NumberRange) checkValue;
          return range.containsNumber(number);
        }
        else if(checkValue instanceof DateRange) {
          if(actualValue instanceof Date == false) {
            return false;
          }
          final Date date = (Date) actualValue;
          final DateRange range = (DateRange) checkValue;
          return range.includes(date);
        }
        return false;
      }
      case IS: {
        if(checkValue instanceof DBType == false) {
View Full Code Here

          switch(ctn.getComparator()) {
          case BETWEEN: {
            Object min, max;
            if(checkValue instanceof NumberRange) {
              final NumberRange range = (NumberRange) checkValue;
              min = range.getMinimumNumber();
              max = range.getMaximumNumber();
            }
            else if(checkValue instanceof DateRange) {
              final DateRange range = (DateRange) checkValue;
              min = range.getStartDate();
              max = range.getEndDate();
            }
            else {
              // presume an object array
              final Object[] oarr = (Object[]) checkValue;
              min = oarr[0];
View Full Code Here

  public static String pickWhiteSpaces(Integer length) {
    return RandomStringUtils.random(length, "\t\n\r");
  }

  public static String pickDigits(Integer length) {
    length = getValidLength(length, new NumberRange(1,10));
    return RandomStringUtils.randomNumeric(length);
  }
View Full Code Here

    return StringUtils.join(result, ".");
  }


  public static String email(Integer emailLength, String domain) {
    emailLength = getValidLength(emailLength, new NumberRange(3, 40));
    domain = domain == null ? "example.org" : domain;
    return word(emailLength - domain.length() - 1) + "@" + domain;
  }
View Full Code Here

    return email(null, null);
  }

  public static String word(Integer length) {
      String word = null;
        length = getValidLength(length, new NumberRange(3, 20));
     
      if (length == 1) {
          word = pickChar();
      } else {
          word = pickCollection(Dictionary.getWordsByLength(length));
View Full Code Here

  public static String word() {
    return word(null);
  }

  public static String firstName(Integer length, Gender gender) {
    length = getValidLength(length, new NumberRange(3, 10));
    return gender.equals(Gender.MALE) ?
        pickCollection(Dictionary.getMaleNameByLength(length)) : pickCollection(Dictionary.getFemaleNameByLength(length));
  }
View Full Code Here

  public static String firstName(Gender gender) {
    return firstName(null, gender);
  }

  public static String lastName(Integer length) {
    length = getValidLength(length, new NumberRange(3, 10));
    return pickCollection(Dictionary.getLastNameByLength(length));
  }
View Full Code Here

   
        matcher = RANGE_QUANTIFIERS.matcher(pattern);
        if (matcher.find()) {
            Integer quantifierStart = Integer.valueOf(matcher.group(2));
            Integer quantifierEnd = Integer.valueOf(matcher.group(3));
            return parseQuantified(matcher.group(1), new Quantifier(new NumberRange(quantifierStart, quantifierEnd)));
        }
       
        matcher = NUMBER_QUANTIFIER.matcher(pattern);
        if (matcher.find()) {
          return parseQuantified(matcher.group(1), new Quantifier(Integer.valueOf(matcher.group(2))));
View Full Code Here

        // 4. check if all items are found
        col = broker.getCollectionByQuery(query);
        assertEquals("size of collection should be four", 4, col.size());

        NumberRange range = new NumberRange(a1.getArticleId(), a5.getArticleId());
        Iterator iter = col.iterator();
        while (iter.hasNext())
        {
            InterfaceArticle testIa = (InterfaceArticle) iter.next();
            assertEquals("should be same value", name, testIa.getArticleName());
            Integer id = testIa.getArticleId();
            assertTrue("Id should be a number of the generated articles", range.containsInteger(id));
        }

        // read one item only
        // 1. set query start equals end
        query.setStartAtIndex(4);
        query.setEndAtIndex(4);

        // 2. check if only one item is found
        OJBIterator ojbIter = (OJBIterator)broker.getIteratorByQuery(query);
        assertEquals("size of iterator should be one", 1, ojbIter.size());
        InterfaceArticle test4 = (InterfaceArticle) ojbIter.next();
        ojbIter.releaseDbResources();
        assertTrue("Id should be a number of the generated articles", range.containsInteger(test4.getArticleId()));
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.lang.math.NumberRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.