DDefine.java revision 325
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows/*
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * This code is free software; you can redistribute it and/or modify it
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * under the terms of the GNU General Public License version 2 only, as
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * published by the Free Software Foundation. Oracle designates this
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * particular file as subject to the "Classpath" exception as provided
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * by Oracle in the LICENSE file that accompanied this code.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * This code is distributed in the hope that it will be useful, but WITHOUT
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * version 2 for more details (a copy is included in the LICENSE file that
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * accompanied this code).
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * You should have received a copy of the GNU General Public License version
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * 2 along with this work; if not, write to the Free Software Foundation,
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * or visit www.oracle.com if you need additional information or have any
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * questions.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows */
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows/*
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Copyright (C) 2004-2011
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Permission is hereby granted, free of charge, to any person obtaining a copy
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * of this software and associated documentation files (the "Software"), to deal
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * in the Software without restriction, including without limitation the rights
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * copies of the Software, and to permit persons to whom the Software is
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * furnished to do so, subject to the following conditions:
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * The above copyright notice and this permission notice shall be included in
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * all copies or substantial portions of the Software.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2d2a52253051eb056ca017546a076c0f585283f2stephh * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * THE SOFTWARE.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
749f21d359d8fbd020c974a1a5227316221bfc9cwesolowspackage com.sun.xml.internal.rngom.digested;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby/**
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * @author Kohsuke Kawaguchi (kk@kohsuke.org)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby */
749f21d359d8fbd020c974a1a5227316221bfc9cwesolowspublic class DDefine {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows private final String name;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows private DPattern pattern;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby private Boolean nullable;
2d2a52253051eb056ca017546a076c0f585283f2stephh DAnnotation annotation;
2d2a52253051eb056ca017546a076c0f585283f2stephh
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public DDefine(String name) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows this.name = name;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows }
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public DPattern getPattern() {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows return pattern;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows }
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public DAnnotation getAnnotation() {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows if(annotation==null)
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows return DAnnotation.EMPTY;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows return annotation;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows }
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public void setPattern(DPattern pattern) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows this.pattern = pattern;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows this.nullable = null;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows }
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows /**
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Gets the name of the pattern block.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows */
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public String getName() {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows return name;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows }
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows public boolean isNullable() {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows if(nullable==null)
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows nullable = pattern.isNullable()?Boolean.TRUE:Boolean.FALSE;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows return nullable.booleanValue();
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows }
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows}
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows