001: /*
002: * Copyright 2001-2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.ws.scout.registry.infomodel;
018:
019: import java.util.ArrayList;
020: import java.util.Collection;
021: import java.util.Iterator;
022:
023: import javax.xml.registry.JAXRException;
024: import javax.xml.registry.LifeCycleManager;
025: import javax.xml.registry.UnsupportedCapabilityException;
026: import javax.xml.registry.infomodel.ClassificationScheme;
027: import javax.xml.registry.infomodel.Concept;
028:
029: /**
030: * Implements JAXR Interface.
031: * For futher details, look into the JAXR API Javadoc.
032: *
033: * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
034: * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
035: */
036: public class ClassificationSchemeImpl extends RegistryEntryImpl
037: implements ClassificationScheme {
038:
039: private Collection<Concept> childConcepts = new ArrayList<Concept>();
040:
041: //private int valueType = 1; KS: not used.
042:
043: private boolean external = false;
044:
045: /**
046: * Creates a new instance of ClassificationSchemeImpl
047: */
048: public ClassificationSchemeImpl(LifeCycleManager lifeCycleManager) {
049: super (lifeCycleManager);
050: }
051:
052: public void addChildConcept(Concept concept) throws JAXRException {
053: childConcepts.add(concept);
054: }
055:
056: public void addChildConcepts(Collection<Concept> collection)
057: throws JAXRException {
058: childConcepts.addAll(collection);
059: }
060:
061: public int getChildConceptCount() throws JAXRException {
062: return childConcepts.size();
063: }
064:
065: public Collection getChildrenConcepts() throws JAXRException {
066: return childConcepts;
067: }
068:
069: public Collection getDescendantConcepts() throws JAXRException {
070: Collection<Concept> coll = new ArrayList<Concept>();
071: Iterator iter = childConcepts.iterator();
072: while (iter != null && iter.hasNext()) {
073: ConceptImpl c = (ConceptImpl) iter.next();
074: coll.add(c);
075: coll.addAll(c.getDescendantConcepts());
076: }
077: return coll;
078: }
079:
080: public int getValueType() throws JAXRException {
081: /*
082: * we are a level 0 provider
083: */
084:
085: throw new UnsupportedCapabilityException();
086: }
087:
088: protected void setExternal(boolean b) {
089: this .external = b;
090: }
091:
092: public boolean isExternal() throws JAXRException {
093: return this .external;
094: }
095:
096: public void removeChildConcept(Concept concept)
097: throws JAXRException {
098: this .childConcepts.remove(concept);
099: }
100:
101: public void removeChildConcepts(Collection collection)
102: throws JAXRException {
103: this .childConcepts.removeAll(collection);
104: }
105:
106: public void setValueType(int param) throws JAXRException {
107: /*
108: * we are a level 0 provider
109: */
110:
111: throw new UnsupportedCapabilityException();
112: }
113:
114: }
|