This project has retired. For details please refer to its Attic page.
ClassificationSchemeImpl xref
View Javadoc
1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.ws.scout.registry.infomodel;
18  
19  import java.util.ArrayList;
20  import java.util.Collection;
21  import java.util.Iterator;
22  
23  import javax.xml.registry.JAXRException;
24  import javax.xml.registry.LifeCycleManager;
25  import javax.xml.registry.UnsupportedCapabilityException;
26  import javax.xml.registry.infomodel.ClassificationScheme;
27  import javax.xml.registry.infomodel.Concept;
28  
29  /**
30   * Implements JAXR Interface.
31   * For futher details, look into the JAXR API Javadoc.
32   *
33   * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
34   * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
35   */
36  public class ClassificationSchemeImpl
37          extends RegistryEntryImpl
38          implements ClassificationScheme
39  {
40  
41      private Collection<Concept> childConcepts = new ArrayList<Concept>();
42  
43      //private int valueType = 1; KS: not used.
44  
45      private boolean external = false;
46      
47      /**
48       * Creates a new instance of ClassificationSchemeImpl
49       */
50      public ClassificationSchemeImpl(LifeCycleManager lifeCycleManager)
51      {
52          super(lifeCycleManager);
53      }
54  
55      public void addChildConcept(Concept concept)
56              throws JAXRException
57      {
58          childConcepts.add(concept);
59      }
60  
61      public void addChildConcepts(Collection collection)
62              throws JAXRException
63      {
64          childConcepts.addAll(collection);
65      }
66  
67      public int getChildConceptCount()
68              throws JAXRException
69      {
70          return childConcepts.size();
71      }
72  
73      public Collection getChildrenConcepts() throws JAXRException
74      {
75          return childConcepts;
76      }
77  
78      public Collection getDescendantConcepts() throws JAXRException
79      {
80          Collection<Concept> coll = new ArrayList<Concept>();
81          Iterator iter = childConcepts.iterator();
82          while(iter != null && iter.hasNext())
83          {
84              ConceptImpl../../../../../../org/apache/ws/scout/registry/infomodel/ConceptImpl.html#ConceptImpl">ConceptImpl c = (ConceptImpl)iter.next();
85              coll.add(c);
86              coll.addAll(c.getDescendantConcepts());
87          }
88          return coll;
89      }
90  
91      public int getValueType()
92          throws JAXRException
93      {
94          /*
95           * we are a level 0 provider
96           */
97  
98          throw new UnsupportedCapabilityException();
99      }
100 
101     protected void setExternal(boolean b) {
102         this.external = b;
103     }
104 
105     public boolean isExternal() throws JAXRException
106     {
107         return this.external;
108     }
109 
110     public void removeChildConcept(Concept concept)
111             throws JAXRException
112     {
113         this.childConcepts.remove(concept);
114     }
115 
116     public void removeChildConcepts(Collection collection)
117             throws JAXRException
118     {
119         this.childConcepts.removeAll(collection);
120     }
121 
122     public void setValueType(int param)
123         throws JAXRException
124     {
125         /*
126          * we are a level 0 provider
127          */
128 
129         throw new UnsupportedCapabilityException();
130     }
131 
132 }