001: package org.kohsuke.rngom.digested;
002:
003: import org.kohsuke.rngom.ast.om.Location;
004: import org.kohsuke.rngom.parse.Context;
005:
006: import java.util.ArrayList;
007: import java.util.List;
008:
009: /**
010: * @author Kohsuke Kawaguchi (kk@kohsuke.org)
011: */
012: public class DDataPattern extends DPattern {
013: DPattern except;
014:
015: String datatypeLibrary;
016: String type;
017:
018: final List<Param> params = new ArrayList<Param>();
019:
020: /**
021: * Parameter to a data pattern.
022: */
023: public final class Param {
024: String name;
025: String value;
026: Context context;
027: String ns;
028: Location loc;
029: Annotation anno;
030:
031: public Param(String name, String value, Context context,
032: String ns, Location loc, Annotation anno) {
033: this .name = name;
034: this .value = value;
035: this .context = context;
036: this .ns = ns;
037: this .loc = loc;
038: this .anno = anno;
039: }
040:
041: public String getName() {
042: return name;
043: }
044:
045: public String getValue() {
046: return value;
047: }
048:
049: public Context getContext() {
050: return context;
051: }
052:
053: public String getNs() {
054: return ns;
055: }
056:
057: public Location getLoc() {
058: return loc;
059: }
060:
061: public Annotation getAnno() {
062: return anno;
063: }
064: }
065:
066: /**
067: * Gets the datatype library URI.
068: *
069: * @return
070: * Can be empty (which represents the built-in datatypes), but never null.
071: */
072: public String getDatatypeLibrary() {
073: return datatypeLibrary;
074: }
075:
076: /**
077: * Gets the datatype name, such as "int" or "token".
078: *
079: * @return
080: * never null.
081: */
082: public String getType() {
083: return type;
084: }
085:
086: /**
087: * Gets the parameters of this <data pattern.
088: *
089: * @return
090: * can be empty but never null.
091: */
092: public List<Param> getParams() {
093: return params;
094: }
095:
096: /**
097: * Gets the pattern that reprsents the <except> child of this data pattern.
098: *
099: * @return null if not exist.
100: */
101: public DPattern getExcept() {
102: return except;
103: }
104:
105: public boolean isNullable() {
106: return false;
107: }
108:
109: public Object accept(DPatternVisitor visitor) {
110: return visitor.onData(this);
111: }
112: }
|