Coverage Report - org.apache.ws.scout.registry.infomodel.ConceptImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ConceptImpl
0%
0/59
0%
0/10
0
 
 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.infomodel.ClassificationScheme;
 26  
 import javax.xml.registry.infomodel.Concept;
 27  
 import javax.xml.registry.infomodel.RegistryObject;
 28  
 
 29  
 /**
 30  
  * Implements JAXR Interface.
 31  
  * For futher details, look into the JAXR API Javadoc.
 32  
  *
 33  
  * @author Anil Saldhana  <anil@apache.org>
 34  
  */
 35  
 public class ConceptImpl extends RegistryObjectImpl implements Concept
 36  
 {
 37  0
     private String value = new String();
 38  
 
 39  0
     private RegistryObject parent = null;
 40  0
     private Concept parentconcept = null;
 41  
 
 42  0
     private ClassificationScheme scheme = null;
 43  0
     private Collection<Concept> childconcepts = new ArrayList<Concept>();
 44  
 
 45  
     /**
 46  
      * Creates a new instance of ConceptImpl
 47  
      */
 48  
     public ConceptImpl(LifeCycleManager lifeCycleManager)
 49  
     {
 50  0
         super(lifeCycleManager);
 51  0
     }
 52  
 
 53  
     public void addChildConcept(Concept concept)
 54  
     {
 55  0
         this.childconcepts.add(concept);
 56  0
         ((ConceptImpl)concept).setParentconcept(this);
 57  0
     }
 58  
 
 59  
     public void addChildConcepts(Collection collection)
 60  
     {
 61  0
         for (Object c : collection) {
 62  0
             ((ConceptImpl) c).setParentconcept(this);
 63  0
             childconcepts.add((Concept) c);
 64  
         }
 65  
 
 66  0
     }
 67  
 
 68  
     public int getChildConceptCount()
 69  
     {
 70  0
         return this.childconcepts.size();                                                                                                           
 71  
     }
 72  
 
 73  
     public Collection<Concept> getChildrenConcepts()
 74  
     {
 75  0
         return this.childconcepts;
 76  
     }
 77  
 
 78  
     public ClassificationScheme getClassificationScheme()
 79  
     {
 80  0
         return scheme;
 81  
     }
 82  
 
 83  
     public Collection<Concept> getDescendantConcepts()
 84  
     {
 85  0
         Collection<Concept> coll = new ArrayList<Concept>();
 86  0
         Iterator iter = childconcepts.iterator();
 87  0
         while(iter != null && iter.hasNext())
 88  
         {
 89  0
             ConceptImpl c = (ConceptImpl)iter.next();
 90  0
             coll.add(c);
 91  0
             coll.addAll(c.getDescendantConcepts());
 92  0
         }
 93  0
         return coll;
 94  
     }
 95  
 
 96  
     public RegistryObject getParent()
 97  
     {
 98  0
         return parent;
 99  
     }
 100  
 
 101  
     public Concept getParentConcept()
 102  
     {
 103  0
         return parentconcept;
 104  
     }
 105  
 
 106  
     public String getPath()
 107  
     {
 108  0
         return null;
 109  
     }
 110  
 
 111  
     public String getValue() throws JAXRException
 112  
     {
 113  0
         return value;
 114  
     }
 115  
 
 116  
     public void removeChildConcept(Concept c)
 117  
     {
 118  0
         ((ConceptImpl)c).setParentconcept(null);
 119  0
         childconcepts.remove(c);
 120  0
     }
 121  
 
 122  
     public void removeChildConcepts(Collection collection)
 123  
     {
 124  0
         Iterator iter = collection.iterator();
 125  0
         while(iter.hasNext())
 126  
         {
 127  0
             Concept c = (Concept)iter.next();
 128  0
             ((ConceptImpl)c).setParentconcept(null);
 129  0
             childconcepts.add(c);
 130  0
         }
 131  0
     }
 132  
 
 133  
     public void setValue(String str)
 134  
     {
 135  0
         value = str;
 136  0
     }
 137  
 
 138  
     public void setParent(RegistryObject parent)
 139  
     {
 140  0
         this.parent = parent;
 141  0
     }
 142  
 
 143  
     public void setParentconcept(Concept parentconcept)
 144  
     {
 145  0
         this.parentconcept = parentconcept;
 146  0
         parent = null; //We deal with concept as parent
 147  0
     }
 148  
 
 149  
     public void setScheme(ClassificationSchemeImpl scheme)
 150  
     {
 151  0
         this.scheme = scheme;
 152  0
     }
 153  
 
 154  
     public void setChildconcepts(Collection<Concept> childconcepts)
 155  
     {
 156  0
         this.childconcepts.clear();
 157  0
         Iterator iter = childconcepts.iterator();
 158  0
         while(iter.hasNext())
 159  
         {
 160  0
             Concept c = (Concept)iter.next();
 161  0
             ((ConceptImpl)c).setParentconcept(this);
 162  0
             childconcepts.add(c);
 163  0
         }
 164  0
     }
 165  
 
 166  
     //Specific API
 167  
     public void setClassificationScheme(ClassificationScheme sc)
 168  
     {
 169  0
         scheme = sc;
 170  0
         parent = sc;
 171  0
     }
 172  
 }