當前位置: 首頁>>代碼示例>>Java>>正文


Java IStorage.getContents方法代碼示例

本文整理匯總了Java中org.eclipse.core.resources.IStorage.getContents方法的典型用法代碼示例。如果您正苦於以下問題:Java IStorage.getContents方法的具體用法?Java IStorage.getContents怎麽用?Java IStorage.getContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.resources.IStorage的用法示例。


在下文中一共展示了IStorage.getContents方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readBpmn

import org.eclipse.core.resources.IStorage; //導入方法依賴的package包/類
private static BpmnParser readBpmn(IStorage bpmnStorage) {

    BpmnParser bpmnParser = new BpmnParser();
    try {
      XMLInputFactory xif = XMLInputFactory.newInstance();
      InputStreamReader in = new InputStreamReader(bpmnStorage.getContents(), "UTF-8");
      XMLStreamReader xtr = xif.createXMLStreamReader(in);

      bpmnParser.parseBpmn(xtr);

      xtr.close();
      in.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
    return bpmnParser;
  }
 
開發者ID:logicalhacking,項目名稱:SecureBPMN,代碼行數:19,代碼來源:DiagramUpdater.java

示例2: findContentTypesFromEditorInput

import org.eclipse.core.resources.IStorage; //導入方法依賴的package包/類
/**
 * Find the content types from the given {@link IDocument} by using
 * {@link IEditorInput} and null otherwise.
 * 
 * @param document
 * @return the content types from the given {@link IDocument} by using
 *         {@link IEditorInput} and null otherwise.
 */
private static ContentTypeInfo findContentTypesFromEditorInput(IDocument document) {
    IEditorInput editorInput = getEditorInput(document);
    if (editorInput != null) {
        if (editorInput instanceof IStorageEditorInput) {
            InputStream input = null;
            try {
                IStorage storage = ((IStorageEditorInput) editorInput).getStorage();
                String fileName = storage.getName();
                input = storage.getContents();
                return new ContentTypeInfo(fileName,
                        Platform.getContentTypeManager().findContentTypesFor(input, fileName));
            } catch (Exception e) {
                return null;
            } finally {
                try {
                    if (input != null)
                        input.close();
                } catch (IOException x) {
                }
            }
        } else {
            // TODO: manage other type of IEditorInput
        }
    }
    return null;
}
 
開發者ID:eclipse,項目名稱:tm4e,代碼行數:35,代碼來源:ContentTypeHelper.java

示例3: openStream

import org.eclipse.core.resources.IStorage; //導入方法依賴的package包/類
private InputStream openStream(IEditorInput input) throws CoreException,
    IOException {
  if (input instanceof IStorageEditorInput) {
    final IStorage storage = ((IStorageEditorInput) input).getStorage();
    return storage.getContents();
  }
  if (input instanceof IURIEditorInput) {
    final URI uri = ((IURIEditorInput) input).getURI();
    return uri.toURL().openStream();
  }
  throw new IOException("Unsupported input type: " + input.getClass()); //$NON-NLS-1$
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:13,代碼來源:ExecutionDataContent.java

示例4: set

import org.eclipse.core.resources.IStorage; //導入方法依賴的package包/類
@Override
public void set(IStorage iStorage) throws CoreException {
    resetAll();
    InputStream inputStream = iStorage.getContents();
    InputStream resettableStream = new BufferedInputStream(inputStream,
            CodedIO.MAX_BUF_SIZE);
    resettableStream.mark(CodedIO.MAX_MARK_SIZE);
    set(resettableStream);
    // TODO we'll need to "remember" IFile, or
    // get its (or its project's) settings, in case
    // those are needed to handle cases when the
    // encoding is not in the file stream.
}
 
開發者ID:angelozerr,項目名稱:eclipse-wtp-json,代碼行數:14,代碼來源:JSONResourceEncodingDetector.java

示例5: setDocumentContent

import org.eclipse.core.resources.IStorage; //導入方法依賴的package包/類
/**
 * Initializes the given document from the given editor input using the
 * given character encoding.
 * 
 * @param document
 *            the document to be initialized
 * @param editorInput
 *            the input from which to derive the content of the document
 * @param encoding
 *            the character encoding used to read the editor input
 * @return <code>true</code> if the document content could be set,
 *         <code>false</code> otherwise
 * @throws CoreException
 *             if the given editor input cannot be accessed
 */
protected boolean setDocumentContent( IDocument document,
        IEditorInput editorInput, String encoding ) throws CoreException
{
    IStorage storage = null;
    if ( editorInput instanceof IStorageEditorInput )
    {
        storage = ( (IStorageEditorInput) editorInput ).getStorage( );
    }

    if ( storage != null )
    {
        InputStream stream = storage.getContents( );
        try
        {
            setDocumentContent( document, stream, encoding );
        }
        finally
        {
            try
            {
                stream.close( );
            }
            catch ( IOException x )
            {
            }
        }
        return true;
    }
    return false;
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:46,代碼來源:StorageDocumentProvider.java


注:本文中的org.eclipse.core.resources.IStorage.getContents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。