001: package org.drools.base;
002:
003: /*
004: * Copyright 2005 JBoss Inc
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.util.List;
020:
021: import org.drools.FactException;
022: import org.drools.FactHandle;
023: import org.drools.QueryResults;
024: import org.drools.WorkingMemory;
025: import org.drools.common.InternalWorkingMemoryActions;
026: import org.drools.rule.Declaration;
027: import org.drools.rule.GroupElement;
028: import org.drools.rule.Rule;
029: import org.drools.spi.Activation;
030: import org.drools.spi.AgendaGroup;
031: import org.drools.spi.KnowledgeHelper;
032: import org.drools.spi.Tuple;
033:
034: public class SequentialKnowledgeHelper implements KnowledgeHelper {
035:
036: private static final long serialVersionUID = 400L;
037:
038: private Rule rule;
039: private GroupElement subrule;
040: private Activation activation;
041: private Tuple tuple;
042: private final InternalWorkingMemoryActions workingMemory;
043:
044: public SequentialKnowledgeHelper(final WorkingMemory workingMemory) {
045: this .workingMemory = (InternalWorkingMemoryActions) workingMemory;
046: }
047:
048: public void setActivation(final Activation agendaItem) {
049: this .rule = agendaItem.getRule();
050: this .subrule = agendaItem.getSubRule();
051: this .activation = agendaItem;
052: this .tuple = agendaItem.getTuple();
053: }
054:
055: public void insert(final Object object) throws FactException {
056: }
057:
058: public void insert(final Object object, final boolean dynamic)
059: throws FactException {
060: }
061:
062: public void insertLogical(final Object object) throws FactException {
063: }
064:
065: public void insertLogical(final Object object, final boolean dynamic)
066: throws FactException {
067: }
068:
069: public void update(final FactHandle handle, final Object newObject)
070: throws FactException {
071: }
072:
073: public void update(final Object object) throws FactException {
074: }
075:
076: public void retract(final FactHandle handle) throws FactException {
077: }
078:
079: public void retract(final Object object) throws FactException {
080: }
081:
082: public void modifyRetract(final Object object) {
083: }
084:
085: public void modifyRetract(final FactHandle factHandle) {
086: }
087:
088: public void modifyInsert(final Object object) {
089: }
090:
091: public void modifyInsert(final FactHandle factHandle,
092: final Object object) {
093: }
094:
095: public Rule getRule() {
096: return this .rule;
097: }
098:
099: // public List getObjects() {
100: // return null; //this.workingMemory.getObjects();
101: // }
102: //
103: // public List getObjects(final Class objectClass) {
104: // return null; //this.workingMemory.getObjects( objectClass );
105: // }
106: //
107: // public void clearAgenda() {
108: // this.workingMemory.clearAgenda();
109: // }
110: //
111: // public void clearAgendaGroup(final String group) {
112: // this.workingMemory.clearAgendaGroup( group );
113: // }
114:
115: public Tuple getTuple() {
116: return this .tuple;
117: }
118:
119: public WorkingMemory getWorkingMemory() {
120: return this .workingMemory;
121: }
122:
123: public Activation getActivation() {
124: return this .activation;
125: }
126:
127: // public QueryResults getQueryResults(final String query) {
128: // return this.workingMemory.getQueryResults( query );
129: // }
130: //
131: // public AgendaGroup getFocus() {
132: // return this.workingMemory.getFocus();
133: // }
134: //
135: public void setFocus(final String focus) {
136: this .workingMemory.setFocus(focus);
137: }
138:
139: //
140: // public void setFocus(final AgendaGroup focus) {
141: // this.workingMemory.setFocus( focus );
142: // }
143:
144: public Object get(final Declaration declaration) {
145: return declaration.getValue(workingMemory, this .tuple.get(
146: declaration).getObject());
147: }
148:
149: public Declaration getDeclaration(final String identifier) {
150: return (Declaration) this .subrule.getOuterDeclarations().get(
151: identifier);
152: }
153:
154: public void halt() {
155: this.workingMemory.halt();
156: }
157: }
|