1 /*
   2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.rngom.digested;
  27 
  28 import com.sun.xml.internal.rngom.ast.om.Location;
  29 import com.sun.xml.internal.rngom.parse.Context;
  30 
  31 import java.util.ArrayList;
  32 import java.util.List;
  33 
  34 /**
  35  * @author Kohsuke Kawaguchi (kk@kohsuke.org)
  36  */
  37 public class DDataPattern extends DPattern {
  38     DPattern except;
  39 
  40     String datatypeLibrary;
  41     String type;
  42 
  43     final List<Param> params = new ArrayList<Param>();
  44 
  45     /**
  46      * Parameter to a data pattern.
  47      */
  48     public final class Param {
  49         String name;
  50         String value;
  51         Context context;
  52         String ns;
  53         Location loc;
  54         Annotation anno;
  55 
  56         public Param(String name, String value, Context context, String ns, Location loc, Annotation anno) {
  57             this.name = name;
  58             this.value = value;
  59             this.context = context;
  60             this.ns = ns;
  61             this.loc = loc;
  62             this.anno = anno;
  63         }
  64 
  65         public String getName() {
  66             return name;
  67         }
  68 
  69         public String getValue() {
  70             return value;
  71         }
  72 
  73         public Context getContext() {
  74             return context;
  75         }
  76 
  77         public String getNs() {
  78             return ns;
  79         }
  80 
  81         public Location getLoc() {
  82             return loc;
  83         }
  84 
  85         public Annotation getAnno() {
  86             return anno;
  87         }
  88     }
  89 
  90     /**
  91      * Gets the datatype library URI.
  92      *
  93      * @return
  94      *      Can be empty (which represents the built-in datatypes), but never null.
  95      */
  96     public String getDatatypeLibrary() {
  97         return datatypeLibrary;
  98     }
  99 
 100     /**
 101      * Gets the datatype name, such as "int" or "token".
 102      *
 103      * @return
 104      *      never null.
 105      */
 106     public String getType() {
 107         return type;
 108     }
 109 
 110     /**
 111      * Gets the parameters of this &lt;data pattern.
 112      *
 113      * @return
 114      *      can be empty but never null.
 115      */
 116     public List<Param> getParams() {
 117         return params;
 118     }
 119 
 120     /**
 121      * Gets the pattern that reprsents the &lt;except> child of this data pattern.
 122      *
 123      * @return null if not exist.
 124      */
 125     public DPattern getExcept() {
 126         return except;
 127     }
 128 
 129     public boolean isNullable() {
 130         return false;
 131     }
 132 
 133     public Object accept( DPatternVisitor visitor ) {
 134         return visitor.onData(this);
 135     }
 136 }