jaxws/src/jdk.xml.bind/share/classes/com/sun/xml/internal/org/relaxng/datatype/helpers/ParameterlessDatatypeBuilder.java
changeset 32904 42076a665ea1
parent 32795 5a5710ee05a0
child 33547 e4c76ac38b12
equal deleted inserted replaced
32803:51b2db2fa04c 32904:42076a665ea1
       
     1 /*
       
     2  * Copyright (c) 2005, 2015, Thai Open Source Software Center Ltd
       
     3  * All rights reserved.
       
     4  *
       
     5  * Redistribution and use in source and binary forms, with or without
       
     6  * modification, are permitted provided that the following conditions are
       
     7  * met:
       
     8  *
       
     9  *     Redistributions of source code must retain the above copyright
       
    10  *     notice, this list of conditions and the following disclaimer.
       
    11  *
       
    12  *     Redistributions in binary form must reproduce the above copyright
       
    13  *     notice, this list of conditions and the following disclaimer in
       
    14  *     the documentation and/or other materials provided with the
       
    15  *     distribution.
       
    16  *
       
    17  *     Neither the name of the Thai Open Source Software Center Ltd nor
       
    18  *     the names of its contributors may be used to endorse or promote
       
    19  *     products derived from this software without specific prior written
       
    20  *     permission.
       
    21  *
       
    22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
       
    23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
       
    24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
       
    25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
       
    26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       
    27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       
    28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       
    29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
       
    30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
       
    31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
       
    32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    33  */
       
    34 
       
    35 package com.sun.xml.internal.org.relaxng.datatype.helpers;
       
    36 
       
    37 import com.sun.xml.internal.org.relaxng.datatype.*;
       
    38 
       
    39 /**
       
    40  * Dummy implementation of {@link DatatypeBuilder}.
       
    41  *
       
    42  * This implementation can be used for Datatypes which have no parameters.
       
    43  * Any attempt to add parameters will be rejected.
       
    44  *
       
    45  * <p>
       
    46  * Typical usage would be:
       
    47  * <PRE>{@code
       
    48  * class MyDatatypeLibrary implements DatatypeLibrary {
       
    49  *     ....
       
    50  *     DatatypeBuilder createDatatypeBuilder( String typeName ) {
       
    51  *         return new ParameterleessDatatypeBuilder(createDatatype(typeName));
       
    52  *     }
       
    53  *     ....
       
    54  * }
       
    55  * }</PRE>
       
    56  *
       
    57  * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
       
    58  */
       
    59 public final class ParameterlessDatatypeBuilder implements DatatypeBuilder {
       
    60 
       
    61         /** This type object is returned for the derive method. */
       
    62         private final Datatype baseType;
       
    63 
       
    64         public ParameterlessDatatypeBuilder( Datatype baseType ) {
       
    65                 this.baseType = baseType;
       
    66         }
       
    67 
       
    68         public void addParameter( String name, String strValue, ValidationContext context )
       
    69                         throws DatatypeException {
       
    70                 throw new DatatypeException();
       
    71         }
       
    72 
       
    73         public Datatype createDatatype() throws DatatypeException {
       
    74                 return baseType;
       
    75         }
       
    76 }