KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > trading > constraint > MultiplyNode


1
2 // Copyright (C) 1998-1999
3
// Object Oriented Concepts, Inc.
4

5 // **********************************************************************
6
//
7
// Copyright (c) 1997
8
// Mark Spruiell (mark@intellisoft.com)
9
//
10
// See the COPYING file for more information
11
//
12
// **********************************************************************
13

14 package org.jacorb.trading.constraint;
15
16 import java.io.*;
17
18
19 /** Represents arithmetic multiplication */
20 public class MultiplyNode extends ExprNode
21 {
22   private ExprNode m_left;
23   private ExprNode m_right;
24
25
26   private MultiplyNode()
27   {
28   }
29
30
31   public MultiplyNode(ExprNode left, ExprNode right)
32   {
33     m_left = left;
34     m_right = right;
35
36       // the type of this expression is the "promoted" type of our
37
// children
38
int id = ValueType.promote(left.getType().getId(), right.getType().getId());
39     setType(new ValueType(id));
40   }
41
42
43   public void print(PrintStream ps)
44   {
45     ps.println("MultiplyNode: type = " + getType());
46     ps.println("Left node:");
47     m_left.print(ps);
48     ps.println("Right node:");
49     m_right.print(ps);
50   }
51
52
53   public Value evaluate(PropertySource source)
54     throws MissingPropertyException
55   {
56     Value result = null;
57
58     int id = getType().getId();
59
60     Value v, left, right;
61     v = m_left.evaluate(source);
62     left = v.convert(id);
63     v = m_right.evaluate(source);
64     right = v.convert(id);
65
66     result = left.multiply(right);
67
68     return result;
69   }
70 }
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Popular Tags