~ubuntu-branches/ubuntu/saucy/ivy/saucy-proposed

« back to all changes in this revision

Viewing changes to src/java/org/apache/ivy/osgi/core/ManifestHeaderElement.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-15 17:44:57 UTC
  • mfrom: (3.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130515174457-ogntd0vxluwalq11
Tags: 2.3.0-2
* Team upload.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
8
 *
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
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.
 
16
 *
 
17
 */
 
18
package org.apache.ivy.osgi.core;
 
19
 
 
20
import java.util.ArrayList;
 
21
import java.util.HashMap;
 
22
import java.util.Iterator;
 
23
import java.util.List;
 
24
import java.util.Map;
 
25
import java.util.Map.Entry;
 
26
 
 
27
public class ManifestHeaderElement {
 
28
    private List/* <String> */values = new ArrayList/* <String> */();
 
29
 
 
30
    private Map/* <String, String> */attributes = new HashMap/* <String, String> */();
 
31
 
 
32
    private Map/* <String, String> */directives = new HashMap/* <String, String> */();
 
33
 
 
34
    public List/* <String> */getValues() {
 
35
        return values;
 
36
    }
 
37
 
 
38
    public void addValue(String value) {
 
39
        values.add(value);
 
40
    }
 
41
 
 
42
    public Map/* <String, String> */getAttributes() {
 
43
        return attributes;
 
44
    }
 
45
 
 
46
    public void addAttribute(String name, String value) {
 
47
        attributes.put(name, value);
 
48
    }
 
49
 
 
50
    public Map/* <String, String> */getDirectives() {
 
51
        return directives;
 
52
    }
 
53
 
 
54
    public void addDirective(String name, String value) {
 
55
        directives.put(name, value);
 
56
    }
 
57
 
 
58
    public boolean equals(Object obj) {
 
59
        if (!(obj instanceof ManifestHeaderElement)) {
 
60
            return false;
 
61
        }
 
62
        ManifestHeaderElement other = (ManifestHeaderElement) obj;
 
63
        if (other.values.size() != values.size()) {
 
64
            return false;
 
65
        }
 
66
        Iterator itValues = values.iterator();
 
67
        while (itValues.hasNext()) {
 
68
            String value = (String) itValues.next();
 
69
            if (!other.values.contains(value)) {
 
70
                return false;
 
71
            }
 
72
        }
 
73
        if (other.directives.size() != directives.size()) {
 
74
            return false;
 
75
        }
 
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()))) {
 
80
                return false;
 
81
            }
 
82
        }
 
83
        if (other.attributes.size() != attributes.size()) {
 
84
            return false;
 
85
        }
 
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()))) {
 
90
                return false;
 
91
            }
 
92
        }
 
93
        return true;
 
94
    }
 
95
 
 
96
    public String toString() {
 
97
        String string = "";
 
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(";");
 
103
            }
 
104
        }
 
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());
 
112
        }
 
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());
 
120
        }
 
121
        return string;
 
122
    }
 
123
}