Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4fdc8ae6473469eb7fe9078284efcb25d0b63179 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.compare.examples.xml;

import java.util.ArrayList;
import java.util.Vector;

/** This class is used to represent a id mapping scheme in the XML Compare preference page
 */
public class IdMap {

	private String fName;
	private boolean fInternal;
	private Vector fMappings;
	private String fExtension;
	private ArrayList fOrdered;//contains Mapping elements for list of ordered entries (the children of these elements will be compared in ordered fashion)

	/**
	 * Creates an IdMap which represents an Id Mapping Scheme
	 * @param internal true if the IdMap is internal
	 */
	public IdMap(boolean internal) {
		this("", internal); //$NON-NLS-1$
	}

	/**
	 * Creates an IdMap which represents an Id Mapping Scheme
	 * @param name The name of the mapping, as in fIdMaps/fIdMapsInternal HashMaps and fOrderedElements/fOrderedElementsInternal HashMaps
	 * @param internal true if the IdMap is internal
	 */
	public IdMap(String name, boolean internal) {
		this(name, internal, new Vector());
	}

	/**
	 * Creates an IdMap which represents an Id Mapping Scheme
	 * @param name The name of the mapping, as in fIdMaps/fIdMapsInternal HashMaps and fOrderedElements/fOrderedElementsInternal HashMaps
	 * @param internal true if the IdMap is internal
	 * @param mappings Vector of Mapping elements which represent the id mappings of this id mapping scheme
	 */
	public IdMap(String name, boolean internal, Vector mappings) {
		this(name, internal, mappings, ""); //$NON-NLS-1$
	}

	/**
	 * Creates an IdMap which represents an Id Mapping Scheme.
	 * @param name The name of the mapping, as in fIdMaps/fIdMapsInternal HashMaps and fOrderedElements/fOrderedElementsInternal HashMaps.
	 * @param internal true if the IdMap is internal.
	 * @param mappings Vector of Mapping elements which represent the id mappings of this id mapping scheme.
	 * @param extension Optional extension to be associated with this id mapping scheme.
	 */
	public IdMap(String name, boolean internal, Vector mappings, String extension) {
		this(name, internal, mappings, extension, null);
	}

	/**
	 * Creates an IdMap which represents an Id Mapping Scheme.
	 * @param name The name of the mapping, as in fIdMaps/fIdMapsInternal HashMaps and fOrderedElements/fOrderedElementsInternal HashMaps.
	 * @param internal true if the IdMap is internal.
	 * @param mappings Vector of Mapping elements which represent the id mappings of this id mapping scheme.
	 * @param extension Optional extension to be associated with this id mapping scheme.
	 * @param ordered Optional ArrayList of Mapping elements representing ordered entries.
	 */
	public IdMap(String name, boolean internal, Vector mappings, String extension, ArrayList ordered) {
		fName = name;
		fInternal = internal;
		fMappings = mappings;
		fExtension= extension.toLowerCase();
		fOrdered= ordered;
	}
	
	/*
	 * @see Object#equals(Object)
	 */
	@Override
	public boolean equals(Object object) {
		if (!(object instanceof IdMap))
			return false;
			
		IdMap idmap= (IdMap) object;

		if (idmap == this)
			return true;		

		return
			idmap.getName().equals(fName) &&
			idmap.getMappings().equals(fMappings);
	}
	
	/*
	 * @see Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return fName.hashCode() ^ fMappings.hashCode();
	}

	public void setName(String name) {
		fName = name;
	}
	
	public String getName() {
		return fName;
	}

	public void setMappings(Vector mappings) {
		fMappings = mappings;
	}
	
	public Vector getMappings() {
		return fMappings;
	}

	public void setInternal(boolean bool) {
		fInternal = bool;
	}
	
	public boolean isInternal() {
		return fInternal;
	}
	
	public void setExtension(String extension) {
		fExtension= extension;
	}
	
	public String getExtension() {
		return fExtension;
	}
	public void setOrdered(ArrayList ordered) {
		fOrdered= ordered;
	}
	public ArrayList getOrdered() {
		return fOrdered;
	}

}

Back to the top