aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.xml.internal.xsom; aoqi@0: aoqi@0: import com.sun.xml.internal.xsom.visitor.XSSimpleTypeFunction; aoqi@0: import com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor; aoqi@0: aoqi@0: import java.util.List; aoqi@0: aoqi@0: /** aoqi@0: * Simple type. aoqi@0: * aoqi@0: * @author aoqi@0: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) aoqi@0: */ aoqi@0: public interface XSSimpleType extends XSType, XSContentType aoqi@0: { aoqi@0: /** aoqi@0: * Gets the base type as XSSimpleType. aoqi@0: * aoqi@0: * Equivalent to aoqi@0: * aoqi@0: * (XSSimpleType)getBaseType() aoqi@0: * aoqi@0: * Since this is a simple type, we know that the base type aoqi@0: * is also a simple type. aoqi@0: * aoqi@0: * The only exception is xs:anySimpleType, which has xs:anyType aoqi@0: * as the base type. aoqi@0: * aoqi@0: * @return aoqi@0: * null if this is xs:anySimpleType. Otherwise non-null. aoqi@0: */ aoqi@0: XSSimpleType getSimpleBaseType(); aoqi@0: aoqi@0: /** aoqi@0: * Gets the variety of this simple type. aoqi@0: */ aoqi@0: XSVariety getVariety(); aoqi@0: aoqi@0: /** aoqi@0: * Gets the ancestor primitive {@link XSSimpleType} if aoqi@0: * this type is {@link XSVariety#ATOMIC atomic}. aoqi@0: * aoqi@0: * @return aoqi@0: * null otherwise. aoqi@0: */ aoqi@0: XSSimpleType getPrimitiveType(); aoqi@0: aoqi@0: /** aoqi@0: * Returns true if this is a primitive built-in simple type aoqi@0: * (that directly derives from xs:anySimpleType, by definition.) aoqi@0: */ aoqi@0: boolean isPrimitive(); aoqi@0: aoqi@0: /** aoqi@0: * Gets the nearest ancestor {@link XSListSimpleType} (including itself) aoqi@0: * if the variety of this type is {@link XSVariety#LIST list}. aoqi@0: * aoqi@0: * @return otherwise return null aoqi@0: */ aoqi@0: XSListSimpleType getBaseListType(); aoqi@0: aoqi@0: /** aoqi@0: * Gets the nearest ancestor {@link XSUnionSimpleType} (including itself) aoqi@0: * if the variety of this type is {@link XSVariety#UNION union}. aoqi@0: * aoqi@0: * @return otherwise return null aoqi@0: */ aoqi@0: XSUnionSimpleType getBaseUnionType(); aoqi@0: aoqi@0: /** aoqi@0: * Returns true if this type definition is marked as 'final' aoqi@0: * with respect to the given {@link XSVariety}. aoqi@0: * aoqi@0: * @return aoqi@0: * true if the type is marked final. aoqi@0: */ aoqi@0: boolean isFinal(XSVariety v); aoqi@0: aoqi@0: /** aoqi@0: * If this {@link XSSimpleType} is redefined by another simple type, aoqi@0: * return that component. aoqi@0: * aoqi@0: * @return null aoqi@0: * if this component has not been redefined. aoqi@0: */ aoqi@0: public XSSimpleType getRedefinedBy(); aoqi@0: aoqi@0: /** aoqi@0: * Gets the effective facet object of the given name. aoqi@0: * aoqi@0: *

aoqi@0: * For example, if a simple type "foo" is derived from aoqi@0: * xs:string by restriction with the "maxLength" facet and aoqi@0: * another simple type "bar" is derived from "foo" by aoqi@0: * restriction with another "maxLength" facet, this method aoqi@0: * will return the latter one, because that is the most aoqi@0: * restrictive, effective facet. aoqi@0: * aoqi@0: *

aoqi@0: * For those facets that can have multiple values aoqi@0: * (pattern facets and enumeration facets), this method aoqi@0: * will return only the first one. aoqi@0: * TODO: allow clients to access all of them by some means. aoqi@0: * aoqi@0: * @return aoqi@0: * If this datatype has a facet of the given name, aoqi@0: * return that object. If the facet is not specified aoqi@0: * anywhere in its derivation chain, null will be returned. aoqi@0: */ aoqi@0: XSFacet getFacet( String name ); aoqi@0: aoqi@0: /** aoqi@0: * For multi-valued facets (enumeration and pattern), obtain all values. aoqi@0: * aoqi@0: * @see #getFacet(String) aoqi@0: * aoqi@0: * @return aoqi@0: * can be empty but never null. aoqi@0: */ aoqi@0: List getFacets( String name ); aoqi@0: aoqi@0: aoqi@0: aoqi@0: void visit( XSSimpleTypeVisitor visitor ); aoqi@0: T apply( XSSimpleTypeFunction function ); aoqi@0: aoqi@0: /** Returns true if this instanceof XSRestrictionSimpleType. */ aoqi@0: boolean isRestriction(); aoqi@0: /** Returns true if this instanceof XSListSimpleType. */ aoqi@0: boolean isList(); aoqi@0: /** Returns true if this instanceof XSUnionSimpleType. */ aoqi@0: boolean isUnion(); aoqi@0: aoqi@0: XSRestrictionSimpleType asRestriction(); aoqi@0: XSListSimpleType asList(); aoqi@0: XSUnionSimpleType asUnion(); aoqi@0: }