01: /*******************************************************************************
02: * Copyright (c) 2003 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jsp;
11:
12: import java.io.IOException;
13: import java.io.InputStreamReader;
14: import java.io.Reader;
15:
16: import org.eclipse.core.resources.IFile;
17: import org.eclipse.core.runtime.CoreException;
18: import org.eclipse.core.indexsearch.*;
19:
20: public class JspMatchLocatorParser extends AbstractJspParser {
21:
22: IFile fResource;
23: String fMatchString;
24: ISearchResultCollector fCollector;
25:
26: boolean fInUseBean;
27: String fId;
28: String fClass;
29:
30: public JspMatchLocatorParser() {
31: super ();
32: }
33:
34: protected void startTag(boolean endTag, String name, int startName) {
35: fInUseBean = "jsp:useBean".equals(name); //$NON-NLS-1$
36: }
37:
38: protected void tagAttribute(String attrName, String value,
39: int startName, int startValue) {
40: if (fInUseBean
41: && "class".equals(attrName) && fMatchString.equals(value)) { //$NON-NLS-1$
42: try {
43: fCollector
44: .accept(fResource, startValue, value.length());
45: } catch (CoreException e) {
46: e.printStackTrace();
47: }
48: }
49: }
50:
51: public void match(IFile resource, String matchString,
52: ISearchResultCollector collector) {
53:
54: fResource = resource;
55: fMatchString = matchString;
56: fCollector = collector;
57: Reader reader = null;
58:
59: try {
60: reader = new InputStreamReader(fResource.getContents());
61: } catch (CoreException e1) {
62: e1.printStackTrace();
63: }
64:
65: try {
66: parse(reader);
67: } catch (IOException e2) {
68: e2.printStackTrace();
69: }
70: }
71: }
|