@@ -0,0 +1,2096 @@
+/*%0A *  Copyright (C) 2011 The Animo Project%0A *  http://animotron.org%0A *%0A *  This program is free software; you can redistribute it and/or%0A *  modify it under the terms of the GNU Lesser General Public License%0A *  as published by the Free Software Foundation; either version 3%0A *  of the License, or (at your option) any later version.%0A *%0A *  This program is distributed in the hope that it will be useful,%0A *  but WITHOUT ANY WARRANTY; without even the implied warranty of%0A *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A *  GNU Lesser General Public License for more details.%0A *%0A *  You should have received a copy of the GNU Lesser General Public License%0A *  along with this program; if not, write to the Free Software%0A *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.%0A */%0Apackage org.animotron.operator;%0A%0Aimport org.animotron.Executor;%0Aimport org.animotron.manipulator.OnQuestion;%0Aimport org.animotron.manipulator.PFlow;%0Aimport org.jetlang.channels.Subscribable;%0Aimport org.jetlang.core.DisposingExecutor;%0Aimport org.neo4j.graphdb.Relationship;%0A%0A/**%0A * Operation 'COUNT'. Count elements.%0A * %0A * @author %3Ca href=%22mailto:shabanovd@gmail.com%22%3EDmitriy Shabanov%3C/a%3E%0A * @author %3Ca href=%22mailto:gazdovsky@gmail.com%22%3EEvgeny Gazdovsky%3C/a%3E%0A */%0Apublic class COUNT extends AbstractOperator implements Evaluable, Cachable %7B%0A%0A%09public static final COUNT _ = new COUNT();%0A%0A%09private COUNT() %7B super(%22count%22, %22animo/count%22); %7D%0A%0A%09@Override%0A%09public Subscribable%3CPFlow%3E onCalcQuestion() %7B%0A%09%09return question;%0A%09%7D%0A%0A%09private OnQuestion question = new OnQuestion() %7B%0A%0A%09%09@Override%0A%09%09public void onMessage(final PFlow pf) %7B%0A%09%09%09System.out.println(%22EACH%22);%0A%09%09%09%0A%09%09%09Subscribable%3CRelationship%3E onContext = new Subscribable%3CRelationship%3E() %7B%0A%09%09%09%09@Override%0A%09%09%09%09public void onMessage(Relationship context) %7B%0A%09%09%09%09%09System.out.println(%22COUNT message context %22+context);%0A%09%09%09%09%09if (context == null) %7B%0A%09%09%09%09%09%09pf.sendAnswer(null);%0A%09%09%09%09%09%09return;%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%0A%09%09%09%09@Override%0A%09%09%09%09public DisposingExecutor getQueue() %7B%0A%09%09%09%09%09return Executor.getFiber();%0A%09%09%09%09%7D%0A%09%09%09%7D;%0A%09%09%09%0A%09%09%09pf.answer.subscribe(onContext);%0A%09%09%7D%0A%09%7D;%0A%7D

'count' operator