diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/PlatformTools.java')
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/PlatformTools.java | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/PlatformTools.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/PlatformTools.java deleted file mode 100644 index adca663831..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/utility/PlatformTools.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle. 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: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.core.internal.utility; - -import java.io.IOException; -import java.io.InputStream; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.core.runtime.content.IContentTypeManager; -import org.eclipse.jpt.core.JptCorePlugin; - -/** - * A collection of utilities for dealing with the Eclipse platform API. - */ -public class PlatformTools { - - /** - * Return the specified file's content type, - * using the Eclipse platform's content type manager. - */ - public static IContentType getContentType(IFile file) { - String fileName = file.getName(); - InputStream fileContents = null; - try { - fileContents = file.getContents(); - } catch (CoreException ex) { - JptCorePlugin.log(ex); - // look for content type based on the file name only(?) - return findContentTypeFor(fileName); - } - - IContentType contentType = null; - try { - contentType = findContentTypeFor(fileContents, fileName); - } catch (IOException ex) { - JptCorePlugin.log(ex); - } finally { - try { - fileContents.close(); - } catch (IOException ex) { - JptCorePlugin.log(ex); - } - } - return contentType; - } - - private static IContentType findContentTypeFor(InputStream fileContents, String fileName) throws IOException { - return getContentTypeManager().findContentTypeFor(fileContents, fileName); - } - - private static IContentType findContentTypeFor(String fileName) { - return getContentTypeManager().findContentTypeFor(fileName); - } - - private static IContentTypeManager getContentTypeManager() { - return Platform.getContentTypeManager(); - } - - private PlatformTools() { - super(); - throw new UnsupportedOperationException(); - } - -} |