Class RewriteCond


  • public class RewriteCond
    extends java.lang.Object
    Rewrite condition.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected RewriteCond.Condition condition
      The condition.
      protected java.lang.String condPattern
      The condition pattern.
      protected java.lang.String flagsString
      The flags string.
      boolean nocase
      This makes the test case-insensitive, i.e., there is no difference between 'A-Z' and 'a-z' both in the expanded TestString and the CondPattern.
      boolean ornext
      Use this to combine rule conditions with a local OR instead of the implicit AND.
      protected boolean positive
      Whether the condition is positive.
      protected Substitution test
      The test substitution.
      protected java.lang.String testString
      The test string.
    • Constructor Summary

      Constructors 
      Constructor Description
      RewriteCond()
      Default constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean evaluate​(java.util.regex.Matcher rule, java.util.regex.Matcher cond, Resolver resolver)
      Evaluate the condition based on the context
      java.lang.String getCondPattern()
      Returns the condition pattern.
      java.lang.String getFlagsString()
      Returns the flags string.
      java.util.regex.Matcher getMatcher()
      Returns the matcher for the condition, if it is a pattern-based condition.
      java.lang.String getTestString()
      Returns the test string.
      boolean isNocase()
      Returns whether the test is case-insensitive.
      boolean isOrnext()
      Returns whether to combine rule conditions with a local OR.
      boolean isPositive()
      Returns whether the condition is positive.
      void parse​(java.util.Map<java.lang.String,​RewriteMap> maps)
      Parses the condition using the provided rewrite maps.
      void setCondPattern​(java.lang.String condPattern)
      Sets the condition pattern.
      void setFlagsString​(java.lang.String flagsString)
      Sets the flags string.
      void setNocase​(boolean nocase)
      Sets whether the test is case-insensitive.
      void setOrnext​(boolean ornext)
      Sets whether to combine rule conditions with a local OR.
      void setPositive​(boolean positive)
      Sets whether the condition is positive.
      void setTestString​(java.lang.String testString)
      Sets the test string.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • testString

        protected java.lang.String testString
        The test string.
      • condPattern

        protected java.lang.String condPattern
        The condition pattern.
      • flagsString

        protected java.lang.String flagsString
        The flags string.
      • positive

        protected boolean positive
        Whether the condition is positive.
      • nocase

        public boolean nocase
        This makes the test case-insensitive, i.e., there is no difference between 'A-Z' and 'a-z' both in the expanded TestString and the CondPattern. This flag is effective only for comparisons between TestString and CondPattern. It has no effect on filesystem and subrequest checks.
      • ornext

        public boolean ornext
        Use this to combine rule conditions with a local OR instead of the implicit AND.
    • Constructor Detail

      • RewriteCond

        public RewriteCond()
        Default constructor.
    • Method Detail

      • getCondPattern

        public java.lang.String getCondPattern()
        Returns the condition pattern.
        Returns:
        the condition pattern
      • setCondPattern

        public void setCondPattern​(java.lang.String condPattern)
        Sets the condition pattern.
        Parameters:
        condPattern - the condition pattern
      • getTestString

        public java.lang.String getTestString()
        Returns the test string.
        Returns:
        the test string
      • setTestString

        public void setTestString​(java.lang.String testString)
        Sets the test string.
        Parameters:
        testString - the test string
      • getFlagsString

        public final java.lang.String getFlagsString()
        Returns the flags string.
        Returns:
        the flags string
      • setFlagsString

        public final void setFlagsString​(java.lang.String flagsString)
        Sets the flags string.
        Parameters:
        flagsString - the flags string
      • parse

        public void parse​(java.util.Map<java.lang.String,​RewriteMap> maps)
        Parses the condition using the provided rewrite maps.
        Parameters:
        maps - the rewrite maps
      • getMatcher

        public java.util.regex.Matcher getMatcher()
        Returns the matcher for the condition, if it is a pattern-based condition.
        Returns:
        the matcher, or null if not a pattern condition
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • evaluate

        public boolean evaluate​(java.util.regex.Matcher rule,
                                java.util.regex.Matcher cond,
                                Resolver resolver)
        Evaluate the condition based on the context
        Parameters:
        rule - corresponding matched rule
        cond - last matched condition
        resolver - Property resolver
        Returns:
        true if the condition matches
      • isNocase

        public boolean isNocase()
        Returns whether the test is case-insensitive.
        Returns:
        true if case-insensitive
      • setNocase

        public void setNocase​(boolean nocase)
        Sets whether the test is case-insensitive.
        Parameters:
        nocase - true if case-insensitive
      • isOrnext

        public boolean isOrnext()
        Returns whether to combine rule conditions with a local OR.
        Returns:
        true if OR is used
      • setOrnext

        public void setOrnext​(boolean ornext)
        Sets whether to combine rule conditions with a local OR.
        Parameters:
        ornext - true if OR is used
      • isPositive

        public boolean isPositive()
        Returns whether the condition is positive.
        Returns:
        true if positive
      • setPositive

        public void setPositive​(boolean positive)
        Sets whether the condition is positive.
        Parameters:
        positive - true if positive