| /******************************************************************************* |
| * Copyright (c) 2000, 2003 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Common Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/cpl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.jdt.internal.core.search.matching; |
| |
| import java.io.IOException; |
| |
| import org.eclipse.core.runtime.IProgressMonitor; |
| import org.eclipse.jdt.core.search.IJavaSearchScope; |
| import org.eclipse.jdt.internal.compiler.ast.AstNode; |
| import org.eclipse.jdt.internal.core.index.IEntryResult; |
| import org.eclipse.jdt.internal.core.index.impl.IndexInput; |
| import org.eclipse.jdt.internal.core.search.IIndexSearchRequestor; |
| |
| public class PackageDeclarationPattern extends SearchPattern { |
| char[] pkgName; |
| public PackageDeclarationPattern(char[] pkgName, int matchMode, boolean isCaseSensitive) { |
| super(matchMode, isCaseSensitive); |
| this.pkgName = pkgName; |
| } |
| /** |
| * @see SearchPattern#decodeIndexEntry |
| */ |
| protected void decodeIndexEntry(IEntryResult entryResult) { |
| // not used |
| } |
| /** |
| * @see SearchPattern#feedIndexRequestor |
| */ |
| public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, IJavaSearchScope scope) throws java.io.IOException { |
| // not used |
| } |
| /** |
| * see SearchPattern#findMatches |
| */ |
| public void findIndexMatches(IndexInput input, IIndexSearchRequestor requestor, int detailLevel, IProgressMonitor progressMonitor, IJavaSearchScope scope) throws IOException { |
| // package declarations are not indexed |
| } |
| /** |
| * @see SearchPattern#indexEntryPrefix |
| */ |
| public char[] indexEntryPrefix() { |
| // not used |
| return null; |
| } |
| /** |
| * @see SearchPattern#matchContainer |
| */ |
| protected int matchContainer() { |
| // used only in the case of a OrPattern |
| return 0; |
| } |
| /** |
| * @see SearchPattern#matchIndexEntry |
| */ |
| protected boolean matchIndexEntry() { |
| // used only in the case of a OrPattern |
| return true; |
| } |
| public String toString(){ |
| StringBuffer buffer = new StringBuffer(20); |
| buffer.append("PackageDeclarationPattern: <"); //$NON-NLS-1$ |
| if (this.pkgName != null) buffer.append(this.pkgName); |
| buffer.append(">, "); //$NON-NLS-1$ |
| switch(matchMode){ |
| case EXACT_MATCH : |
| buffer.append("exact match, "); //$NON-NLS-1$ |
| break; |
| case PREFIX_MATCH : |
| buffer.append("prefix match, "); //$NON-NLS-1$ |
| break; |
| case PATTERN_MATCH : |
| buffer.append("pattern match, "); //$NON-NLS-1$ |
| break; |
| } |
| if (isCaseSensitive) |
| buffer.append("case sensitive"); //$NON-NLS-1$ |
| else |
| buffer.append("case insensitive"); //$NON-NLS-1$ |
| return buffer.toString(); |
| } |
| |
| /** |
| * @see SearchPattern#matchLevel(AstNode, boolean) |
| */ |
| public int matchLevel(AstNode node, boolean resolve) { |
| // used only in the case of a OrPattern |
| return ACCURATE_MATCH; |
| } |
| } |