本文整理匯總了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;
}
示例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;
}
示例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$
}
示例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.
}
示例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;
}