325N/A/*
325N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.xml.internal.xsom;
325N/A
325N/Aimport com.sun.xml.internal.xsom.visitor.XSSimpleTypeFunction;
325N/Aimport com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor;
325N/A
325N/Aimport java.util.List;
325N/A
325N/A/**
325N/A * Simple type.
325N/A *
325N/A * @author
325N/A * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
325N/A */
325N/Apublic interface XSSimpleType extends XSType, XSContentType
325N/A{
325N/A /**
325N/A * Gets the base type as XSSimpleType.
325N/A *
325N/A * Equivalent to
325N/A * <code>
325N/A * (XSSimpleType)getBaseType()
325N/A * </code>
325N/A * Since this is a simple type, we know that the base type
325N/A * is also a simple type.
325N/A *
325N/A * The only exception is xs:anySimpleType, which has xs:anyType
325N/A * as the base type.
325N/A *
325N/A * @return
325N/A * null if this is xs:anySimpleType. Otherwise non-null.
325N/A */
325N/A XSSimpleType getSimpleBaseType();
325N/A
325N/A /**
325N/A * Gets the variety of this simple type.
325N/A */
325N/A XSVariety getVariety();
325N/A
325N/A /**
325N/A * Gets the ancestor primitive {@link XSSimpleType} if
325N/A * this type is {@link XSVariety#ATOMIC atomic}.
325N/A *
325N/A * @return
325N/A * null otherwise.
325N/A */
325N/A XSSimpleType getPrimitiveType();
325N/A
325N/A /**
325N/A * Returns true if this is a primitive built-in simple type
325N/A * (that directly derives from xs:anySimpleType, by definition.)
325N/A */
325N/A boolean isPrimitive();
325N/A
325N/A /**
325N/A * Gets the nearest ancestor {@link XSListSimpleType} (including itself)
325N/A * if the variety of this type is {@link XSVariety#LIST list}.
325N/A *
325N/A * @return otherwise return null
325N/A */
325N/A XSListSimpleType getBaseListType();
325N/A
325N/A /**
325N/A * Gets the nearest ancestor {@link XSUnionSimpleType} (including itself)
325N/A * if the variety of this type is {@link XSVariety#UNION union}.
325N/A *
325N/A * @return otherwise return null
325N/A */
325N/A XSUnionSimpleType getBaseUnionType();
325N/A
325N/A /**
325N/A * Returns true if this type definition is marked as 'final'
325N/A * with respect to the given {@link XSVariety}.
325N/A *
325N/A * @return
325N/A * true if the type is marked final.
325N/A */
325N/A boolean isFinal(XSVariety v);
325N/A
325N/A /**
325N/A * If this {@link XSSimpleType} is redefined by another simple type,
325N/A * return that component.
325N/A *
325N/A * @return null
325N/A * if this component has not been redefined.
325N/A */
325N/A public XSSimpleType getRedefinedBy();
325N/A
325N/A /**
325N/A * Gets the effective facet object of the given name.
325N/A *
325N/A * <p>
325N/A * For example, if a simple type "foo" is derived from
325N/A * xs:string by restriction with the "maxLength" facet and
325N/A * another simple type "bar" is derived from "foo" by
325N/A * restriction with another "maxLength" facet, this method
325N/A * will return the latter one, because that is the most
325N/A * restrictive, effective facet.
325N/A *
325N/A * <p>
325N/A * For those facets that can have multiple values
325N/A * (pattern facets and enumeration facets), this method
325N/A * will return only the first one.
325N/A * TODO: allow clients to access all of them by some means.
325N/A *
325N/A * @return
325N/A * If this datatype has a facet of the given name,
325N/A * return that object. If the facet is not specified
325N/A * anywhere in its derivation chain, null will be returned.
325N/A */
325N/A XSFacet getFacet( String name );
325N/A
325N/A /**
325N/A * For multi-valued facets (enumeration and pattern), obtain all values.
325N/A *
325N/A * @see #getFacet(String)
325N/A *
325N/A * @return
325N/A * can be empty but never null.
325N/A */
325N/A List<XSFacet> getFacets( String name );
325N/A
325N/A
325N/A
325N/A void visit( XSSimpleTypeVisitor visitor );
325N/A <T> T apply( XSSimpleTypeFunction<T> function );
325N/A
325N/A /** Returns true if <code>this instanceof XSRestrictionSimpleType</code>. */
325N/A boolean isRestriction();
325N/A /** Returns true if <code>this instanceof XSListSimpleType</code>. */
325N/A boolean isList();
325N/A /** Returns true if <code>this instanceof XSUnionSimpleType</code>. */
325N/A boolean isUnion();
325N/A
325N/A XSRestrictionSimpleType asRestriction();
325N/A XSListSimpleType asList();
325N/A XSUnionSimpleType asUnion();
325N/A}