Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
package org.eclipse.jdt.internal.core.search;
import  org.eclipse.core.resources.IFile;
import  org.eclipse.core.resources.ResourcesPlugin;
import  org.eclipse.core.runtime.CoreException;
import  org.eclipse.core.runtime.IPath;
import  org.eclipse.core.runtime.Path;
public class JavaSearchDocument extends SearchDocument {
	private IFile file;
	protected byte[] byteContents;
	protected char[] charContents;
	public JavaSearchDocument(String documentPathSearchParticipant participant) {
		super(documentPathparticipant);
	}
	public JavaSearchDocument(java.util.zip.ZipEntry zipEntry, IPath zipFilePathbyte[] contentsSearchParticipant participant) {
		super(zipFilePath + . + zipEntry.getName(), participant);
		this. = contents;
	}
	public byte[] getByteContents() {
		if (this. != nullreturn this.;
		try {
catch (JavaModelException e) {
			if (. || .) { // used during search and during indexing
			}
			return null;
		}
	}
	public char[] getCharContents() {
		if (this. != nullreturn this.;
		try {
catch (JavaModelException e) {
			if (. || .) { // used during search and during indexing
			}
			return null;
		}
	}
	public String getEncoding() {
		// Return the encoding of the associated file
		IFile resource = getFile();
		if (resource != null) {
			try {
				return resource.getCharset();
			}
			catch(CoreException ce) {
				try {
					return ResourcesPlugin.getWorkspace().getRoot().getDefaultCharset();
catch (CoreException e) {
					// use no encoding
				}
			}
		}
		return null;
	}
	private IFile getFile() {
		if (this. == null)
			this. = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(getPath()));
		return this.;
	}
	public String toString() {
		return "SearchDocument for " + getPath(); //$NON-NLS-1$
	}
New to GrepCode? Check out our FAQ X