Java 类com.intellij.util.io.UnsyncByteArrayInputStream 实例源码

项目:intellij-ce-playground    文件:HTMLControls.java   
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
private static Control[] loadControls() {
  Document document;
  try {
    // use temporary bytes stream because otherwise inputStreamSkippingBOM will fail
    // on ZipFileInputStream used in jar files
    final InputStream stream = HTMLControls.class.getResourceAsStream("HtmlControls.xml");
    final byte[] bytes = FileUtilRt.loadBytes(stream);
    stream.close();
    final UnsyncByteArrayInputStream bytesStream = new UnsyncByteArrayInputStream(bytes);
    document = JDOMUtil.loadDocument(CharsetToolkit.inputStreamSkippingBOM(bytesStream));
    bytesStream.close();
  } catch (Exception e) {
    LOG.error(e);
    return new Control[0];
  }
  if (!document.getRootElement().getName().equals("htmlControls")) {
    LOG.error("HTMLControls storage is broken");
    return new Control[0];
  }
  return XmlSerializer.deserialize(document, Control[].class);
}
项目:intellij-ce-playground    文件:SmallMapSerializer.java   
private void init() {
  try {
    final byte[] bytes = FileUtil.loadFileBytes(myFile);
    final DataInputStream dis = new DataInputStream(new UnsyncByteArrayInputStream(bytes));
    final int size = dis.readInt();
    for (int i = 0; i < size; i++) {
      final KeyWrapper<K> keyWrapper = new KeyWrapper<K>(myKeyDescriptor, myKeyDescriptor.read(dis));
      final V value = myValueExternalizer.read(dis);
      myMap.put(keyWrapper, value);
    }
  } catch (FileNotFoundException ignore) {
  } catch (IOException e) {
    LOG.error(e);
  }
}
项目:intellij-ce-playground    文件:SerializedStubTree.java   
@NotNull
public Stub getStub(boolean willIndexStub) throws SerializerNotFoundException {
  Stub stubElement = myStubElement;
  if (stubElement != null) {
    // not null myStubElement means we just built SerializedStubTree for indexing,
    // if we request stub for indexing we can safely use it
    myStubElement = null;
    if (willIndexStub) return stubElement;
  }
  return SerializationManagerEx.getInstanceEx().deserialize(new UnsyncByteArrayInputStream(myBytes));
}
项目:tools-idea    文件:SmallMapSerializer.java   
private void init() {
  try {
    final byte[] bytes = FileUtil.loadFileBytes(myFile);
    final DataInputStream dis = new DataInputStream(new UnsyncByteArrayInputStream(bytes));
    final int size = dis.readInt();
    for (int i = 0; i < size; i++) {
      final KeyWrapper<K> keyWrapper = new KeyWrapper<K>(myKeyDescriptor, myKeyDescriptor.read(dis));
      final V value = myValueExternalizer.read(dis);
      myMap.put(keyWrapper, value);
    }
  } catch (FileNotFoundException ignore) {
  } catch (IOException e) {
    LOG.error(e);
  }
}
项目:tools-idea    文件:SerializedStubTree.java   
@NotNull
public Stub getStub(boolean willIndexStub) throws SerializerNotFoundException {
  Stub stubElement = myStubElement;
  if (stubElement != null) {
    // not null myStubElement means we just built SerializedStubTree for indexing,
    // if we request stub for indexing we can safely use it
    myStubElement = null;
    if (willIndexStub) return stubElement;
  }
  return SerializationManagerEx.getInstanceEx().deserialize(new UnsyncByteArrayInputStream(myBytes));
}
项目:consulo    文件:VirtualFileImpl.java   
@Override
@Nonnull
public InputStream getInputStream() throws IOException {
  final byte[] preloadedContent = getUserData(ourPreloadedContentKey);

  return VfsUtilCore.inputStreamSkippingBOM(
          preloadedContent == null ?
          ourPersistence.getInputStream(this):
          new DataInputStream(new UnsyncByteArrayInputStream(preloadedContent)),
          this
  );
}
项目:consulo    文件:MapReduceIndex.java   
public static <Key, Value> void checkValuesHaveProperEqualsAndHashCode(@Nonnull Map<Key, Value> data,
                                                                       @Nonnull ID<Key, Value> indexId,
                                                                       @Nonnull DataExternalizer<Value> valueExternalizer) {
  if (DebugAssertions.DEBUG) {
    for (Map.Entry<Key, Value> e : data.entrySet()) {
      final Value value = e.getValue();
      if (!(Comparing.equal(value, value) && (value == null || value.hashCode() == value.hashCode()))) {
        LOG.error("Index " + indexId.toString() + " violates equals / hashCode contract for Value parameter");
      }

      try {
        final BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream();
        DataOutputStream outputStream = new DataOutputStream(out);
        valueExternalizer.save(outputStream, value);
        outputStream.close();
        final Value deserializedValue =
                valueExternalizer.read(new DataInputStream(new UnsyncByteArrayInputStream(out.getInternalBuffer(), 0, out.size())));

        if (!(Comparing.equal(value, deserializedValue) && (value == null || value.hashCode() == deserializedValue.hashCode()))) {
          LOG.error("Index " + indexId.toString() + " deserialization violates equals / hashCode contract for Value parameter");
        }
      }
      catch (IOException ex) {
        LOG.error(ex);
      }
    }
  }
}
项目:consulo    文件:SmallMapSerializer.java   
private void init() {
  try {
    final byte[] bytes = FileUtil.loadFileBytes(myFile);
    final DataInputStream dis = new DataInputStream(new UnsyncByteArrayInputStream(bytes));
    final int size = dis.readInt();
    for (int i = 0; i < size; i++) {
      final KeyWrapper<K> keyWrapper = new KeyWrapper<K>(myKeyDescriptor, myKeyDescriptor.read(dis));
      final V value = myValueExternalizer.read(dis);
      myMap.put(keyWrapper, value);
    }
  } catch (FileNotFoundException ignore) {
  } catch (IOException e) {
    LOG.error(e);
  }
}
项目:consulo    文件:SerializedStubTree.java   
@Nonnull
public Stub getStub(boolean willIndexStub) throws SerializerNotFoundException {
  Stub stubElement = myStubElement;
  if (stubElement != null) {
    // not null myStubElement means we just built SerializedStubTree for indexing,
    // if we request stub for indexing we can safely use it
    myStubElement = null;
    if (willIndexStub) return stubElement;
  }
  return SerializationManagerEx.getInstanceEx().deserialize(new UnsyncByteArrayInputStream(myBytes));
}
项目:consulo-xml    文件:HTMLControls.java   
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
private static Control[] loadControls()
{
    Document document;
    try
    {
        // use temporary bytes stream because otherwise inputStreamSkippingBOM will fail
        // on ZipFileInputStream used in jar files
        final InputStream stream = HTMLControls.class.getResourceAsStream("HtmlControls.xml");
        final byte[] bytes = FileUtilRt.loadBytes(stream);
        stream.close();
        final UnsyncByteArrayInputStream bytesStream = new UnsyncByteArrayInputStream(bytes);
        document = JDOMUtil.loadDocument(CharsetToolkit.inputStreamSkippingBOM(bytesStream));
        bytesStream.close();
    }
    catch(Exception e)
    {
        LOG.error(e);
        return new Control[0];
    }
    if(!document.getRootElement().getName().equals("htmlControls"))
    {
        LOG.error("HTMLControls storage is broken");
        return new Control[0];
    }
    return XmlSerializer.deserialize(document, Control[].class);
}
项目:intellij-ce-playground    文件:MemoryResource.java   
@Override
public InputStream getInputStream() throws IOException {
  return new UnsyncByteArrayInputStream(myContent);
}
项目:intellij-ce-playground    文件:RefCountingStorage.java   
@Override
public DataInputStream readStream(int record) throws IOException {
  if (myDoNotZipCaches) return super.readStream(record);
  BufferExposingByteArrayOutputStream stream = internalReadStream(record);
  return new DataInputStream(new UnsyncByteArrayInputStream(stream.getInternalBuffer(), 0, stream.size()));
}
项目:intellij-ce-playground    文件:RefCountingStorage.java   
public CustomInflaterInputStream(byte[] compressedData) {
  super(new UnsyncByteArrayInputStream(compressedData), new Inflater(), 1);
  // force to directly use compressed data, this ensures less round trips with native extraction code and copy streams
  this.buf = compressedData;
  this.len = -1;
}
项目:intellij-ce-playground    文件:AbstractStorage.java   
public DataInputStream readStream(int record) throws IOException {
  final byte[] bytes = readBytes(record);
  return new DataInputStream(new UnsyncByteArrayInputStream(bytes));
}
项目:tools-idea    文件:JarMemoryLoader.java   
@Override
public InputStream getInputStream() throws IOException {
  return new UnsyncByteArrayInputStream(myContent);
}
项目:tools-idea    文件:RefCountingStorage.java   
public DataInputStream readStream(int record) throws IOException {
  if (myDoNotZipCaches) return super.readStream(record);
  BufferExposingByteArrayOutputStream stream = internalReadStream(record);
  return new DataInputStream(new UnsyncByteArrayInputStream(stream.getInternalBuffer(), 0, stream.size()));
}
项目:tools-idea    文件:RefCountingStorage.java   
public CustomInflaterInputStream(byte[] compressedData) {
  super(new UnsyncByteArrayInputStream(compressedData), new Inflater(), 1);
  // force to directly use compressed data, this ensures less round trips with native extraction code and copy streams
  this.buf = compressedData;
  this.len = -1;
}
项目:tools-idea    文件:AbstractStorage.java   
public DataInputStream readStream(int record) throws IOException {
  final byte[] bytes = readBytes(record);
  return new DataInputStream(new UnsyncByteArrayInputStream(bytes));
}
项目:consulo    文件:MemoryResource.java   
@Override
public InputStream getInputStream() throws IOException {
  return new UnsyncByteArrayInputStream(myContent);
}
项目:consulo    文件:RefCountingStorage.java   
@Override
public DataInputStream readStream(int record) throws IOException {
  if (myDoNotZipCaches) return super.readStream(record);
  BufferExposingByteArrayOutputStream stream = internalReadStream(record);
  return new DataInputStream(new UnsyncByteArrayInputStream(stream.getInternalBuffer(), 0, stream.size()));
}
项目:consulo    文件:RefCountingStorage.java   
public CustomInflaterInputStream(byte[] compressedData) {
  super(new UnsyncByteArrayInputStream(compressedData), new Inflater(), 1);
  // force to directly use compressed data, this ensures less round trips with native extraction code and copy streams
  this.buf = compressedData;
  this.len = -1;
}
项目:consulo    文件:AbstractStorage.java   
public DataInputStream readStream(int record) throws IOException {
  final byte[] bytes = readBytes(record);
  return new DataInputStream(new UnsyncByteArrayInputStream(bytes));
}