001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 2004-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.openidex.search;
043:
044: import java.util.Iterator;
045: import org.openide.loaders.DataObject;
046:
047: /**
048: * Defines which <code>DataObject</code>s should be searched.
049: * Iterator returned by this interface's method enumerates
050: * <code>DataObject</code>s that should be searched.
051: * <p>
052: * <code>SearchInfo</code> objects are used by module User Utilities
053: * – in actions <em>Find</em> (since User Utilities 1.16)
054: * and <em>Find in Projects</em> (since User Utilities 1.23).
055: * Action <em>Find</em> obtains <code>SearchInfo</code> from
056: * <a href="@org-openide-nodes@/org/openide/nodes/Node.html#getLookup()"><code>Lookup</code> of nodes</a>
057: * the action was invoked on. Action <em>Find in Projects</em> obtains
058: * <code>SearchInfo</code> from
059: * <a href="@org-netbeans-modules-projectapi@/org/netbeans/api/project/Project.html#getLookup()"><code>Lookup</code>
060: * of the projects</a>.
061: * </p>
062: *
063: * @see SearchInfoFactory
064: * @see <a href="@org-openide-loaders@/org/openide/loaders/DataObject.html"><code>DataObject</code></a>
065: * @see <a href="@org-openide-nodes@/org/openide/nodes/Node.html#getLookup()"><code>Node.getLookup()</code></a>
066: * @see <a href="@org-netbeans-modules-projectapi@/org/netbeans/api/project/Project.html#getLookup()"><code>Project.getLookup()</code></a>
067: * @since org.openidex.util/3 3.2
068: * @author Marian Petras
069: */
070: public interface SearchInfo {
071:
072: /**
073: * Determines whether the object which provided this <code>SearchInfo</code>
074: * can be searched.
075: * This method determines whether the <em>Find</em> action should be enabled
076: * for the object or not.
077: * <p>
078: * This method must be very quick as it may be called frequently and its
079: * speed may influence responsiveness of the whole application. If the exact
080: * algorithm for determination of the result value should be slow, it is
081: * better to return <code>true</code> than make the method slow.
082: *
083: * @return <code>false</code> if the object is known that it cannot be
084: * searched; <code>true</code> otherwise
085: * @since org.openidex.util/3 3.3
086: */
087: public boolean canSearch();
088:
089: /**
090: * Specifies which <code>DataObject</code>s should be searched.
091: * The returned <code>Iterator</code> needn't implement method
092: * {@link java.util.Iterator#remove remove()} (i.e. it may throw
093: * <code>UnsupportedOperationException</code> instead of actual
094: * implementation).
095: *
096: * @return iterator which iterates over <code>DataObject</code>s
097: * to be searched
098: */
099: public Iterator<DataObject> objectsToSearch();
100:
101: }
|