001package ca.uhn.hl7v2.validation.impl;
002
003
004/**
005 * <p>
006 * Validation Rule which will not accept any content (i.e. length must be 0).
007 * </p>
008 * <p>
009 * This class is expected to be used for withdrawn fields/components, and will
010 * provide a failure description indicating that the type is withdrawn.
011 * </p>
012 * <p>
013 * If you wish to disable this rule globally, invoke the following code:
014 * </p>
015 * <code>System.setProperty(ca.uhn.hl7v2.validation.impl.WithdrawnDatatypeRule.PROP_DISABLE_RULE, "true");</code>
016 * </p>
017 * Note that this property is only checked the first time the class is loaded (i.e. not at runtime). To disable for an individual parser at runtime, call
018 * </p>
019 * <code>parser.setValidationContext(new NoValidation());</code>
020 */
021@SuppressWarnings("serial")
022public class WithdrawnDatatypeRule extends SizeRule {
023
024    /**
025     * Set the value of a system property to "true" to disable this rule globally.
026     */
027    public static final String PROP_DISABLE_RULE = "ca.uhn.hl7v2.validation.impl.WithdrawnDatatypeRule";
028    
029    private static final int RULE_SIZE;
030    
031    static {
032        if (Boolean.getBoolean(PROP_DISABLE_RULE)) {
033            RULE_SIZE = Integer.MAX_VALUE;
034        } else {
035            RULE_SIZE = 0;
036        }
037    }
038    
039    /**
040     * Constructor
041     */
042    public WithdrawnDatatypeRule() {
043        super(RULE_SIZE);
044    }
045
046
047    /**
048     * {@inheritDoc}
049     */
050    public String getDescription() {
051        return "The field/component is withdrawn from the current HL7 version and should not be used. See the JavaDoc for WithdrawnDatatypeRule for information on disabling this rule.";
052    }
053
054}