KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xam > ui > search > Query


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.xam.ui.search;
21
22 /**
23  * Encapsulates the search query and its parameters.
24  *
25  * @author Nathan Fiedler
26  */

27 public class Query {
28     /** The query string, possibly a regular expression. */
29     private String JavaDoc query;
30     /** Indicates if search is rooted at selected component, or the
31      * XAM model root component. */

32     private boolean selected;
33     /** Indicates if the query is a regular expression or a plain string. */
34     private boolean regex;
35
36     /**
37      * Creates a new instance of Query.
38      *
39      * @param query phrase to search for.
40      * @param selected if true, limit search to selected subtree.
41      * @param regex if true, query is a regular expression.
42      */

43     public Query(String JavaDoc query, boolean selected, boolean regex) {
44         this.query = query;
45         this.selected = selected;
46         this.regex = regex;
47     }
48
49     /**
50      * Returns the query string entered by the user.
51      *
52      * @return search phrase.
53      */

54     public String JavaDoc getQuery() {
55         return query;
56     }
57
58     /**
59      * Returns true if the query string is a Perl-like regular expression,
60      * false if it is a plain string.
61      *
62      * @return true if regex, false otherwise.
63      */

64     public boolean isRegularExpression() {
65         return regex;
66     }
67
68     /**
69      * Returns true if this query should be rooted at the selected component,
70      * or if the search should begin at the root component.
71      *
72      * @return true if searching from selected component, false if root.
73      * @see #getSelectedComponent
74      */

75     public boolean useSelected() {
76         return selected;
77     }
78 }
79
Popular Tags