001package ca.uhn.hl7v2.validation.impl;
002
003/**
004 * <p>
005 * Validation Rule which will not accept any content (i.e. length must be 0).
006 * </p>
007 * <p>
008 * This class is expected to be used for withdrawn fields/components, and will
009 * provide a failure description indicating that the type is withdrawn.
010 * </p>
011 * <p>
012 * If you wish to disable this rule globally, invoke the following code:
013 * </p>
014 * <code>System.setProperty(ca.uhn.hl7v2.validation.impl.WithdrawnDatatypeRule.PROP_DISABLE_RULE, "true");</code>
015 * </p> Note that this property is only checked the first time the class is
016 * loaded (i.e. not at runtime). To disable for an individual parser at runtime,
017 * call </p> <code>parser.setValidationContext(new NoValidation());</code>
018 * 
019 * @deprecated use {@link ca.uhn.hl7v2.validation.builder.BuilderSupport#withdrawn()} instead
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
026         * globally.
027         */
028        public static final String PROP_DISABLE_RULE = "ca.uhn.hl7v2.validation.impl.WithdrawnDatatypeRule";
029
030        private static final int RULE_SIZE;
031
032        static {
033                if (Boolean.getBoolean(PROP_DISABLE_RULE)) {
034                        RULE_SIZE = Integer.MAX_VALUE;
035                } else {
036                        RULE_SIZE = 0;
037                }
038        }
039
040        /**
041         * Constructor
042         */
043        public WithdrawnDatatypeRule() {
044                super(RULE_SIZE);
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}