21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 * or visit www.oracle.com if you need additional information or have any |
22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 /* |
25 /* |
26 * Copyright (C) 2004-2011 |
26 * Copyright (C) 2004-2012 |
27 * |
27 * |
28 * Permission is hereby granted, free of charge, to any person obtaining a copy |
28 * Permission is hereby granted, free of charge, to any person obtaining a copy |
29 * of this software and associated documentation files (the "Software"), to deal |
29 * of this software and associated documentation files (the "Software"), to deal |
30 * in the Software without restriction, including without limitation the rights |
30 * in the Software without restriction, including without limitation the rights |
31 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
31 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
53 * Base class of all the patterns. |
53 * Base class of all the patterns. |
54 * |
54 * |
55 * @author Kohsuke Kawaguchi (kk@kohsuke.org) |
55 * @author Kohsuke Kawaguchi (kk@kohsuke.org) |
56 */ |
56 */ |
57 public abstract class DPattern implements ParsedPattern { |
57 public abstract class DPattern implements ParsedPattern { |
|
58 |
58 Locator location; |
59 Locator location; |
59 DAnnotation annotation; |
60 DAnnotation annotation; |
60 |
|
61 /** |
61 /** |
62 * Used to chain the child patterns in a doubly-linked list. |
62 * Used to chain the child patterns in a doubly-linked list. |
63 */ |
63 */ |
64 DPattern next; |
64 DPattern next; |
65 DPattern prev; |
65 DPattern prev; |
72 } |
72 } |
73 |
73 |
74 /** |
74 /** |
75 * Returns the annotation associated with it. |
75 * Returns the annotation associated with it. |
76 * |
76 * |
77 * @return |
77 * @return may be empty, but never be null. |
78 * may be empty, but never be null. |
|
79 */ |
78 */ |
80 public DAnnotation getAnnotation() { |
79 public DAnnotation getAnnotation() { |
81 if(annotation==null) |
80 if (annotation == null) { |
82 return DAnnotation.EMPTY; |
81 return DAnnotation.EMPTY; |
|
82 } |
83 return annotation; |
83 return annotation; |
84 } |
84 } |
85 |
85 |
86 /** |
86 /** |
87 * Returns true if this pattern is nullable. |
87 * Returns true if this pattern is nullable. |
88 * |
88 * |
89 * A nullable pattern is a pattern that can match the empty sequence. |
89 * A nullable pattern is a pattern that can match the empty sequence. |
90 */ |
90 */ |
91 public abstract boolean isNullable(); |
91 public abstract boolean isNullable(); |
92 |
92 |
93 public abstract <V> V accept( DPatternVisitor<V> visitor ); |
93 public abstract <V> V accept(DPatternVisitor<V> visitor); |
94 |
94 |
95 /** |
95 /** |
96 * Creates a {@link Parseable} object that reparses this pattern. |
96 * Creates a {@link Parseable} object that reparses this pattern. |
97 */ |
97 */ |
98 public Parseable createParseable() { |
98 public Parseable createParseable() { |