2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.ivy.osgi.core;
20
import java.util.ArrayList;
21
import java.util.HashMap;
22
import java.util.Iterator;
23
import java.util.List;
25
import java.util.Map.Entry;
27
public class ManifestHeaderElement {
28
private List/* <String> */values = new ArrayList/* <String> */();
30
private Map/* <String, String> */attributes = new HashMap/* <String, String> */();
32
private Map/* <String, String> */directives = new HashMap/* <String, String> */();
34
public List/* <String> */getValues() {
38
public void addValue(String value) {
42
public Map/* <String, String> */getAttributes() {
46
public void addAttribute(String name, String value) {
47
attributes.put(name, value);
50
public Map/* <String, String> */getDirectives() {
54
public void addDirective(String name, String value) {
55
directives.put(name, value);
58
public boolean equals(Object obj) {
59
if (!(obj instanceof ManifestHeaderElement)) {
62
ManifestHeaderElement other = (ManifestHeaderElement) obj;
63
if (other.values.size() != values.size()) {
66
Iterator itValues = values.iterator();
67
while (itValues.hasNext()) {
68
String value = (String) itValues.next();
69
if (!other.values.contains(value)) {
73
if (other.directives.size() != directives.size()) {
76
Iterator itDirectives = directives.entrySet().iterator();
77
while (itDirectives.hasNext()) {
78
Entry/* <String, String> */directive = (Entry) itDirectives.next();
79
if (!directive.getValue().equals(other.directives.get(directive.getKey()))) {
83
if (other.attributes.size() != attributes.size()) {
86
Iterator itAttributes = attributes.entrySet().iterator();
87
while (itAttributes.hasNext()) {
88
Entry/* <String, String> */attribute = (Entry) itAttributes.next();
89
if (!attribute.getValue().equals(other.attributes.get(attribute.getKey()))) {
96
public String toString() {
98
Iterator/* <String> */itValues = values.iterator();
99
while (itValues.hasNext()) {
100
string = string.concat((String) itValues.next());
101
if (itValues.hasNext()) {
102
string = string.concat(";");
105
Iterator itDirectives = directives.entrySet().iterator();
106
while (itDirectives.hasNext()) {
107
Entry/* <String, String> */directive = (Entry) itDirectives.next();
108
string = string.concat(";");
109
string = string.concat((String) directive.getKey());
110
string = string.concat(":=");
111
string = string.concat((String) directive.getValue());
113
Iterator itAttributes = attributes.entrySet().iterator();
114
while (itAttributes.hasNext()) {
115
Entry/* <String, String> */attribute = (Entry) itAttributes.next();
116
string = string.concat(";");
117
string = string.concat((String) attribute.getKey());
118
string = string.concat("=");
119
string = string.concat((String) attribute.getValue());