Package kawa.lang

Class Pattern

  • All Implemented Interfaces:
    gnu.kawa.format.Printable
    Direct Known Subclasses:
    AnyPat, EqualPat, ListPat, ListRepeatPat, PairPat, SyntaxPattern, VarListPat

    public abstract class Pattern
    extends java.lang.Object
    implements gnu.kawa.format.Printable
    A Pattern is used to match against objects. E.g. it can be used to match against macro arguments.
    • Constructor Summary

      Constructors 
      Constructor Description
      Pattern()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object[] match​(java.lang.Object obj)
      Match this Pattern against an object.
      abstract boolean match​(java.lang.Object obj, java.lang.Object[] vars, int start_vars)
      Match this Pattern against an Object.
      void print​(Consumer out)  
      abstract int varCount()  
      • Methods inherited from class java.lang.Object

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

      • typePattern

        public static ClassType typePattern
      • matchPatternMethod

        public static final Method matchPatternMethod
    • Constructor Detail

      • Pattern

        public Pattern()
    • Method Detail

      • match

        public java.lang.Object[] match​(java.lang.Object obj)
        Match this Pattern against an object.
        Parameters:
        obj - object to match against this pattern
        Returns:
        null on failure, or an array of bound pattern variables.
      • match

        public abstract boolean match​(java.lang.Object obj,
                                      java.lang.Object[] vars,
                                      int start_vars)
        Match this Pattern against an Object.
        Parameters:
        obj - the Object to match against
        vars - the "pattern variable" values extracted from obj go here
        start_vars - where in vars to strt putting the varCount() values
        Returns:
        true iff the match succeeded.
      • varCount

        public abstract int varCount()
      • print

        public void print​(Consumer out)
        Specified by:
        print in interface gnu.kawa.format.Printable