001: package example.nz.org.take.compiler.userv.generated;
002:
003: import nz.org.take.rt.*;
004:
005: /**
006: * Class generated by the take compiler.
007: * @version Mon Feb 11 13:49:16 NZDT 2008
008: */
009: @SuppressWarnings("unchecked")
010: class KBFragement_getBasePremium {
011: /**
012: * Method generated for query /basePremium[in,out]
013: * @param car input parameter generated from slot 0
014: * @return an iterator for instances of BasePremium
015: */
016: public static ResultSet<BasePremium> getBasePremium(
017: final example.nz.org.take.compiler.userv.domainmodel.Car car) {
018: DerivationController _derivation = new DefaultDerivationController();
019: ResultSet<BasePremium> _result = new ResultSet(
020: KBFragement_getBasePremium.getBasePremium(car,
021: _derivation), _derivation);
022:
023: return _result;
024: }
025:
026: /**
027: * Method generated for query /basePremium[in,out]
028: * @param car input parameter generated from slot 0
029: * @return an iterator for instances of BasePremium
030: */
031: static ResourceIterator<BasePremium> getBasePremium(
032: final example.nz.org.take.compiler.userv.domainmodel.Car car,
033: final DerivationController _derivation) {
034: final int _derivationlevel = _derivation.getDepth();
035: ResourceIterator<BasePremium> result = new IteratorChain<BasePremium>(
036: 3) {
037: public Object getIteratorOrObject(int pos) {
038: switch (pos) {
039: // AP_01 IF isCompact(<car>) THEN /basePremium(<car>,250)
040: case 0:
041: return getBasePremium_0(car, _derivation
042: .reset(_derivationlevel));
043:
044: // AP_02 IF isSedan(<car>) THEN /basePremium(<car>,400)
045: case 1:
046: return getBasePremium_1(car, _derivation
047: .reset(_derivationlevel));
048:
049: // AP_03 IF isLuxury(<car>) THEN /basePremium(<car>,500)
050: case 2:
051: return getBasePremium_2(car, _derivation
052: .reset(_derivationlevel));
053:
054: default:
055: return EmptyIterator.DEFAULT;
056: } // switch(pos)
057: } // getIterator()
058:
059: public String getRuleRef(int pos) {
060: switch (pos) {
061: // AP_01 IF isCompact(<car>) THEN /basePremium(<car>,250)
062: case 0:
063: return "AP_01";
064:
065: // AP_02 IF isSedan(<car>) THEN /basePremium(<car>,400)
066: case 1:
067: return "AP_02";
068:
069: // AP_03 IF isLuxury(<car>) THEN /basePremium(<car>,500)
070: case 2:
071: return "AP_03";
072:
073: default:
074: return "";
075: } // switch(pos)
076: } // getRuleRef()
077: };
078:
079: return result;
080: }
081:
082: /**
083: * Method generated for query /basePremium[in,out]
084: * @param car input parameter generated from slot 0
085: * @return an iterator for instances of BasePremium
086: */
087: private static ResourceIterator<BasePremium> getBasePremium_0(
088: final example.nz.org.take.compiler.userv.domainmodel.Car car,
089: final DerivationController _derivation) {
090: _derivation.log("AP_01", DerivationController.RULE, car,
091: DerivationController.NIL);
092:
093: // Variable bindings in rule: IF isCompact(<car>) THEN /basePremium(<car>,250)
094: class bindingsInRule39 {
095: // Property generated for term "<car>"
096: example.nz.org.take.compiler.userv.domainmodel.Car p1;
097:
098: // Property generated for term "250"
099: long p2;
100: }
101: ;
102:
103: final bindingsInRule39 bindings = new bindingsInRule39();
104: bindings.p1 = car;
105: bindings.p2 = 250;
106:
107: // code for prereq isCompact(<car>)
108: final ResourceIterator<isCompact> iterator1 = KBFragement_isCompact_1
109: .isCompact_1(car, _derivation.increaseDepth());
110:
111: // code for prereq /basePremium(<car>,250)
112: final ResourceIterator<BasePremium> iterator2 = new NestedIterator<isCompact, BasePremium>(
113: iterator1) {
114: public ResourceIterator<BasePremium> getNextIterator(
115: isCompact object) {
116: bindings.p1 = object.slot1;
117:
118: return new SingletonIterator(new BasePremium(
119: bindings.p1, bindings.p2));
120: }
121: };
122:
123: return iterator2;
124: }
125:
126: /**
127: * Method generated for query /basePremium[in,out]
128: * @param car input parameter generated from slot 0
129: * @return an iterator for instances of BasePremium
130: */
131: private static ResourceIterator<BasePremium> getBasePremium_1(
132: final example.nz.org.take.compiler.userv.domainmodel.Car car,
133: final DerivationController _derivation) {
134: _derivation.log("AP_02", DerivationController.RULE, car,
135: DerivationController.NIL);
136:
137: // Variable bindings in rule: IF isSedan(<car>) THEN /basePremium(<car>,400)
138: class bindingsInRule40 {
139: // Property generated for term "400"
140: long p1;
141:
142: // Property generated for term "<car>"
143: example.nz.org.take.compiler.userv.domainmodel.Car p2;
144: }
145: ;
146:
147: final bindingsInRule40 bindings = new bindingsInRule40();
148: bindings.p1 = 400;
149: bindings.p2 = car;
150:
151: // code for prereq isSedan(<car>)
152: final ResourceIterator<isSedan> iterator1 = KBFragement_isSedan_1
153: .isSedan_1(car, _derivation.increaseDepth());
154:
155: // code for prereq /basePremium(<car>,400)
156: final ResourceIterator<BasePremium> iterator2 = new NestedIterator<isSedan, BasePremium>(
157: iterator1) {
158: public ResourceIterator<BasePremium> getNextIterator(
159: isSedan object) {
160: bindings.p2 = object.slot1;
161:
162: return new SingletonIterator(new BasePremium(
163: bindings.p2, bindings.p1));
164: }
165: };
166:
167: return iterator2;
168: }
169:
170: /**
171: * Method generated for query /basePremium[in,out]
172: * @param car input parameter generated from slot 0
173: * @return an iterator for instances of BasePremium
174: */
175: private static ResourceIterator<BasePremium> getBasePremium_2(
176: final example.nz.org.take.compiler.userv.domainmodel.Car car,
177: final DerivationController _derivation) {
178: _derivation.log("AP_03", DerivationController.RULE, car,
179: DerivationController.NIL);
180:
181: // Variable bindings in rule: IF isLuxury(<car>) THEN /basePremium(<car>,500)
182: class bindingsInRule41 {
183: // Property generated for term "<car>"
184: example.nz.org.take.compiler.userv.domainmodel.Car p1;
185:
186: // Property generated for term "500"
187: long p2;
188: }
189: ;
190:
191: final bindingsInRule41 bindings = new bindingsInRule41();
192: bindings.p1 = car;
193: bindings.p2 = 500;
194:
195: // code for prereq isLuxury(<car>)
196: final ResourceIterator<isLuxury> iterator1 = KBFragement_isLuxury_1
197: .isLuxury_1(car, _derivation.increaseDepth());
198:
199: // code for prereq /basePremium(<car>,500)
200: final ResourceIterator<BasePremium> iterator2 = new NestedIterator<isLuxury, BasePremium>(
201: iterator1) {
202: public ResourceIterator<BasePremium> getNextIterator(
203: isLuxury object) {
204: bindings.p1 = object.slot1;
205:
206: return new SingletonIterator(new BasePremium(
207: bindings.p1, bindings.p2));
208: }
209: };
210:
211: return iterator2;
212: }
213: }
|