当前位置: 首页>>代码示例>>Java>>正文


Java IContentDescription.getCharset方法代码示例

本文整理汇总了Java中org.eclipse.core.runtime.content.IContentDescription.getCharset方法的典型用法代码示例。如果您正苦于以下问题:Java IContentDescription.getCharset方法的具体用法?Java IContentDescription.getCharset怎么用?Java IContentDescription.getCharset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.runtime.content.IContentDescription的用法示例。


在下文中一共展示了IContentDescription.getCharset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCharset

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
public static String getCharset(String name, InputStream stream) throws IOException {
	IContentDescription description = getContentDescription(name, stream);
	return description == null ? null : description.getCharset();

}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:6,代码来源:SVNUIPlugin.java

示例2: cacheEncodingState

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
protected void cacheEncodingState() {
  fEncoding = fExplicitEncoding;
  fHasBOM = false;
  fIsCacheUpdated = true;

  InputStream stream = null;
  try {
    stream = getFileContents(fFileStore);
    if (stream == null) return;

    QualifiedName[] options =
        new QualifiedName[] {IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK};
    IContentDescription description =
        null; // Platform.getContentTypeManager().getDescriptionFor(stream, fFileStore.getName(),
    // options);
    if (description != null) {
      fHasBOM = description.getProperty(IContentDescription.BYTE_ORDER_MARK) != null;
      if (fEncoding == null) fEncoding = description.getCharset();
    }
  } catch (CoreException e) {
    // do nothing
  } /*catch (IOException e) {
    	// do nothing
    }*/ finally {
    try {
      if (stream != null) stream.close();
    } catch (IOException ex) {
      FileBuffersPlugin.getDefault()
          .log(
              new Status(
                  IStatus.ERROR,
                  FileBuffersPlugin.PLUGIN_ID,
                  IStatus.OK,
                  FileBuffersMessages.JavaTextFileBuffer_error_closeStream,
                  ex));
    }
  }

  // Use global default
  if (fEncoding == null) fEncoding = fManager.getDefaultEncoding();
}
 
开发者ID:eclipse,项目名称:che,代码行数:42,代码来源:FileStoreTextFileBuffer.java

示例3: createMemento

import org.eclipse.core.runtime.content.IContentDescription; //导入方法依赖的package包/类
protected EncodingMemento createMemento(
		IContentDescription contentDescription) {
	EncodingMemento result;
	String appropriateDefault = contentDescription.getContentType()
			.getDefaultCharset();
	String detectedCharset = (String) contentDescription
			.getProperty(IContentDescriptionExtended.DETECTED_CHARSET);
	String unSupportedCharset = (String) contentDescription
			.getProperty(IContentDescriptionExtended.UNSUPPORTED_CHARSET);
	String javaCharset = contentDescription.getCharset();

	// Set default workbench encoding:
	if (detectedCharset == null && appropriateDefault == null) {
		detectedCharset = javaCharset = appropriateDefault = ResourcesPlugin
				.getEncoding();
	}

	// integrity checks for debugging
	if (javaCharset == null) {
		Logger.log(Logger.INFO_DEBUG, "charset equaled null!"); //$NON-NLS-1$
	} else if (javaCharset.length() == 0) {
		Logger.log(Logger.INFO_DEBUG, "charset equaled emptyString!"); //$NON-NLS-1$
	}
	byte[] BOM = (byte[]) contentDescription
			.getProperty(IContentDescription.BYTE_ORDER_MARK);
	// result = (EncodingMemento)
	// contentDescription.getProperty(IContentDescriptionExtended.ENCODING_MEMENTO);
	result = createEncodingMemento(BOM, javaCharset, detectedCharset,
			unSupportedCharset, appropriateDefault, null);
	if (!result.isValid()) {
		result.setAppropriateDefault(appropriateDefault);
		// integrity check for debugging "invalid" cases.
		// the apprriate default we have, should equal what's in the
		// detected field. (not sure this is always required)
		if (DEBUG) {
			if (appropriateDefault != null
					&& !appropriateDefault.equals(detectedCharset)) {
				Logger
						.log(Logger.INFO_DEBUG,
								"appropriate did not equal detected, as expected for invalid charset case"); //$NON-NLS-1$
			}
		}
	}
	return result;
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-freemarker,代码行数:46,代码来源:FMDocumentLoader.java


注:本文中的org.eclipse.core.runtime.content.IContentDescription.getCharset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。