Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2012 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.builder;
 
 import  org.eclipse.core.resources.IFile;
 import  org.eclipse.core.runtime.IPath;
 import  org.eclipse.core.runtime.CoreException;
 
 
 public class SourceFile implements ICompilationUnit {
 
 public IFile resource;
 boolean updateClassFile;
 
 public SourceFile(IFile resourceClasspathMultiDirectory sourceLocation) {
 	this. = resource;
 	this. = sourceLocation;
 	this. = false;
 }
 
 public SourceFile(IFile resourceClasspathMultiDirectory sourceLocationboolean updateClassFile) {
 	this(resourcesourceLocation);
 
 	this. = updateClassFile;
 }
 
 public boolean equals(Object o) {
 	if (this == oreturn true;
 	if (!(o instanceof SourceFile)) return false;
 
 	SourceFile f = (SourceFileo;
 	return this. == f.sourceLocation && this..getFullPath().equals(f.resource.getFullPath());
 }
 
 	// answer a String with the qualified type name for the source file in the form: 'p1/p2/A'
 	IPath fullPath = this..getFullPath();
 	int resourceSegmentCount = fullPath.segmentCount();
 	int sourceFolderSegmentCount = this...getFullPath().segmentCount();
 	int charCount = (resourceSegmentCount - sourceFolderSegmentCount - 1);
 	resourceSegmentCount--; // deal with the last segment separately
 	for (int i = sourceFolderSegmentCounti < resourceSegmentCounti++)
 		charCount += fullPath.segment(i).length();
 	String lastSegment = fullPath.segment(resourceSegmentCount);
 	int extensionIndex = Util.indexOfJavaLikeExtension(lastSegment);
 	charCount += extensionIndex;
 
 	char[] result = new char[charCount];
 	int offset = 0;
 	for (int i = sourceFolderSegmentCounti < resourceSegmentCounti++) {
 		String segment = fullPath.segment(i);
 		int size = segment.length();
 		segment.getChars(0, sizeresultoffset);
 		offset += size;
 		result[offset++] = '/';
 	}
 	lastSegment.getChars(0, extensionIndexresultoffset);
 	return new String(result);
 }
 
 public char[] getContents() {
 
 	try {
 	} catch (CoreException e) {
 		throw new AbortCompilation(truenew MissingSourceFileException(this..getFullPath().toString()));
 	}
 }

See also:
org.eclipse.jdt.internal.compiler.env.IDependent.getFileName()
 
 public char[] getFileName() {
 	return this..getFullPath().toString().toCharArray(); // do not know what you want to return here
 }
 
 public char[] getMainTypeName() {
 	char[] typeName = this..toCharArray();
 	int lastIndex = CharOperation.lastIndexOf('/'typeName);
 	return CharOperation.subarray(typeNamelastIndex + 1, -1);
 }
 
 public char[][] getPackageName() {
 	char[] typeName = this..toCharArray();
	int lastIndex = CharOperation.lastIndexOf('/'typeName);
	return CharOperation.splitOn('/'typeName, 0, lastIndex);
public int hashCode() {
	return this..hashCode();
public boolean ignoreOptionalProblems() {
	return this..getProjectRelativePath().toString();
public String toString() {
	return "SourceFile[" //$NON-NLS-1$
this..getFullPath() + "]";  //$NON-NLS-1$
New to GrepCode? Check out our FAQ X