KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > Assignment


1 /**
2  * com.mckoi.database.Assignment 18 Jul 2000
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database;
26
27 /**
28  * An assignment from a variable to an expression. For example;<p>
29  * <pre>
30  * value_of = value_of * 1.10
31  * name = concat("CS-", name)
32  * description = concat("LEGACY: ", upper(number));
33  * </pre>
34  *
35  * @author Tobias Downer
36  */

37
38 public final class Assignment
39             implements StatementTreeObject, java.io.Serializable JavaDoc, Cloneable JavaDoc {
40
41   static final long serialVersionUID = 498589698743066869L;
42
43   /**
44    * The Variable that is the lhs of the assignment.
45    */

46   private Variable variable;
47
48   /**
49    * Set expression that is the rhs of the assignment.
50    */

51   private Expression expression;
52
53   /**
54    * Constructs the assignment.
55    */

56   public Assignment(Variable variable, Expression expression) {
57     this.variable = variable;
58     this.expression = expression;
59   }
60
61   /**
62    * Returns the variable for this assignment.
63    */

64   public Variable getVariable() {
65     return variable;
66   }
67
68   /**
69    * Returns the Expression for this assignment.
70    */

71   public Expression getExpression() {
72     return expression;
73   }
74
75   // ---------- Implemented from StatementTreeObject ----------
76
public void prepareExpressions(ExpressionPreparer preparer)
77                                                     throws DatabaseException {
78     if (expression != null) {
79       expression.prepare(preparer);
80     }
81   }
82
83   public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
84     Assignment v = (Assignment) super.clone();
85     v.variable = (Variable) variable.clone();
86     v.expression = (Expression) expression.clone();
87     return v;
88   }
89
90 }
91
Popular Tags