blob: 4bf0f76cfea3845693cf1a558eee19e98c5fe9e6 [file] [log] [blame]
Stuart McCullochb657c2f2008-01-25 08:10:25 +00001/*
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 */
19package org.apache.felix.obr.plugin;
20
21
22import java.util.ArrayList;
23import java.util.List;
24
25import org.w3c.dom.Document;
26import org.w3c.dom.Element;
27import 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 */
34public 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 McCullochbb9bd382008-01-25 08:14:10 +000067 m_name = name;
Stuart McCullochb657c2f2008-01-25 08:10:25 +000068 }
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 McCullochbb9bd382008-01-25 08:14:10 +000090 m_p = mp;
Stuart McCullochb657c2f2008-01-25 08:10:25 +000091 }
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 McCullochbb9bd382008-01-25 08:14:10 +0000115 capability.setAttribute( "name", getName() );
116 for ( int i = 0; i < getP().size(); i++ )
Stuart McCullochb657c2f2008-01-25 08:10:25 +0000117 {
Stuart McCullochbb9bd382008-01-25 08:14:10 +0000118 capability.appendChild( ( ( PElement ) ( getP().get( i ) ) ).getNode( father ) );
Stuart McCullochb657c2f2008-01-25 08:10:25 +0000119 }
120 return capability;
121 }
122
123}