File: FieldXml.java

package info (click to toggle)
gpsprune 26.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,824 kB
  • sloc: java: 52,154; sh: 25; makefile: 21; python: 15
file content (65 lines) | stat: -rw-r--r-- 1,575 bytes parent folder | download | duplicates (4)
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
package tim.prune.data;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

/**
 * Class to represent a field from an xml extension
 */
public class FieldXml extends Field
{
	private final String _label;
	private final String _tagName;
	private final String[] _categories;


	public FieldXml(FileType inFileType, String inTagName, Collection<String> inCategories)
	{
		super(inFileType);
		_tagName = inTagName;
		_label = FieldRecogniser.getLabel(inTagName);
		_categories = inCategories == null ? new String[0] : inCategories.toArray(new String[0]);
	}

	public FieldXml(FileType inFileType, String inTagName, String inCategory) {
		this(inFileType, inTagName, List.of(inCategory));
	}

	/**
	 * @return the name of the field for display
	 */
	public String getName() {
		return _label;
	}

	/**
	 * @return the categories of the field for export
	 */
	public String[] getCategories() {
		return _categories;
	}

	/**
	 * @return the xml tag holding the given value (assuming categories are already present)
	 */
	public String getTag(String inValue) {
		return "<" + _tagName + ">" + inValue + "</" + _tagName + ">";
	}

	/**
	 * Checks if the two fields are equal
	 * @param inOther other Field object
	 * @return true if Fields are identical
	 */
	public boolean equals(Object inOther)
	{
		if (inOther == null || !(inOther instanceof FieldXml)) {
			return false;
		}
		FieldXml other = (FieldXml) inOther;
		return Objects.equals(_tagName, other._tagName)
				&& Arrays.equals(_categories, other._categories);
	}
}