Example usage for org.eclipse.jdt.internal.core.util Messages build_wrongFileFormat

List of usage examples for org.eclipse.jdt.internal.core.util Messages build_wrongFileFormat

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.util Messages build_wrongFileFormat.

Prototype

String build_wrongFileFormat

To view the source code for org.eclipse.jdt.internal.core.util Messages build_wrongFileFormat.

Click Source Link

Usage

From source file:org.eclipse.jdt.internal.core.JavaModelManager.java

License:Open Source License

/**
 * Reads the build state for the relevant project.
 *///from  www  . j  a va  2s. c  om
protected Object readState(IProject project) throws CoreException {
    File file = getSerializationFile(project);
    if (file != null && file.exists()) {
        try {
            DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
            try {
                String pluginID = in.readUTF();
                if (!pluginID.equals(JavaCore.PLUGIN_ID))
                    throw new IOException(Messages.build_wrongFileFormat);
                String kind = in.readUTF();
                if (!kind.equals("STATE")) //$NON-NLS-1$
                    throw new IOException(Messages.build_wrongFileFormat);
                if (in.readBoolean())
                    return JavaBuilder.readState(project, in);
                if (JavaBuilder.DEBUG)
                    System.out.println("Saved state thinks last build failed for " + project.getName()); //$NON-NLS-1$
            } finally {
                in.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new CoreException(new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, Platform.PLUGIN_ERROR,
                    "Error reading last build state for project " + project.getName(), e)); //$NON-NLS-1$
        }
    } else if (JavaBuilder.DEBUG) {
        if (file == null)
            System.out.println("Project does not exist: " + project); //$NON-NLS-1$
        else
            System.out.println("Build state file " + file.getPath() + " does not exist"); //$NON-NLS-1$ //$NON-NLS-2$
    }
    return null;
}