KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.thaiopensource.relaxng.impl;
2
3 import org.xml.sax.Locator JavaDoc;
4 import org.xml.sax.SAXException JavaDoc;
5 import org.xml.sax.SAXParseException JavaDoc;
6
7 class RefPattern extends Pattern {
8   private Pattern p;
9   private Locator JavaDoc refLoc;
10   private final String JavaDoc name;
11   private int checkRecursionDepth = -1;
12   private boolean combineImplicit = false;
13   private byte combineType = COMBINE_NONE;
14   private byte replacementStatus = REPLACEMENT_KEEP;
15   private boolean expanded = false;
16
17   static final byte REPLACEMENT_KEEP = 0;
18   static final byte REPLACEMENT_REQUIRE = 1;
19   static final byte REPLACEMENT_IGNORE = 2;
20
21   static final byte COMBINE_NONE = 0;
22   static final byte COMBINE_CHOICE = 1;
23   static final byte COMBINE_INTERLEAVE = 2;
24
25   RefPattern(String JavaDoc name) {
26     this.name = name;
27   }
28
29   Pattern getPattern() {
30     return p;
31   }
32   
33   void setPattern(Pattern p) {
34     this.p = p;
35   }
36
37   Locator JavaDoc getRefLocator() {
38     return refLoc;
39   }
40   
41   void setRefLocator(Locator JavaDoc loc) {
42     this.refLoc = loc;
43   }
44   
45   void checkRecursion(int depth) throws SAXException JavaDoc {
46     if (checkRecursionDepth == -1) {
47       checkRecursionDepth = depth;
48       p.checkRecursion(depth);
49       checkRecursionDepth = -2;
50     }
51     else if (depth == checkRecursionDepth)
52       // XXX try to recover from this?
53
throw new SAXParseException JavaDoc(SchemaBuilderImpl.localizer.message("recursive_reference", name),
54                   refLoc);
55   }
56
57   Pattern expand(SchemaPatternBuilder b) {
58     if (!expanded) {
59       p = p.expand(b);
60       expanded = true;
61     }
62     return p;
63   }
64
65   boolean samePattern(Pattern other) {
66     return false;
67   }
68
69   void accept(PatternVisitor visitor) {
70     p.accept(visitor);
71   }
72
73   Object JavaDoc apply(PatternFunction f) {
74     return f.caseRef(this);
75   }
76
77   byte getReplacementStatus() {
78     return replacementStatus;
79   }
80   
81   void setReplacementStatus(byte replacementStatus) {
82     this.replacementStatus = replacementStatus;
83   }
84
85   boolean isCombineImplicit() {
86     return combineImplicit;
87   }
88
89   void setCombineImplicit() {
90     combineImplicit = true;
91   }
92
93   byte getCombineType() {
94     return combineType;
95   }
96
97   void setCombineType(byte combineType) {
98     this.combineType = combineType;
99   }
100
101   String JavaDoc getName() {
102     return name;
103   }
104 }
105
106
Popular Tags