if (getPostalAddress() != null)
validComponents++;
if (getVerticalExtent() != null)
validComponents++;
if (validComponents == 0) {
throw new InvalidDDMSException("At least 1 of geographicIdentifier, boundingBox, boundingGeometry, "
+ "postalAddress, or verticalExtent must be used.");
}
Util.requireBoundedChildCount(extElement, GeographicIdentifier.getName(getDDMSVersion()), 0, 1);
Util.requireBoundedChildCount(extElement, BoundingBox.getName(getDDMSVersion()), 0, 1);
Util.requireBoundedChildCount(extElement, BoundingGeometry.getName(getDDMSVersion()), 0, 1);
Util.requireBoundedChildCount(extElement, PostalAddress.getName(getDDMSVersion()), 0, 1);
Util.requireBoundedChildCount(extElement, VerticalExtent.getName(getDDMSVersion()), 0, 1);
if (hasFacilityIdentifier() && validComponents > 1) {
throw new InvalidDDMSException("A geographicIdentifier containing a facilityIdentifier must not be used in "
+ "tandem with any other coverage elements.");
}
if (!getDDMSVersion().isAtLeast("4.0.1")) {
if (getOrder() != null) {
throw new InvalidDDMSException("The ddms:order attribute must not be used until DDMS 4.0.1 or later.");
}
if (!Util.isEmpty(getPrecedence())) {
throw new InvalidDDMSException(
"The ddms:precedence attribute must not be used until DDMS 4.0.1 or later.");
}
}
if (!Util.isEmpty(getPrecedence())) {
if (!VALID_PRECEDENCE_VALUES.contains(getPrecedence())) {
throw new InvalidDDMSException("The ddms:precedence attribute must have a value from: "
+ VALID_PRECEDENCE_VALUES);
}
if (getGeographicIdentifier() == null || getGeographicIdentifier().getCountryCode() == null) {
throw new InvalidDDMSException("The ddms:precedence attribute must only be applied to a "
+ "geospatialCoverage containing a country code.");
}
}
if (!getDDMSVersion().isAtLeast("3.0") && !getSecurityAttributes().isEmpty()) {
throw new InvalidDDMSException(
"Security attributes must not be applied to this component until DDMS 3.0 or later.");
}
super.validate();
}