initial load
[DTRules.git] / DTRules / src / main / java / com / dtrules / interpreter / IRObject.java
blobe8ae3332b5ec2b6ef0c638c2a55c7f247ea83e24
1 /*
2 * $Id$
3 *
4 * Copyright 2004-2007 MTBJ, Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
19 package com.dtrules.interpreter;
22 import java.util.ArrayList;
23 import java.util.Date;
24 import java.util.HashMap;
26 import com.dtrules.entity.IREntity;
27 import com.dtrules.infrastructure.RulesException;
28 import com.dtrules.mapping.XMLTag;
29 import com.dtrules.session.DTState;
30 import com.dtrules.session.IRSession;
32 @SuppressWarnings({"unchecked"})
33 public interface IRObject {
35 public IRObject clone(IRSession s) throws RulesException;
37 // *************** NOTE !!!!!!
38 // You can't put static methods on an interface. So the String to integer conversion
39 // for types is a static method on the RSession class.
41 final String rBoolean = "boolean",
42 rString = "string",
43 rInteger = "integer",
44 rFloat = "float",
45 rEntity = "entity",
46 rName = "name",
47 rArray = "array",
48 rDecisiontable = "decisiontable",
49 rNull = "null",
50 rMark = "mark",
51 rOperator = "operator",
52 rTime = "time",
53 rTable = "table",
54 rXmlValue = "xmlvalue";
56 final String types[] = { rBoolean, rString, rInteger, rFloat,
57 rEntity, rName, rArray, rDecisiontable,
58 rNull, rMark, rOperator, rTime,
59 rTable, rXmlValue};
61 final int iBoolean = 0,
62 iString = 1,
63 iInteger = 2,
64 iDouble = 3,
65 iEntity = 4,
66 iName = 5,
67 iArray = 6,
68 iDecisiontable = 7,
69 iNull = 8,
70 iMark = 9,
71 iOperator = 10,
72 iTime = 11,
73 iTable = 12,
74 iXmlValue = 13;
77 void execute(DTState state) throws RulesException;
79 public IRObject getExecutable();
81 public IRObject getNonExecutable();
83 public boolean equals(IRObject o) throws RulesException;
85 public boolean isExecutable();
87 /**
88 * By default, the toString() method for most Objects should provide
89 * a representation of the object that can be used as the postFix value.
90 * The stringValue should provide simply the data for the object. Thus
91 * If I want to append the a String and a Date to create a new string,
92 * I should append the results from their stringValue() implementation.
93 * <br><br>
94 * If I needed the postfix (and thus the quotes and maybe other ) then
95 * call postFix(). But if the postFix is going to match either stringValue()
96 * or toString, it is going to match toString().
97 * <br><br>
98 * @return
100 public String stringValue();
101 public RString rStringValue();
103 public String postFix();
105 public int type();
107 public IRObject rclone();
109 public XMLTag xmlTagValue() throws RulesException;
110 public long longValue () throws RulesException;
111 public int intValue () throws RulesException;
112 public RInteger rIntegerValue() throws RulesException;
113 public double doubleValue () throws RulesException;
114 public RDouble rDoubleValue() throws RulesException;
115 public ArrayList<IRObject> arrayValue () throws RulesException;
116 public RArray rArrayValue() throws RulesException;
117 public boolean booleanValue () throws RulesException;
118 public RBoolean rBooleanValue() throws RulesException;
119 public HashMap hashMapValue () throws RulesException;
120 public RXmlValue rXmlValue () throws RulesException;
121 public IREntity rEntityValue () throws RulesException;
122 public RName rNameValue () throws RulesException;
123 public RTime rTimeValue () throws RulesException;
124 public Date timeValue () throws RulesException;
125 public RTable rTableValue() throws RulesException;
126 public HashMap tableValue() throws RulesException;
127 public int compare(IRObject irObject) throws RulesException;