Author: julien_viet
Date: 2010-11-26 16:24:55 -0500 (Fri, 26 Nov 2010)
New Revision: 5304
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java
Log:
preliminary visitor support
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java 2010-11-26
21:11:05 UTC (rev 5303)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/regexp/RENode.java 2010-11-26
21:24:55 UTC (rev 5304)
@@ -28,6 +28,32 @@
public abstract String toString();
+ public abstract void accept(Visitor visitor);
+
+ /**
+ * A visitor.
+ */
+ public static abstract class Visitor
+ {
+ public void enter(Disjunction disjunction) {}
+ public void leave(Disjunction disjunction) {}
+ public void enter(Alternative alternative) {}
+ public void leave(Alternative alternative) {}
+ public void enter(Group group) {}
+ public void leave(Group group) {}
+ public void visit(Assertion assertion) {}
+ public void visit(Dot dot) {}
+ public void visit(Character character) {}
+ public void enter(CharacterClass.Not not) {}
+ public void leave(CharacterClass.Not not) {}
+ public void enter(CharacterClass.Or or) {}
+ public void leave(CharacterClass.Or or) {}
+ public void enter(CharacterClass.And and) {}
+ public void leave(CharacterClass.And and) {}
+ public void visit(CharacterClass.Simple simple) {}
+ public void visit(CharacterClass.Range range) {}
+ }
+
public static class Disjunction extends RENode
{
@@ -66,6 +92,18 @@
return alternative.toString();
}
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.enter(this);
+ alternative.accept(visitor);
+ if (next != null)
+ {
+ next.accept(visitor);
+ }
+ visitor.leave(this);
+ }
}
public static class Alternative extends RENode
@@ -104,6 +142,18 @@
return exp.toString();
}
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.enter(this);
+ exp.accept(visitor);
+ if (next != null)
+ {
+ next.accept(visitor);
+ }
+ visitor.leave(this);
+ }
}
public static abstract class Exp extends RENode
@@ -158,6 +208,12 @@
private Assertion()
{
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.visit(this);
+ }
}
public static abstract class Atom extends Exp
@@ -179,6 +235,12 @@
{
sb.append("<./>");
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.visit(this);
+ }
}
public static final class Group extends Atom
@@ -201,6 +263,14 @@
{
sb.append("<(>").append(disjunction).append("</)>");
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.enter(this);
+ disjunction.accept(visitor);
+ visitor.leave(this);
+ }
}
public static final class Character extends Atom
@@ -219,6 +289,12 @@
{
sb.append("<c>").append(value).append("</c>");
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.visit(this);
+ }
}
public static abstract class CharacterClass extends Atom
@@ -248,6 +324,14 @@
negated.toString(sb);
sb.append("]");
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.enter(this);
+ negated.accept(visitor);
+ visitor.leave(this);
+ }
}
public static class Or extends CharacterClass
@@ -281,6 +365,15 @@
right.toString(sb);
sb.append("]");
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.enter(this);
+ left.accept(visitor);
+ right.accept(visitor);
+ visitor.leave(this);
+ }
}
public static class And extends CharacterClass
@@ -315,6 +408,15 @@
right.toString(sb);
sb.append("]");
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.enter(this);
+ left.accept(visitor);
+ right.accept(visitor);
+ visitor.leave(this);
+ }
}
public static class Simple extends CharacterClass
@@ -335,6 +437,12 @@
sb.append(value);
sb.append("]");
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.visit(this);
+ }
}
public static class Range extends CharacterClass
@@ -361,6 +469,12 @@
sb.append(to);
sb.append("]");
}
+
+ @Override
+ public void accept(Visitor visitor)
+ {
+ visitor.visit(this);
+ }
}
}
}
Show replies by date