01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-impl/api-impl/src/java/org/sakaiproject/metaobj/utils/xml/impl/AttributeSchemaNodeImpl.java $
03: * $Id: AttributeSchemaNodeImpl.java 14225 2006-09-05 17:39:44Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.metaobj.utils.xml.impl;
21:
22: import org.apache.commons.logging.Log;
23: import org.apache.commons.logging.LogFactory;
24: import org.jdom.Element;
25: import org.sakaiproject.metaobj.utils.xml.SchemaInvalidException;
26:
27: public class AttributeSchemaNodeImpl extends SimpleSchemaNodeImpl {
28: protected final Log logger = LogFactory.getLog(getClass());
29: private boolean required = false;
30:
31: public AttributeSchemaNodeImpl(Element schemaElement,
32: SchemaNodeImpl.GlobalMaps globalMaps, boolean isAttribute)
33: throws SchemaInvalidException {
34: super (schemaElement, globalMaps, isAttribute);
35: required = "required".equals(getSchemaElement()
36: .getAttributeValue("use"));
37: }
38:
39: protected void initSchemaElement() {
40: super .initSchemaElement();
41: }
42:
43: /**
44: * Retuns the max number of times the element
45: * defined by this node can occur in its parent.
46: * The root schema will always return 1 here.
47: *
48: * @return
49: */
50: public int getMaxOccurs() {
51: return 1;
52: }
53:
54: /**
55: * Returns the min number of times the element
56: * defined by this node can occur in its parent.
57: * The root schema will always return 1 here.
58: *
59: * @return
60: */
61: public int getMinOccurs() {
62: return required ? 1 : 0;
63: }
64: }
|