类javax.xml.bind.ValidationException源码实例Demo

下面列出了怎么用javax.xml.bind.ValidationException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spring-analysis-note   文件: Jaxb2Marshaller.java
/**
 * Convert the given {@code JAXBException} to an appropriate exception
 * from the {@code org.springframework.oxm} hierarchy.
 * @param ex {@code JAXBException} that occurred
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertJaxbException(JAXBException ex) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("JAXB validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		return new MarshallingFailureException("JAXB marshalling exception", ex);
	}
	else if (ex instanceof UnmarshalException) {
		return new UnmarshallingFailureException("JAXB unmarshalling exception", ex);
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown JAXB exception", ex);
	}
}
 
源代码2 项目: java-technology-stack   文件: Jaxb2Marshaller.java
/**
 * Convert the given {@code JAXBException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * @param ex {@code JAXBException} that occurred
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertJaxbException(JAXBException ex) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("JAXB validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		return new MarshallingFailureException("JAXB marshalling exception", ex);
	}
	else if (ex instanceof UnmarshalException) {
		return new UnmarshallingFailureException("JAXB unmarshalling exception", ex);
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown JAXB exception", ex);
	}
}
 
源代码3 项目: spring4-understanding   文件: Jaxb2Marshaller.java
/**
 * Convert the given {@code JAXBException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * @param ex {@code JAXBException} that occured
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertJaxbException(JAXBException ex) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("JAXB validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		return new MarshallingFailureException("JAXB marshalling exception", ex);
	}
	else if (ex instanceof UnmarshalException) {
		return new UnmarshallingFailureException("JAXB unmarshalling exception", ex);
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown JAXB exception", ex);
	}
}
 
源代码4 项目: sis   文件: AbstractDerivedCRS.java
/**
 * Invoked by JAXB after all elements have been unmarshalled. At this point we should have the
 * coordinate system (CS). The CS information is required by {@code createConversionFromBase(…)}
 * in order to create a {@link MathTransform} with correct axis swapping and unit conversions.
 */
private void afterUnmarshal(Unmarshaller unmarshaller, Object parent) throws ValidationException {
    String property = "conversion";
    if (conversionFromBase != null) {
        final SingleCRS baseCRS = CC_Conversion.setBaseCRS(conversionFromBase, null);  // Clear the temporary value now.
        property = "coordinateSystem";
        if (super.getCoordinateSystem() != null) {
            property = "baseCRS";
            if (baseCRS != null) {
                conversionFromBase = createConversionFromBase(null, baseCRS, conversionFromBase);
                return;
            }
        }
    }
    /*
     * If we reach this point, we failed to update the conversion. The 'baseCRS' information will be lost
     * and call to 'getConversionFromBase()' will throw a ClassCastException if this instance is actually
     * a ProjectedCRS (because of the method overriding with return type covariance).
     */
    throw new ValidationException(Errors.format(Errors.Keys.MissingValueForProperty_1, property));
}
 
源代码5 项目: dragonwell8_jdk   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码6 项目: arcusplatform   文件: Attributes.java
public static void validate(Iterable<AttributeDefinition> definition, AttributeMap attributes) throws ValidationException {
Set<AttributeKey<?>> missing = new HashSet<>();
  for(AttributeDefinition attribute: definition) {
  	if(attribute.isOptional()) {
  		continue;
  	}
  	if(attributes.containsKey(attribute.getKey())) {
  		continue;
  	}
  	missing.add(attribute.getKey());
  }
  if(!missing.isEmpty()) {
  	throw new ValidationException("Missing required attribute(s): " + missing);
  }
 }
 
源代码7 项目: TencentKona-8   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码8 项目: joyqueue   文件: Validators.java
/**
 * 认证
 *
 * @param method    方法
 * @param target    目标对象
 * @param arguments 参数
 * @throws ValidationException
 */
public static void validate(final Method method, final Object target, final Object... arguments) throws
        ValidationException {
    if (method == null || target == null || arguments == null || arguments.length == 0) {
        return;
    }
    // 获取方法验证
    MethodValidation valid = getMethodValidation(method, target);
    if (valid != null && valid.validation != null) {
        Validator validator;
        // 遍历参数
        for (int i = 0; i < valid.types.length; i++) {
            if (valid.annotations[i] != null) {
                // 遍历声明
                for (Annotation annotation : valid.annotations[i]) {
                    // 获取验证器
                    validator = getValidator(annotation);
                    // 判断是否能验证
                    if (validator != null) {
                        // 验证
                        validator.validate(target, annotation,
                                new Validator.Value(valid.names[i], valid.types[i], arguments[i]));
                    }
                }
            }
        }
    }
}
 
源代码9 项目: jdk8u60   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码10 项目: openjdk-jdk8u   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码12 项目: jdk8u-jdk   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码13 项目: hottub   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码14 项目: openjdk-8-source   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码15 项目: openjdk-8   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码16 项目: jdk8u_jdk   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码17 项目: jdk8u-jdk   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码18 项目: jdk8u-dev-jdk   文件: SupplierValidator.java
/**
 * Validates the supplier.
 *
 * @param supplier - Supplier that needs to be validated.
 * @return true if supplier has passed validation check. False otherwise.
 */
public static boolean validate(Supplier<?> supplier) {
    for (Validate annotation
            : supplier.getClass().getAnnotationsByType(Validate.class)) {
        try {
            annotation.value().validate(supplier);
        } catch (ValidationException e) {
            System.out.println(annotation.description());
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
源代码19 项目: waggle-dance   文件: FederationsAdminController.java
@ExceptionHandler(ValidationException.class)
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
public ValidationError handleValidationException(HttpServletRequest req, ValidationException exception) {
  return ValidationError.builder().error(exception.getMessage()).build();
}