4 package com
.dtrules
.interpreter
;
6 import java
.util
.ArrayList
;
8 import com
.dtrules
.infrastructure
.RulesException
;
9 import com
.dtrules
.mapping
.XMLTag
;
10 import com
.dtrules
.session
.DTState
;
15 * An XmlValue object represents a node in the XML input stream that
16 * supplied data to the Rules Engine. It provides a way to update
17 * and modify that XML based on rules defined in Decision Tables.
20 public class RXmlValue
extends ARObject
{
25 public RXmlValue(DTState state
, XMLTag tag
){
27 id
= state
.getSession().getUniqueID();
31 * Sets the value of an Attribute on the tag for this RXmlValue.
36 public void setAttribute(String attribute
, String value
){
37 tag
.getAttribs().put(attribute
, value
);
41 * Gets the value of an Attribute on the tag for this RXmlValue.
42 * Returns a null if the Attribute isn't defined on this tag.
46 public String
getAttribute(String attribute
){
47 if(!tag
.getAttribs().containsKey(attribute
)){
50 return tag
.getAttribs().get(attribute
).toString();
54 * The following are all the accessors that are suppored
55 * for working with RXmlValue objects
59 * The string value of an XMLTag is its body value
61 public String
stringValue() {
62 return tag
.getBody().toString();
68 public ArrayList
<IRObject
> arrayValue() throws RulesException
{
69 ArrayList
<IRObject
> a
= new ArrayList
<IRObject
>();
70 if(tag
.getTags().size()>0){
71 for(XMLTag t
: tag
.getTags()){
72 a
.add(new RXmlValue(state
,t
));
79 public boolean booleanValue() throws RulesException
{
80 return RBoolean
.booleanValue(tag
.getBody().toString());
84 public double doubleValue() throws RulesException
{
85 return RDouble
.getDoubleValue(tag
.getBody().toString());
89 public boolean equals(IRObject o
) throws RulesException
{
90 return rStringValue().equals(o
);
94 public int intValue() throws RulesException
{
95 return (int)RInteger
.getIntegerValue(tag
.getBody().toString());
100 public long longValue() throws RulesException
{
101 return RInteger
.getIntegerValue(tag
.getBody().toString());
105 public RBoolean
rBooleanValue() throws RulesException
{
106 return RBoolean
.getRBoolean(booleanValue());
110 public RDouble
rDoubleValue() throws RulesException
{
111 return RDouble
.getRDoubleValue(doubleValue());
115 public RInteger
rIntegerValue() throws RulesException
{
116 return RInteger
.getRIntegerValue(longValue());
120 public RName
rNameValue() throws RulesException
{
121 return RName
.getRName(stringValue(),false);
124 public RString
rStringValue() {
125 return RString
.newRString(stringValue());
128 public RTime
rTimeValue() throws RulesException
{
129 return RTime
.getRTime(timeValue());
132 public Date
timeValue() throws RulesException
{
133 return RTime
.getDate(tag
.getBody().toString());
137 * @see com.dtrules.interpreter.ARObject#rXmlValue()
140 public RXmlValue
rXmlValue() throws RulesException
{
145 * @see com.dtrules.interpreter.ARObject#xmlTagValue()
148 public XMLTag
xmlTagValue() throws RulesException
{