1 /* 2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License, version 2.0, 6 * as published by the Free Software Foundation. 7 * 8 * This program is also distributed with certain software (including 9 * but not limited to OpenSSL) that is licensed under separate terms, 10 * as designated in a particular file or component or in included license 11 * documentation. The authors of MySQL hereby grant you an additional 12 * permission to link the program and your derivative works with the 13 * separately licensed software that they have included with MySQL. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License, version 2.0, for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 package com.mysql.clusterj.jdbc.antlr.node; 26 27 import org.antlr.runtime.tree.CommonTree; 28 import org.antlr.runtime.Token; 29 30 import com.mysql.clusterj.ClusterJFatalInternalException; 31 import com.mysql.clusterj.core.util.I18NHelper; 32 import com.mysql.clusterj.core.util.Logger; 33 import com.mysql.clusterj.core.util.LoggerFactoryService; 34 import com.mysql.clusterj.jdbc.SQLExecutor; 35 import com.mysql.clusterj.query.Predicate; 36 import com.mysql.clusterj.query.QueryDomainType; 37 38 public class Node extends CommonTree { 39 40 /** My number of parameters */ 41 protected int numberOfParameters = -1; 42 43 /** My message translator */ 44 static final I18NHelper local = I18NHelper.getInstance(SQLExecutor.class); 45 46 /** My logger */ 47 static final Logger logger = LoggerFactoryService.getFactory().getInstance(SQLExecutor.class); 48 Node(Token token)49 public Node(Token token) { 50 super(token); 51 } 52 Node(Node node)53 public Node(Node node) { 54 super(node); 55 } 56 57 @Override dupNode()58 public Node dupNode() { 59 return new Node(this); 60 } 61 getPredicate(QueryDomainType<?> queryDomainType)62 public Predicate getPredicate(QueryDomainType<?> queryDomainType) { 63 // default behavior is no predicate is possible from the tree 64 return null; 65 } 66 getNumberOfParameters()67 public int getNumberOfParameters() { 68 if (numberOfParameters == -1) { 69 throw new ClusterJFatalInternalException(local.message("ERR_Number_Of_Parameters_Not_Initialized")); 70 } 71 return numberOfParameters; 72 } 73 setNumberOfParameters(int numberOfParameters)74 protected void setNumberOfParameters(int numberOfParameters) { 75 this.numberOfParameters = numberOfParameters; 76 } 77 78 } 79