Skip to main content
summaryrefslogtreecommitdiffstats
blob: 301cc26c8ac124b43500b244c75091c789c60fa8 (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
/*******************************************************************************
 * Copyright (c) 2010, 2017 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.internal.p2.updatesite;

import java.util.ArrayList;
import java.util.List;

public class SiteIU {

	public static final String QUERY_TYPE_CONTEXT = "context"; //$NON-NLS-1$
	public static final String QUERY_TYPE_MATCH = "match"; //$NON-NLS-1$

	private String id = null;
	private String range = null;
	private String queryExpression = null;
	private String queryType = null;
	private List<String> queryParams = null;
	private List<String> categoryNames = null;

	/**
	 * Returns the id of the IU
	 * @return the id of the IU
	 */
	public String getID() {
		return id;
	}

	/**
	 * Returns the range of the IU
	 * @return the range of the IU
	 */
	public String getRange() {
		return range;
	}

	/**
	 * Returns the query expression for the IU.
	 * 
	 * @return query expression
	 */
	public String getQueryExpression() {
		return queryExpression;
	}

	/**
	 * Returns the query type for the IU.
	 * 
	 * @return the query type
	 */
	public String getQueryType() {
		return queryType;
	}

	/**
	 * Returns the params for the query expression for the IU
	 * 
	 * @return an array of query params.
	 */
	public String[] getQueryParams() {
		if (queryParams == null)
			return new String[0];

		return queryParams.toArray(new String[0]);
	}

	/**
	 * Returns the names of categories the referenced IU belongs to.
	 * 
	 * @return an array of names, or an empty array.
	 */
	public String[] getCategoryNames() {
		if (categoryNames == null)
			return new String[0];

		return categoryNames.toArray(new String[0]);
	}

	/**
	 * Sets the id for the IU.
	 * @param id the id
	 */
	public void setID(String id) {
		this.id = id;
	}

	/**
	 * Sets the range for the IU.
	 * @param range the range
	 */
	public void setRange(String range) {
		this.range = range;
	}

	/**
	 * Sets the query expression for the IU.
	 * 
	 * @param queryExpression query expression
	 */
	public void setQueryExpression(String queryExpression) {
		this.queryExpression = queryExpression;
	}

	/**
	 * Sets the query type for the IU.
	 * 
	 * @param queryType the query type
	 */
	public void setQueryType(String queryType) {
		this.queryType = queryType;
	}

	/**
	 * Adds the name of a category this IU belongs to.
	 * 
	 * @param categoryName category name
	 */
	public void addCategoryName(String categoryName) {
		if (this.categoryNames == null)
			this.categoryNames = new ArrayList<>();
		if (!this.categoryNames.contains(categoryName))
			this.categoryNames.add(categoryName);
	}

	/**
	 * Adds a param for the query expression for this IU.
	 * 
	 * @param queryParam a query param.
	 */
	public void addQueryParams(String queryParam) {
		if (this.queryParams == null)
			this.queryParams = new ArrayList<>();
		// don't do contains check, order matters and there may be duplicates
		this.queryParams.add(queryParam);
	}
}

Back to the top