Class RuleSetReferenceId


  • @Deprecated
    @InternalApi
    public class RuleSetReferenceId
    extends Object
    Deprecated.
    This is part of the internals of the RuleSetLoader.
    This class is used to parse a RuleSet reference value. Most commonly used for specifying a RuleSet to process, or in a Rule 'ref' attribute value in the RuleSet XML. The RuleSet reference can refer to either an external RuleSet or the current RuleSet when used as a Rule 'ref' attribute value. An individual Rule in the RuleSet can be indicated. For an external RuleSet, referring to the entire RuleSet, the format is ruleSetName, where the RuleSet name is either a resource file path to a RuleSet that ends with '.xml', or a simple RuleSet name. A simple RuleSet name, is one which contains no path separators, and either contains a '-' or is entirely numeric release number. A simple name of the form [language]-[name] is short for the full RuleSet name rulesets/[language]/[name].xml. A numeric release simple name of the form [release] is short for the full PMD Release RuleSet name rulesets/releases/[release].xml. For an external RuleSet, referring to a single Rule, the format is ruleSetName/ruleName, where the RuleSet name is as described above. A Rule with the ruleName should exist in this external RuleSet. For the current RuleSet, the format is ruleName, where the Rule name is not RuleSet name (i.e. contains no path separators, '-' or '.xml' in it, and is not all numeric). A Rule with the ruleName should exist in the current RuleSet.
    Examples
    String RuleSet file name Rule
    rulesets/java/basic.xml rulesets/java/basic.xml all
    rulesets/java/basic.xml/EmptyCatchBlock rulesets/java/basic.xml EmptyCatchBlock
    EmptyCatchBlock null EmptyCatchBlock
    • Constructor Detail

      • RuleSetReferenceId

        public RuleSetReferenceId​(String id)
        Deprecated.
        Construct a RuleSetReferenceId for the given single ID string.
        Parameters:
        id - The id string.
        Throws:
        IllegalArgumentException - If the ID contains a comma character.
      • RuleSetReferenceId

        public RuleSetReferenceId​(String id,
                                  RuleSetReferenceId externalRuleSetReferenceId)
        Deprecated.
        Construct a RuleSetReferenceId for the given single ID string. If an external RuleSetReferenceId is given, the ID must refer to a non-external Rule. The external RuleSetReferenceId will be responsible for producing the InputStream containing the Rule.
        Parameters:
        id - The id string.
        externalRuleSetReferenceId - A RuleSetReferenceId to associate with this new instance.
        Throws:
        IllegalArgumentException - If the ID contains a comma character.
        IllegalArgumentException - If external RuleSetReferenceId is not external.
        IllegalArgumentException - If the ID is not Rule reference when there is an external RuleSetReferenceId.
    • Method Detail

      • parse

        public static List<RuleSetReferenceId> parse​(String referenceString)
        Deprecated.
        Parse a String comma separated list of RuleSet reference IDs into a List of RuleReferenceId instances.
        Parameters:
        referenceString - A comma separated list of RuleSet reference IDs.
        Returns:
        The corresponding List of RuleSetReferenceId instances.
      • isExternal

        public boolean isExternal()
        Deprecated.
        Is this an external RuleSet reference?
        Returns:
        true if this is an external reference, false otherwise.
      • isAllRules

        public boolean isAllRules()
        Deprecated.
        Is this a reference to all Rules in a RuleSet, or a single Rule?
        Returns:
        true if this is a reference to all Rules, false otherwise.
      • getRuleSetFileName

        public String getRuleSetFileName()
        Deprecated.
        Get the RuleSet file name.
        Returns:
        The RuleSet file name if this is an external reference, null otherwise.
      • getRuleName

        public String getRuleName()
        Deprecated.
        Get the Rule name.
        Returns:
        The Rule name. The Rule name.
      • getInputStream

        public InputStream getInputStream​(ResourceLoader rl)
                                   throws IOException
        Deprecated.
        Try to load the RuleSet resource with the specified ResourceLoader. Multiple attempts to get independent InputStream instances may be made, so subclasses must ensure they support this behavior. Delegates to an external RuleSetReferenceId if there is one associated with this instance.
        Parameters:
        rl - The ResourceLoader to use.
        Returns:
        An InputStream to that resource.
        Throws:
        IOException
      • toString

        @Deprecated
        public String toString()
        Deprecated.
        Do not rely on the format of this method, it may be changed in PMD 7.
        Return the String form of this Rule reference.
        Overrides:
        toString in class Object
        Returns:
        Return the String form of this Rule reference, which is ruleSetFileName for all Rule external references, ruleSetFileName/ruleName, for a single Rule external references, or ruleName otherwise.