Java Code Examples for com.intellij.util.ArrayUtil#EMPTY_BYTE_ARRAY

The following examples show how to use com.intellij.util.ArrayUtil#EMPTY_BYTE_ARRAY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StoredContent.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] getBytes() {
  //todo handle unavailable content 
  //if (!isAvailable()) throw new RuntimeException("content is not available");
  try {
    if (myContentId == UNAVAILABLE) return ArrayUtil.EMPTY_BYTE_ARRAY;
    return getFS().contentsToByteArray(myContentId);
  }
  catch (IOException e) {
    throw new RuntimeException("cannot get stored content", e);
  }
}
 
Example 2
Source File: VirtualFileImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public byte[] contentsToByteArray() throws IOException {
  if (myFileInfo == null) {
    throw new UnsupportedOperationException();
  }

  VirtualFile localFile = myFileInfo.getLocalFile();
  if (localFile != null) {
    return localFile.contentsToByteArray();
  }
  return ArrayUtil.EMPTY_BYTE_ARRAY;
}
 
Example 3
Source File: JBZipFile.java    From consulo with Apache License 2.0 5 votes vote down vote up
private byte[] readBytes(int count) throws IOException {
  if (count > 0) {
    byte[] bytes = new byte[count];
    archive.readFully(bytes);
    return bytes;
  }
  else {
    return ArrayUtil.EMPTY_BYTE_ARRAY;
  }
}
 
Example 4
Source File: VcsVirtualFile.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public byte[] contentsToByteArray() throws IOException {
  if (myContentLoadFailed || myProcessingBeforeContentsChange) {
    return ArrayUtil.EMPTY_BYTE_ARRAY;
  }
  if (myContent == null) {
    loadContent();
  }
  return myContent;
}
 
Example 5
Source File: ContentRevisionVirtualFile.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public byte[] contentsToByteArray() throws IOException {
  if (myContentLoadFailed || myProcessingBeforeContentsChange) {
    return ArrayUtil.EMPTY_BYTE_ARRAY;
  }
  if (myContent == null) {
    loadContent();
  }
  return myContent;
}
 
Example 6
Source File: Mock.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public byte[] contentsToByteArray() throws IOException {
  return ArrayUtil.EMPTY_BYTE_ARRAY;
}
 
Example 7
Source File: MockLocalFileSystem.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public byte[] contentsToByteArray(@Nonnull final VirtualFile file) throws IOException {
  return ArrayUtil.EMPTY_BYTE_ARRAY;
}
 
Example 8
Source File: BinaryLightVirtualFile.java    From consulo with Apache License 2.0 4 votes vote down vote up
public BinaryLightVirtualFile(@NonNls String name) {
  this(name, ArrayUtil.EMPTY_BYTE_ARRAY);
}
 
Example 9
Source File: FileContent.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void setEmptyContent() {
  myCachedBytes = ArrayUtil.EMPTY_BYTE_ARRAY;
  myCachedLength = 0;
}
 
Example 10
Source File: TestVirtualFile.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public byte[] contentsToByteArray() throws IOException {
  return myContent == null ? ArrayUtil.EMPTY_BYTE_ARRAY : myContent.getBytes();
}
 
Example 11
Source File: ContentRevisionVirtualFile.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void loadContent() {
  final VcsFileSystem vcsFileSystem = ((VcsFileSystem)getFileSystem());

  try {
    final String content = myContentRevision.getContent();
    if (content == null) {
      throw new VcsException("Could not load content");
    }
    fireBeforeContentsChange();

    myModificationStamp++;
    setRevision(myContentRevision.getRevisionNumber().asString());
    myContent = content.getBytes(getCharset());
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        vcsFileSystem.fireContentsChanged(this, ContentRevisionVirtualFile.this, 0);
      }
    });

  }
  catch (VcsException e) {
    myContentLoadFailed = true;
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        vcsFileSystem.fireBeforeFileDeletion(this, ContentRevisionVirtualFile.this);
      }
    });
    myContent = ArrayUtil.EMPTY_BYTE_ARRAY;
    setRevision("0");

    Messages.showMessageDialog(
            VcsBundle.message("message.text.could.not.load.virtual.file.content", getPresentableUrl(), e.getLocalizedMessage()),
            VcsBundle.message("message.title.could.not.load.content"),
            Messages.getInformationIcon());

    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        vcsFileSystem.fireFileDeleted(this, ContentRevisionVirtualFile.this, getName(), getParent());
      }
    });

  }
  catch (ProcessCanceledException ex) {
    myContent = ArrayUtil.EMPTY_BYTE_ARRAY;
  }
}
 
Example 12
Source File: VcsFileRevision.java    From consulo with Apache License 2.0 4 votes vote down vote up
public byte[] getContent() throws IOException, VcsException {
  return ArrayUtil.EMPTY_BYTE_ARRAY;
}