Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9f1d79c69d5b443f73b71e9b130bd506176245bd (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
148
149
150
151
/*****************************************************************************
 * Copyright (c) 2013 CEA LIST 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:
 *   CEA LIST - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.uml.search.ui.query;

import java.util.Collection;
import java.util.Collections;

import org.eclipse.emf.common.util.URI;
import org.eclipse.papyrus.uml.search.ui.providers.ParticipantTypeElement;
import org.eclipse.uml2.uml.NamedElement;

/**
 * A <em>Parameter Object</em> for creation of {@link AbstractPapyrusQuery} instances via an {@link IPapyrusQueryProvider}.
 */
public class QueryInfo {

	private String queryText;

	private boolean caseSensitive;

	private boolean regularExpression;

	private boolean searchAllStringAttributes;

	private Collection<? extends ParticipantTypeElement> participantTypes;
	
	private boolean searchForAllSter;

	private Collection<URI> scope;

	/**
	 * Creates a query info for simple query.
	 * 
	 * @param queryText
	 *        the user-supplied search query text
	 * @param caseSensitive
	 *        whether the {@code queryText} is to be applied in case-sensitive fashion
	 * @param regularExpression
	 *        whether the {@code queryText} is to be taken as a regular expression
	 * @param searchAllStringAttributes
	 *        whether to search all string attributes of UML metaclasses ({@code true}), or just named element {@linkplain NamedElement#getName()
	 *        names} ({@code false})
	 * @param scope
	 *        the domain-specific search scope
	 */
	public QueryInfo(String queryText, boolean caseSensitive, boolean regularExpression, boolean searchAllStringAttributes, Collection<URI> scope) {
		super();

		
		this.queryText = queryText;
		this.caseSensitive = caseSensitive;
		this.regularExpression = regularExpression;
		this.searchAllStringAttributes = searchAllStringAttributes;
		this.participantTypes = Collections.emptyList();
		this.scope = scope;
	}

	/**
	 * Creates a query info for advanced query.
	 * 
	 * @param queryText
	 *        the user-supplied search query text
	 * @param caseSensitive
	 *        whether the {@code queryText} is to be applied in case-sensitive fashion
	 * @param regularExpression
	 *        whether the {@code queryText} is to be taken as a regular expression
	 * @param participantTypes
	 *        the participant types (identifying specific metaclasses and/or attributes) to include in the search
	 * @param searchForAllSter
	 *        stereotype application must all applied or not
	 * @param scope
	 *        the domain-specific search scope
	 */
	public QueryInfo(String queryText, boolean caseSensitive, boolean regularExpression, Collection<? extends ParticipantTypeElement> participantTypes, Collection<URI> scope,boolean searchForAllSter) {
		super();

		this.queryText = queryText;
		this.caseSensitive = caseSensitive;
		this.regularExpression = regularExpression;
		this.searchAllStringAttributes = false;
		this.participantTypes = participantTypes;
		this.scope = scope;
		this.searchForAllSter = searchForAllSter;
	}
	
	/**
	 * Partition copy constructor.
	 */
	private QueryInfo(QueryInfo original, Collection<URI> scope) {
		super();

		this.queryText = original.queryText;
		this.caseSensitive = original.caseSensitive;
		this.regularExpression = original.regularExpression;
		this.searchAllStringAttributes = original.searchAllStringAttributes;
		this.participantTypes = original.participantTypes;
		this.searchForAllSter = original.searchForAllSter;
		this.scope = scope;
	}

	public String getQueryText() {
		return queryText;
	}

	public boolean isCaseSensitive() {
		return caseSensitive;
	}

	public boolean isRegularExpression() {
		return regularExpression;
	}

	public boolean isSearchAllStringAttributes() {
		return searchAllStringAttributes;
	}

	public Collection<? extends ParticipantTypeElement> getParticipantTypes() {
		return participantTypes;
	}

	public Collection<URI> getScope() {
		return scope;
	}
	
	public boolean isSearchForAllSter() {
		return searchForAllSter;
	}


	/**
	 * Creates a new instance encapsulating query parameters for the specified partition (strict subset) of my {@linkplain #getScope() scope}.
	 * 
	 * @param scopePartition a partition of my scope
	 * 
	 * @return the partition query info
	 * 
	 * @see #getScope()
	 */
	public QueryInfo partition(Collection<URI> scopePartition) {
		return new QueryInfo(this, scopePartition);
	}
}

Back to the top