KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > relaxng > impl > DataDataDerivType


1 package com.thaiopensource.relaxng.impl;
2
3 import org.relaxng.datatype.Datatype;
4 import org.relaxng.datatype.ValidationContext;
5
6 class DataDataDerivType extends DataDerivType {
7   private final Datatype dt;
8   private PatternMemo validMemo;
9   private PatternMemo invalidMemo;
10
11   DataDataDerivType(Datatype dt) {
12     this.dt = dt;
13   }
14
15   PatternMemo dataDeriv(ValidatorPatternBuilder builder, Pattern p, String JavaDoc str, ValidationContext vc) {
16     if (dt.isValid(str, vc)) {
17       if (validMemo == null)
18         validMemo = super.dataDeriv(builder, p, str, vc);
19       return validMemo;
20     }
21     else {
22       if (invalidMemo == null)
23         invalidMemo = super.dataDeriv(builder, p, str, vc);
24       return invalidMemo;
25     }
26   }
27
28   DataDerivType copy() {
29     return new DataDataDerivType(dt);
30   }
31
32   DataDerivType combine(DataDerivType ddt) {
33     if (ddt instanceof DataDataDerivType) {
34       if (((DataDataDerivType)ddt).dt == dt)
35         return this;
36       return InconsistentDataDerivType.getInstance();
37     }
38     if (ddt instanceof ValueDataDerivType) {
39       if (((ValueDataDerivType)ddt).getDatatype() == dt)
40         return ddt;
41       return InconsistentDataDerivType.getInstance();
42     }
43     return ddt.combine(this);
44   }
45 }
Popular Tags