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/RefAttributeSchemaNodeImpl.java $
03: * $Id: RefAttributeSchemaNodeImpl.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 RefAttributeSchemaNodeImpl extends RefSchemaNodeImpl {
28: protected final Log logger = LogFactory.getLog(getClass());
29: private boolean required = false;
30:
31: public RefAttributeSchemaNodeImpl(String refName,
32: Element schemaElement, SchemaNodeImpl.GlobalMaps globalMaps)
33: throws SchemaInvalidException {
34: super (refName, schemaElement, globalMaps);
35: required = "required".equals(getSchemaElement()
36: .getAttributeValue("use"));
37: }
38:
39: /**
40: * Retuns the max number of times the element
41: * defined by this node can occur in its parent.
42: * The root schema will always return 1 here.
43: *
44: * @return
45: */
46: public int getMaxOccurs() {
47: return 1;
48: }
49:
50: /**
51: * Returns the min number of times the element
52: * defined by this node can occur in its parent.
53: * The root schema will always return 1 here.
54: *
55: * @return
56: */
57: public int getMinOccurs() {
58: return required ? 1 : 0;
59: }
60:
61: public boolean isAttribute() {
62: return true;
63: }
64: }
|