001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-impl/api-impl/src/java/org/sakaiproject/metaobj/utils/xml/impl/RefSchemaNodeImpl.java $
003: * $Id: RefSchemaNodeImpl.java 14225 2006-09-05 17:39:44Z chmaurer@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.metaobj.utils.xml.impl;
021:
022: import java.util.List;
023: import java.util.Map;
024:
025: import org.jdom.Element;
026: import org.sakaiproject.metaobj.utils.xml.ElementType;
027: import org.sakaiproject.metaobj.utils.xml.NormalizationException;
028: import org.sakaiproject.metaobj.utils.xml.SchemaInvalidException;
029: import org.sakaiproject.metaobj.utils.xml.SchemaNode;
030: import org.sakaiproject.metaobj.utils.xml.ValidatedNode;
031:
032: /**
033: * Created by IntelliJ IDEA.
034: * User: John Ellis
035: * Date: Apr 15, 2004
036: * Time: 6:53:25 PM
037: * To change this template use File | Settings | File Templates.
038: */
039: public class RefSchemaNodeImpl extends SchemaNodeImpl {
040:
041: private String refName = null;
042: private Map localGlobalElements;
043:
044: public RefSchemaNodeImpl(String refName, Element schemaElement,
045: GlobalMaps globalMaps) throws SchemaInvalidException {
046: super (schemaElement, globalMaps);
047: localGlobalElements = globalMaps.globalElements;
048: this .refName = refName;
049: }
050:
051: protected SchemaNode getActualNode() {
052: return (SchemaNode) localGlobalElements.get(refName);
053: }
054:
055: /**
056: * Validates the passed in node and all children.
057: * Will also normalize any values.
058: *
059: * @param node a jdom element to validate
060: * @return the validated Element wrapped
061: * in a ValidatedNode class
062: */
063: public ValidatedNode validateAndNormalize(Element node) {
064: return getActualNode().validateAndNormalize(node);
065: }
066:
067: /**
068: * Gets the schema object for the named child node.
069: *
070: * @param elementName the name of the schema node to retrive.
071: * @return
072: */
073: public SchemaNode getChild(String elementName) {
074: return getActualNode().getChild(elementName);
075: }
076:
077: public String getSchemaNormalizedValue(Object value)
078: throws NormalizationException {
079: return getActualNode().getSchemaNormalizedValue(value);
080: }
081:
082: public Object getActualNormalizedValue(String value)
083: throws NormalizationException {
084: return getActualNode().getActualNormalizedValue(value);
085: }
086:
087: public List getChildren() {
088: return getActualNode().getChildren();
089: }
090:
091: public ElementType getType() {
092: if (getActualNode() instanceof SimpleSchemaNodeImpl) {
093: return ((SimpleSchemaNodeImpl) getActualNode()).getType();
094: }
095:
096: return null;
097: }
098:
099: public String getName() {
100: return getActualNode().getName();
101: }
102:
103: public Class getObjectType() {
104: return getActualNode().getObjectType();
105: }
106:
107: public List getEnumeration() {
108: return getActualNode().getEnumeration();
109: }
110:
111: public boolean isDataNode() {
112: return getActualNode().isDataNode();
113: }
114:
115: }
|