Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * Wikitty :: api
   * %%
   * Copyright (C) 2012 CodeLutin, Benjamin Poussin
   * %%
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Lesser General Public License as 
   * published by the Free Software Foundation, either version 3 of the 
  * License, or (at your option) any later version.
  * 
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Lesser Public License for more details.
  * 
  * You should have received a copy of the GNU General Lesser Public 
  * License along with this program.  If not, see
  * <http://www.gnu.org/licenses/lgpl-3.0.html>.
  * #L%
  */
 package org.nuiton.wikitty.query;
 
Permet d'implanter un visiteur de Query ou Condition. Une fois que vous avez cree votre propre Visiteur pour l'utiliser
 WikittyQuery q = ...;
 MyVisitor v = new MyVisitor();
 q.accept(v);
 v.getXXXX()
 
ATTENTION les sous classes doivent avoir une visibilite public car sinon l'introspection n'arrive pas a executer les methods

Author(s):
poussin
Version:
$Revision$
Since:
3.3 Last update: $Date$ by : $Author$
 
 public abstract class WikittyQueryVisitor {

    
to use log facility, just put in your code: log.info(\"...\");
 
     static private Log log = LogFactory.getLog(WikittyQueryVisitor.class);

    
True if we want visit sub-element, otherwize false

Parameters:
o
Returns:
True if we want visit sub-element, otherwize false
 
     abstract public boolean visitEnter(WikittyQuery o);
    
Leave method is alway called, but evaluation of enter is passed in arguement

Parameters:
o
enterOrMiddleResult result returned by visitEnter method
 
     abstract public void visitLeave(WikittyQuery oboolean enterOrMiddleResult);
    
True if we want visit sub-element, otherwize false

Parameters:
o
Returns:
True if we want visit sub-element, otherwize false
 
     abstract public boolean visitEnter(And o);
    
True if we want visit others elements, otherwize false. If false visitMiddle for this node is never called

Parameters:
o
Returns:
True if we want visit others elements, otherwize false
    abstract public boolean visitMiddle(And o);
    
Leave method is alway called, but evaluation of enter is passed in arguement

Parameters:
o
enterOrMiddleResult result returned by visitEnter method
    abstract public void visitLeave(And oboolean enterOrMiddleResult);
    
True if we want visit sub-element, otherwize false visitMiddle for this node is never called

Parameters:
o
Returns:
True if we want visit sub-element, otherwize false
    abstract public boolean visitEnter(Or o);
    
True if we want visit others elements, otherwize false

Parameters:
o
Returns:
True if we want visit others elements, otherwize false
    abstract public boolean visitMiddle(Or o);
    
Leave method is alway called, but evaluation of enter is passed in arguement

Parameters:
o
enterOrMiddleResult result returned by visitEnter method
    abstract public void visitLeave(Or oboolean enterOrMiddleResult);
    
True if we want visit sub-element, otherwize false

Parameters:
o
Returns:
True if we want visit sub-element, otherwize false

    
True if we want visit sub-element, otherwize false

Parameters:
o
Returns:
True if we want visit sub-element, otherwize false
    abstract public boolean visitEnter(Select o);
    
True if we want visit others elements, otherwize false

Parameters:
o
Returns:
True if we want visit others elements, otherwize false
    abstract public boolean visitMiddle(Select o);
    
Leave method is alway called, but evaluation of enter is passed in arguement

Parameters:
o
enterOrMiddleResult result returned by visitEnter method
    abstract public void visitLeave(Select oboolean enterOrMiddleResult);
    
True if we want visit sub-element, otherwize false

Parameters:
o
Returns:
True if we want visit sub-element, otherwize false
    abstract public boolean visitEnter(Not o);
    
Leave method is alway called, but evaluation of enter is passed in arguement

Parameters:
o
enterOrMiddleResult result returned by visitEnter method
    abstract public void visitLeave(Not oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(Between o);
    abstract public boolean visitMiddle(Between o);
    abstract public void visitLeave(Between oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(ContainsAll o);
    abstract public boolean visitMiddle(ContainsAll o);
    abstract public void visitLeave(ContainsAll oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(ContainsOne o);
    abstract public boolean visitMiddle(ContainsOne o);
    abstract public void visitLeave(ContainsOne oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(Equals o);
    abstract public void visitLeave(Equals oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(NotEquals o);
    abstract public void visitLeave(NotEquals oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(Greater o);
    abstract public void visitLeave(Greater oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(GreaterOrEquals o);
    abstract public void visitLeave(GreaterOrEquals oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(Keyword o);
    abstract public void visitLeave(Keyword oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(Less o);
    abstract public void visitLeave(Less oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(LessOrEquals o);
    abstract public void visitLeave(LessOrEquals oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(Like o);
    abstract public void visitLeave(Like oboolean enterOrMiddleResult);
    abstract public boolean visitEnter(Unlike o);
    abstract public void visitLeave(Unlike oboolean enterOrMiddleResult);
    abstract public void visit(Null o);
    abstract public void visit(NotNull o);
    abstract public void visit(False o);
    abstract public void visit(True o);
    abstract public void visit(ConditionValueString o);
    abstract public boolean visitEnter(WikittyQueryFunction function);
    abstract public boolean visitMiddle(WikittyQueryFunction function);
    abstract public void visitLeave(WikittyQueryFunction functionboolean enterOrMiddleResult);
    abstract public void visit(FunctionValue function);
    abstract public void defaultVisit(Object o);
    
True if we want visit sub-element, otherwize false

Parameters:
o
Returns:
True if we want visit sub-element, otherwize false
    abstract public boolean defaultVisitEnter(Object o);
    
True if we want visit others elements, otherwize false visitMiddle for this node is never called

Parameters:
o
Returns:
True if we want visit others elements, otherwize false
    abstract public boolean defaultVisitMiddle(Object o);
    
Leave method is alway called, but evaluation of enter is passed in arguement

Parameters:
o
enterOrMiddleResult result returned by visitEnter method
    abstract public void defaultVisitLeave(Object oboolean enterOrMiddleResult);
    public void visit(Object object) {
        if (.isDebugEnabled()) {
            .debug(String.format("Visit '%s'",
                    ClassUtils.getShortCanonicalName(object"null")));
        }
        try {
            Method downPolymorphic = this.getClass().getMethod("visit",
                    new Class[] { object.getClass() });
            if (downPolymorphic == null) {
                defaultVisit(object);
            } else {
                try {
                    downPolymorphic.invoke(thisnew Object[] {object});
                } catch (Exception eee) {
                    throw new WikittyException(String.format(
                            "Error during visitor call method '%s'",
                            downPolymorphic), eee);
                }
            }
        }
        catch (NoSuchMethodException eee) {
            .debug("Can't call specific visit method, call defaultVisit"eee);
            this.defaultVisit(object);
        }
    }
    public boolean visitEnter(Object object) {
        if (.isDebugEnabled()) {
            .debug(String.format("VisitEnter '%s'",
                    ClassUtils.getShortCanonicalName(object"null")));
        }
        boolean result;
        try {
            Method downPolymorphic = this.getClass().getMethod("visitEnter",
                    new Class[] { object.getClass() });
            if (downPolymorphic == null) {
                result = defaultVisitEnter(object);
            } else {
                try {
                    result = (Boolean)downPolymorphic.invoke(thisnew Object[] {object});
                } catch (Exception eee) {
                    throw new WikittyException(String.format(
                            "Error during visitor call method '%s'",
                            downPolymorphic), eee);
                }
            }
        }
        catch (NoSuchMethodException eee) {
            .debug("Can't call specific visit method, call defaultVisitEnter"eee);
            result = defaultVisitEnter(object);
        }
        return result;
    }
    
    public boolean visitMiddle(Object object) {
        if (.isDebugEnabled()) {
            .debug(String.format("VisitMiddle '%s'",
                    ClassUtils.getShortCanonicalName(object"null")));
        }
        boolean result;
        try {
            Method downPolymorphic = this.getClass().getMethod("visitMiddle",
                    new Class[] { object.getClass() });
            if (downPolymorphic == null) {
                result = defaultVisitMiddle(object);
            } else {
                try {
                    result = (Boolean)downPolymorphic.invoke(thisnew Object[] {object});
                } catch (Exception eee) {
                    throw new WikittyException(String.format(
                            "Error during visitor call method '%s'",
                            downPolymorphic), eee);
                }
            }
        }
        catch (NoSuchMethodException eee) {
            .debug("Can't call specific visit method, call defaultVisitMiddle"eee);
            result = defaultVisitMiddle(object);
        }
        return result;
    }
    public void visitLeave(Object objectboolean enterOrMiddleResult) {
        if (.isDebugEnabled()) {
            .debug(String.format("VisitLeave '%s'",
                    ClassUtils.getShortCanonicalName(object"null")));
        }
        try {
            Method downPolymorphic = this.getClass().getMethod("visitLeave",
                    new Class[] { object.getClass(), . });
            if (downPolymorphic == null) {
                defaultVisitLeave(objectenterOrMiddleResult);
            } else {
                try {
                    downPolymorphic.invoke(thisnew Object[] {objectenterOrMiddleResult});
                } catch (Exception eee) {
                    throw new WikittyException(String.format(
                            "Error during visitor call method '%s'",
                            downPolymorphic), eee);
                }
            }
        }
        catch (NoSuchMethodException eee) {
            .error("Can't call specific visit method, call defaultVisitLeave"eee);
            this.defaultVisitLeave(objectenterOrMiddleResult);
        }
    }
New to GrepCode? Check out our FAQ X