本文整理汇总了Java中org.eclipse.core.runtime.content.IContentDescription类的典型用法代码示例。如果您正苦于以下问题:Java IContentDescription类的具体用法?Java IContentDescription怎么用?Java IContentDescription使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IContentDescription类属于org.eclipse.core.runtime.content包,在下文中一共展示了IContentDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isBPM2FileType
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
private boolean isBPM2FileType(final IFileEditorInput editorInput) {
boolean isBPMN2File = false;
IFile file = editorInput.getFile();
try {
IContentDescription desc = file.getContentDescription();
if (desc != null) {
IContentType type = desc.getContentType();
if (ActivitiBPMNDiagramConstants.BPMN2_CONTENTTYPE_ID.equals(type.getId())) {
isBPMN2File = true;
}
}
} catch (CoreException e) {
e.printStackTrace();
return isBPMN2File;
}
return isBPMN2File;
}
示例2: hasTextContentType
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
/**
* @param file must be not null
* @return true if the file has "text" content description.
*/
public static boolean hasTextContentType(IFile file) {
try {
IContentDescription contentDescr = file.getContentDescription();
if (contentDescr == null) {
return false;
}
IContentType contentType = contentDescr.getContentType();
if (contentType == null) {
return false;
}
return contentType.isKindOf(TEXT_TYPE);
//
} catch (CoreException e) {
FileSyncPlugin.log(
"Could not get content type for: " + file, e, IStatus.WARNING);
}
return false;
}
示例3: shouldValidate
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
private boolean shouldValidate(IResource file, boolean checkExtension) {
if (file == null || !file.exists() || file.getType() != IResource.FILE)
return false;
if (checkExtension) {
String extension = file.getFileExtension();
if (extension != null
&& "json".endsWith(extension.toLowerCase(Locale.US))) //$NON-NLS-1$
return true;
}
IContentDescription contentDescription = null;
try {
contentDescription = ((IFile) file).getContentDescription();
if (contentDescription != null) {
IContentType contentType = contentDescription.getContentType();
return contentDescription != null
&& contentType.isKindOf(getJSONContentType());
}
} catch (CoreException e) {
Logger.logException(e);
}
return false;
}
示例4: handleDetectedSpecialCase
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
private void handleDetectedSpecialCase(IContentDescription description,
Object detectedCharset, Object javaCharset) {
// since equal, we don't need to add, but if our detected version is
// different than javaCharset, then we should add it. This will
// happen, for example, if there's differences in case, or differences
// due to override properties
if (detectedCharset != null) {
// Once we detected a charset, we should set the property even
// though it's the same as javaCharset
// because there are clients that rely on this property to
// determine if the charset is actually detected in file or not.
description.setProperty(
IContentDescriptionExtended.DETECTED_CHARSET,
detectedCharset);
}
}
示例5: isRelevent
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
/**
* @param description
* @return
*/
private boolean isRelevent(IContentDescription description) {
boolean result = false;
if (description == null)
result = false;
else if (description.isRequested(IContentDescription.BYTE_ORDER_MARK))
result = true;
else if (description.isRequested(IContentDescription.CHARSET))
result = true;
else if (description
.isRequested(IContentDescriptionExtended.APPROPRIATE_DEFAULT))
result = true;
else if (description
.isRequested(IContentDescriptionExtended.DETECTED_CHARSET))
result = true;
else if (description
.isRequested(IContentDescriptionExtended.UNSUPPORTED_CHARSET))
result = true;
// else if
// (description.isRequested(IContentDescriptionExtended.ENCODING_MEMENTO))
// result = true;
return result;
}
示例6: isProfileContentType
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
public static boolean isProfileContentType (IResource resource) {
if ((resource instanceof IFile) && resource.exists()) {
try {
IContentDescription cd = ((IFile)resource).getContentDescription();
if (cd != null) {
IContentType type = cd.getContentType();
if ((type != null) && type.isKindOf(PROFILE_CONTENT_TYPE)) {
return true;
}
}
} catch (CoreException e) {
LogUtil.error(e);
}
}
return false;
}
示例7: isJavaPropertiesFile
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
/**
* Checks whether the passed file editor input defines a Java properties file.
*
* @param element the file editor input
* @return <code>true</code> if element defines a Java properties file, <code>false</code>
* otherwise
* @throws CoreException
*
* @since 3.7
*/
public static boolean isJavaPropertiesFile(Object element) throws CoreException {
if (JAVA_PROPERTIES_FILE_CONTENT_TYPE == null || !(element instanceof IFileEditorInput))
return false;
IFileEditorInput input= (IFileEditorInput)element;
IFile file= input.getFile();
if (file == null || !file.isAccessible())
return false;
IContentDescription description= file.getContentDescription();
if (description == null || description.getContentType() == null || !description.getContentType().isKindOf(JAVA_PROPERTIES_FILE_CONTENT_TYPE))
return false;
return true;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:PropertiesFileDocumentProvider.java
示例8: isClassFile
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
private static boolean isClassFile(IFile file) {
IContentDescription contentDescription;
try {
contentDescription= file.getContentDescription();
} catch (CoreException e) {
contentDescription= null;
}
if (contentDescription == null)
return false;
IContentType contentType= contentDescription.getContentType();
if (contentType == null)
return false;
return "org.eclipse.jdt.core.javaClass".equals(contentType.getId()); //$NON-NLS-1$
}
示例9: visit
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
@Override
public boolean visit(IResourceProxy proxy) throws CoreException
{
if (proxy.isDerived())
return false;
if (proxy.getType() == IResource.FILE && proxy.getName().endsWith(".xml"))
{
IFile file = (IFile)proxy.requestResource();
IContentDescription contentDesc = file.getContentDescription();
if (contentDesc != null)
{
IContentType contentType = contentDesc.getContentType();
if (contentType != null && (contentType.isKindOf(configContentType)
|| contentType.isKindOf(springConfigContentType)))
{
configFiles.put(file, contentType);
}
}
}
return true;
}
示例10: getDescriptionValue
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
/**
* Returns the given property's Eclipse value converted to EMF's corresponding basic value.
* @param qualifiedName the name of the property for which this value applies.
* @param value the value to convert.
* @return the given property's Eclipse value converted to EMF's corresponding basic value.
*/
protected Object getDescriptionValue(QualifiedName qualifiedName, Object value)
{
if (value == null)
{
return null;
}
else if (IContentDescription.BYTE_ORDER_MARK.equals(qualifiedName))
{
for (ByteOrderMark byteOrderMarker : ContentHandler.ByteOrderMark.values())
{
if (value == byteOrderMarker.bytes())
{
return byteOrderMarker;
}
}
return null;
}
else
{
return value;
}
}
示例11: getDescriptionValue
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
/**
* Returns the given property's basic EMF value converted to the corresponding Eclipse value.
* @param qualifiedName the name of the property for which this value applies.
* @param value the value to convert.
* @return the given property's basic EMF value converted to the corresponding Eclipse value.
*/
protected Object getDescriptionValue(QualifiedName qualifiedName, Object value)
{
if (value == null)
{
return null;
}
else if (IContentDescription.BYTE_ORDER_MARK.equals(qualifiedName))
{
return ((ContentHandler.ByteOrderMark)value).bytes();
}
else
{
return value;
}
}
示例12: describe
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
@Override
public int describe(InputStream contents, IContentDescription description) throws IOException {
try {
GradleScriptASTParser parser = new GradleScriptASTParser(contents);
PluginsSyntaxDescriberVisitor pluginsVisitor = new PluginsSyntaxDescriberVisitor();
ApplySyntaxDescriberVisitor visitor = new ApplySyntaxDescriberVisitor();
parser.walkScript(pluginsVisitor);
if (pluginsVisitor.isFoundPlugin()) {
return IContentDescriber.VALID;
}
parser.walkScript(visitor);
if (visitor.isFoundplugin()) {
return IContentDescriber.VALID;
}
} catch (MultipleCompilationErrorsException ex) {
return IContentDescriber.INDETERMINATE;
}
return IContentDescriber.INVALID;
}
示例13: getContentDescription
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
public static IContentDescription getContentDescription(String name, InputStream stream) throws IOException {
// tries to obtain a description for this file contents
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
try {
return contentTypeManager.getDescriptionFor(stream, name, IContentDescription.ALL);
} finally {
if (stream != null)
try {
stream.close();
} catch (IOException e) {
// Ignore exceptions on close
}
}
}
示例14: hasBinaryContent
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
private boolean hasBinaryContent(CharSequence seq, IFile file) throws CoreException {
IContentDescription desc = file.getContentDescription();
if (desc != null) {
IContentType contentType = desc.getContentType();
if (contentType != null
&& contentType.isKindOf(
Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT))) {
return false;
}
}
// avoid calling seq.length() at it runs through the complete file,
// thus it would do so for all binary files.
try {
int limit = FileCharSequenceProvider.BUFFER_SIZE;
for (int i = 0; i < limit; i++) {
if (seq.charAt(i) == '\0') {
return true;
}
}
} catch (IndexOutOfBoundsException e) {
} catch (FileCharSequenceException ex) {
if (ex.getCause() instanceof CharConversionException) return true;
throw ex;
}
return false;
}
示例15: getInputStream
import org.eclipse.core.runtime.content.IContentDescription; //导入依赖的package包/类
private InputStream getInputStream(String charset) throws CoreException, IOException {
boolean ok = false;
InputStream contents = fFile.getContents();
try {
if (CHARSET_UTF_8.equals(charset)) {
/*
* This is a workaround for a corresponding bug in Java readers and writer,
* see http://developer.java.sun.com/developer/bugParade/bugs/4508058.html
* we remove the BOM before passing the stream to the reader
*/
IContentDescription description = fFile.getContentDescription();
if ((description != null)
&& (description.getProperty(IContentDescription.BYTE_ORDER_MARK) != null)) {
int bomLength = IContentDescription.BOM_UTF_8.length;
byte[] bomStore = new byte[bomLength];
int bytesRead = 0;
do {
int bytes = contents.read(bomStore, bytesRead, bomLength - bytesRead);
if (bytes == -1) throw new IOException();
bytesRead += bytes;
} while (bytesRead < bomLength);
if (!Arrays.equals(bomStore, IContentDescription.BOM_UTF_8)) {
// discard file reader, we were wrong, no BOM -> new stream
contents.close();
contents = fFile.getContents();
}
}
}
ok = true;
} finally {
if (!ok && contents != null)
try {
contents.close();
} catch (IOException ex) {
// ignore
}
}
return contents;
}