/** * Validates the given subcontrol and bitwise "AND" the subcontrols valid state to the passed in * current valid state. If the subcontrol validation results into a message which has a higher * message type than the currently set message, the message from the subcontrol is applied to the * control itself. * * <p><b>Note:</b> If the given subcontrol is <code>null</code>, the current validation state is * returned unchanged. * * @param subControl The subcontrol instance or <code>null</code>. * @param currentValidationState The current control validation state before the subcontrol is * validated. * @return The new controls validation state after the subcontrol has been validated. */ protected final boolean isSubControlValid( BaseControl subControl, boolean currentValidationState) { if (subControl == null) return currentValidationState; // Validate the subcontrol and bitwise "AND" the result to the current validation state currentValidationState &= subControl.isValid(); // Check if the subcontrol has set a message which has a higher message // type than the currently set message. if (subControl.getMessageType() > getMessageType()) { // Apply the message from the subcontrol to the control setMessage(subControl.getMessage(), subControl.getMessageType()); } // Returns the resulting validation state. return currentValidationState; }