Validates the component to ensure it meets the CPE 2.3 specification of
allowed values.

@param value the value to validate
@return the validation status given value;
@see us.springett.parsers.cpe.util.Status#isValid()
421409
public static Status component(String value) {
        if (value != null && !value.isEmpty()) {
            if ("\\-".equals(value)) {
                return Status.SINGLE_QUOTED_HYPHEN;
            }
            for (int x = 0; x < value.length(); x++) {
                char c = value.charAt(x);
                if (c == '?' && x > 0 && x < value.length() - 1
                        && !((value.charAt(x - 1) == '?' || value.charAt(x - 1) == '*' || value.charAt(x - 1) == '\\')
                        || (x < value.length() - 1 && (value.charAt(x + 1) == '?' || value.charAt(x + 1) == '*')))) {
                    return Status.UNQUOTED_QUESTION_MARK;
                } else if (Character.isWhitespace(c)) {
                    return Status.WHITESPACE;
                } else if (c < 32 || c > 127) {
                    return Status.NON_PRINTABLE;
                } else if (c == '*' && x != 0 && value.charAt(x - 1) == '*') {
                    return Status.ASTERISK_SEQUENCE;
                } else if (c == '*' && !((x == 0 || x == value.length() - 1)
                        || (x > 0 && '\\' == value.charAt(x - 1)))) {
                    return Status.UNQUOTED_ASTERISK;
                }
            }
            return Status.VALID;
        }
        return Status.EMPTY;
    }
1095753
public void containsValue(@NullableDecl Object value) {
    check("values()").that(actual().values()).contains(value);
  }
1149525
@Override
    public ValidationResult validate(@Nullable final Object value) {
        if (value instanceof ObjectId) {
            return new ValidationResult.ValidationPassed();
        } else {
            return new ValidationResult.ValidationFailed(String.valueOf(value) + " is not a valid ObjectId!");
        }
    }
947160
static void validateHeaderValue(CharSequence value) {
        if (value == null) {
            throw new NullPointerException("value");
        }
        for (int i = 0; i < value.length(); i ++) {
            char c = value.charAt(i);
            if (c == 0) {
                throw new IllegalArgumentException(
                        "value contains null character: " + value);
            }
        }
    }
438862
protected void addValidValue(String value)
	{
		if(value!=null && !value.isEmpty())
			validValues.add(value.toLowerCase());
	}
1362314
public static boolean isValid(final String value) {
        if (value == null) {
            return true;
        }
        final String uuidPattern = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-" + "[0-9a-f]{4}-[0-9a-f]{12}$";
        return Pattern.matches(uuidPattern, value);
    }
1259475
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    if (pvalue == null) {
      return true;
    }
    try {
      final String fieldCheckValue =
          BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, fieldCheckName);
      final String fieldCompareValue =
          BeanPropertyReaderUtil.getNullSaveStringProperty(pvalue, fieldCompareName);
      if (StringUtils.isNotEmpty(fieldCheckValue)
          && StringUtils.equals(valueCompare, fieldCompareValue)) {
        switchContext(pcontext);
        return false;
      }
      return true;
    } catch (final Exception ignore) {
      switchContext(pcontext);
      return false;
    }
  }
376976
public static FormValidation validateNonNegativeInteger(String value) {
        try {
            if(Integer.parseInt(value)<0)
                return error(hudson.model.Messages.Hudson_NotANonNegativeNumber());
            return ok();
        } catch (NumberFormatException e) {
            return error(hudson.model.Messages.Hudson_NotANumber());
        }
    }
672337
public static Status formattedString(String value) {
        boolean result = true;
        try {
            Cpe23PartIterator instance;
            try {
                instance = new Cpe23PartIterator(value);
            } catch (CpeParsingException ex) {
                LOG.warn("The CPE (" + value + ") is invalid as it is not in the formatted string format");
                return Status.INVALID;
            }
            try {
                //part
                Part.getEnum(instance.next());
            } catch (CpeParsingException ex) {
                LOG.warn("The CPE (" + value + ") is invalid as it has an invalid part attribute");
                return Status.INVALID_PART;
            }
            Status status;
            //vendor
            status = Validate.component(instance.next());
            if (!status.isValid()) {
                LOG.warn("The CPE (" + value + ") has an invalid vendor - " + status.getMessage());
                return status;
            }
            //product
            status = Validate.component(instance.next());
            if (!status.isValid()) {
                LOG.warn("The CPE (" + value + ") has an invalid product - " + status.getMessage());
                return status;
            }
            //version
            status = Validate.component(instance.next());
            if (!status.isValid()) {
                LOG.warn("The CPE (" + value + ") has an version version - " + status.getMessage());
                return status;
            }
            //update
            status = Validate.component(instance.next());
            if (!status.isValid()) {
                LOG.warn("The CPE (" + value + ") has an invalid update - " + status.getMessage());
                return status;
            }
            //edition
            status = Validate.component(instance.next());
            if (!status.isValid()) {
                LOG.warn("The CPE (" + value + ") has an invalid edition - " + status.getMessage());
                return status;
            }
            //language
            status = Validate.component(instance.next());
            if (!status.isValid()) {
                LOG.warn("The CPE (" + value + ") has an invalid language - " + status.getMessage());
                return status;
            }
            //swEdition
            status = Validate.component(instance.next());
            if (!status.isValid()) {
                LOG.warn("The CPE (" + value + ") has an invalid swEdition - " + status.getMessage());
                return status;
            }
            //targetSw
            status = Validate.component(instance.next());
            if (!status.isValid()) {
                LOG.warn("The CPE (" + value + ") has an invalid targetSw - " + status.getMessage());
                return status;
            }
            //targetHw
            status = Validate.component(instance.next());
            if (!status.isValid()) {
                LOG.warn("The CPE (" + value + ") has an invalid targetHw - " + status.getMessage());
                return status;
            }
            //other
            status = Validate.component(instance.next());
            if (!status.isValid()) {
                LOG.warn("The CPE (" + value + ") has an invalid other attribute - " + status.getMessage());
                return status;
            }
            if (instance.hasNext()) {
                LOG.warn(Status.TOO_MANY_ELEMENTS.getMessage());
                return Status.TOO_MANY_ELEMENTS;
            }
        } catch (NoSuchElementException ex) {
            LOG.warn(Status.TOO_FEW_ELEMENTS.getMessage());
            return Status.TOO_FEW_ELEMENTS;
        }
        return Status.VALID;
    }
132424
public static boolean isValid(@Nullable final String booleanStr) {
        if (StringUtils.isBlank(booleanStr)) {
            return false;
        }
        final String lowerCaseBoolean = getLowerCaseString(booleanStr);
        return lowerCaseBoolean.equals(BooleanValues.TRUE) || lowerCaseBoolean.equals(BooleanValues.FALSE);
    }
1181138
public boolean isValid(String value) {
    if (value == null) {
      return false;
    }
    for (int i = 0; i < patterns.length; i++) {
      if (patterns[i].matcher(value).matches()) {
        return true;
      }
    }
    return false;
  }
294
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = StringUtils.strip(Objects.toString(pvalue, null), stripcharacters);

    return StringUtils.isNotEmpty(valueAsString);
  }
1324080
public boolean isValid(final CharSequence value, final ConstraintValidatorContext context) {
    if (value == null) {
      return true;
    }

    final String valueAsString = value.toString();
    String digitsAsString;
    char checkDigit;
    try {
      digitsAsString = this.extractVerificationString(valueAsString);
      checkDigit = this.extractCheckDigit(valueAsString);
    } catch (final IndexOutOfBoundsException e) {
      return false;
    }
    digitsAsString = this.stripNonDigitsIfRequired(digitsAsString);

    List<Integer> digits;
    try {
      digits = this.extractDigits(digitsAsString);
    } catch (final NumberFormatException e) {
      return false;
    }

    return this.isCheckDigitValid(digits, checkDigit);
  }
26201
public static Object checkValue(Object value) {
        if (null == value) return null;
        if (value instanceof Tag) return ((Tag)value).getName(); // name instead of ordinal to make decoding easier
        Object result = value;
        if (result instanceof GString) result = value.toString();
        if (result instanceof BaseAttribute) {
            if (log.isLoggable(Level.WARNING)) log.warning("An Attribute may not itself contain an attribute as a value. Assuming you forgot to call getValue().");
            result = checkValue((((BaseAttribute) value).getValue()));
        }
        boolean ok = false;
        for (Class type : SUPPORTED_VALUE_TYPES ) {
            if (type.isAssignableFrom(result.getClass())) { ok = true; break; }
        }
        if (!ok) {
            throw new IllegalArgumentException("Attribute values of this type are not allowed: " + result.getClass().getSimpleName());
        }
        return result;
    }
309386
@Override
    public ValidationResult validate(Object value) {
        if (value instanceof org.joda.time.DateTime && value.toString().endsWith("Z")) {
            return new ValidationResult.ValidationPassed();
        } else {
            return new ValidationResult.ValidationFailed(value + " is not a valid date!");
        }
    }
819923
@Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        List<String> emailAddresses = EmailAddressesParser.parse(value);
        List<String> badAddresses = null;
        for (String ea : emailAddresses) {
            if (!EMAIL_VALIDATOR.isValid(ea, null)) {
                if (badAddresses == null) {
                    badAddresses = new LinkedList<String>();
                }

                badAddresses.add(ea);
            }
        }

        if (badAddresses != null) {
            context.disableDefaultConstraintViolation();
            context.buildConstraintViolationWithTemplate(MessageFormat.format(constraintAnnotation.message(),
                                                                              StringUtils.join(badAddresses, ", ")))
                   .addConstraintViolation();
        }
        return (badAddresses == null);
    }
455693
@Override
  public final boolean isValid(final Object pvalue, final ConstraintValidatorContext pcontext) {
    final String valueAsString = Objects.toString(pvalue, null);

    if (StringUtils.isEmpty(valueAsString)) {
      // empty field is ok
      return true;
    }
    return allowDin5008 && valueAsString.matches(PHONE_NUMBER_DIN5008) //
        || allowE123 && valueAsString.matches(PHONE_NUMBER_E123) //
        || allowUri && valueAsString.matches(PHONE_NUMBER_URI) //
        || allowMs && valueAsString.matches(PHONE_NUMBER_MS) //
        || allowCommon && valueAsString.matches(PHONE_NUMBER_COMMON);
  }