KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > console > JavaLikeExtensionsResolver


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.ui.console;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.variables.IDynamicVariable;
15 import org.eclipse.core.variables.IDynamicVariableResolver;
16 import org.eclipse.jdt.core.JavaCore;
17
18 /**
19  * Resolves to Java-like file extensions for hyperlink matching.
20  *
21  * @since 3.2
22  */

23 public class JavaLikeExtensionsResolver implements IDynamicVariableResolver {
24
25     public String JavaDoc resolveValue(IDynamicVariable variable, String JavaDoc argument) throws CoreException {
26         String JavaDoc[] javaLikeExtensions = JavaCore.getJavaLikeExtensions();
27         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
28         if (javaLikeExtensions.length > 1) {
29             buffer.append("("); //$NON-NLS-1$
30
}
31         for (int i = 0; i < javaLikeExtensions.length; i++) {
32             String JavaDoc ext = javaLikeExtensions[i];
33             buffer.append("\\."); //$NON-NLS-1$
34
buffer.append(ext);
35             buffer.append(":"); //$NON-NLS-1$
36
if (i < (javaLikeExtensions.length - 1)) {
37                 buffer.append("|"); //$NON-NLS-1$
38
}
39         }
40         if (javaLikeExtensions.length > 1) {
41             buffer.append(")"); //$NON-NLS-1$
42
}
43         return buffer.toString();
44     }
45
46 }
47
Popular Tags