Stuart McCulloch | b657c2f | 2008-01-25 08:10:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.apache.felix.obr.plugin; |
| 20 | |
| 21 | |
| 22 | import java.util.ArrayList; |
| 23 | import java.util.List; |
| 24 | |
| 25 | import org.w3c.dom.Document; |
| 26 | import org.w3c.dom.Element; |
| 27 | import org.w3c.dom.Node; |
| 28 | |
| 29 | |
| 30 | /** |
| 31 | * This class describe and store capability node. |
| 32 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 33 | */ |
| 34 | public class Capability |
| 35 | { |
| 36 | |
| 37 | /** |
| 38 | * m_name: name of the capability. |
| 39 | */ |
| 40 | private String m_name; |
| 41 | |
| 42 | /** |
| 43 | * m_p: List of PElement. |
| 44 | */ |
| 45 | private List m_p = new ArrayList(); |
| 46 | |
| 47 | |
| 48 | /** |
| 49 | * get the name attribute. |
| 50 | * |
| 51 | * @return name attribute |
| 52 | */ |
| 53 | public String getName() |
| 54 | { |
| 55 | return m_name; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | /** |
| 60 | * set the name attribute. |
| 61 | * |
| 62 | * @param name new name value |
| 63 | * |
| 64 | */ |
| 65 | public void setName( String name ) |
| 66 | { |
Stuart McCulloch | bb9bd38 | 2008-01-25 08:14:10 +0000 | [diff] [blame] | 67 | m_name = name; |
Stuart McCulloch | b657c2f | 2008-01-25 08:10:25 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | |
| 71 | /** |
| 72 | * return the capabilities. |
| 73 | * |
| 74 | * @return List of PElement |
| 75 | */ |
| 76 | public List getP() |
| 77 | { |
| 78 | return m_p; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | /** |
| 83 | * set the capabilities. |
| 84 | * |
| 85 | * @param mp List of PElement |
| 86 | * |
| 87 | */ |
| 88 | public void setP( List mp ) |
| 89 | { |
Stuart McCulloch | bb9bd38 | 2008-01-25 08:14:10 +0000 | [diff] [blame] | 90 | m_p = mp; |
Stuart McCulloch | b657c2f | 2008-01-25 08:10:25 +0000 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | |
| 94 | /** |
| 95 | * add one element in List. |
| 96 | * |
| 97 | * @param pelement PElement |
| 98 | * |
| 99 | */ |
| 100 | public void addP( PElement pelement ) |
| 101 | { |
| 102 | m_p.add( pelement ); |
| 103 | } |
| 104 | |
| 105 | |
| 106 | /** |
| 107 | * transform this object to Node. |
| 108 | * |
| 109 | * @param father father document for create Node |
| 110 | * @return node |
| 111 | */ |
| 112 | public Node getNode( Document father ) |
| 113 | { |
| 114 | Element capability = father.createElement( "capability" ); |
Stuart McCulloch | bb9bd38 | 2008-01-25 08:14:10 +0000 | [diff] [blame] | 115 | capability.setAttribute( "name", getName() ); |
| 116 | for ( int i = 0; i < getP().size(); i++ ) |
Stuart McCulloch | b657c2f | 2008-01-25 08:10:25 +0000 | [diff] [blame] | 117 | { |
Stuart McCulloch | bb9bd38 | 2008-01-25 08:14:10 +0000 | [diff] [blame] | 118 | capability.appendChild( ( ( PElement ) ( getP().get( i ) ) ).getNode( father ) ); |
Stuart McCulloch | b657c2f | 2008-01-25 08:10:25 +0000 | [diff] [blame] | 119 | } |
| 120 | return capability; |
| 121 | } |
| 122 | |
| 123 | } |