• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DataInputOutputUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.util.io.DataInputOutputUtil的典型用法代码示例。如果您正苦于以下问题:Java DataInputOutputUtil类的具体用法?Java DataInputOutputUtil怎么用?Java DataInputOutputUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataInputOutputUtil类属于com.intellij.util.io包,在下文中一共展示了DataInputOutputUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: save

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
public static <X> void save(final TIntHashSet x, final DataOutput out) {
  try {
    DataInputOutputUtil.writeINT(out, x.size());
    x.forEach(new TIntProcedure() {
      @Override
      public boolean execute(int value) {
        try {
          DataInputOutputUtil.writeINT(out, value);
          return true;
        }
        catch (IOException e) {
          throw new BuildDataCorruptedException(e);
        }
      }
    });
  }
  catch (IOException c) {
    throw new BuildDataCorruptedException(c);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:RW.java


示例2: save

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
@Override
public void save(@NotNull final DataOutput out, final TIntHashSet value) throws IOException {
  final Ref<IOException> exRef = new Ref<IOException>(null);
  value.forEach(new TIntProcedure() {
    @Override
    public boolean execute(int elem) {
      try {
        DataInputOutputUtil.writeINT(out, elem);
      }
      catch (IOException e) {
        exRef.set(e);
        return false;
      }
      return true;
    }
  });
  final IOException exception = exRef.get();
  if (exception != null) {
    throw exception;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:IntIntPersistentMultiMaplet.java


示例3: ClassRepr

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
public ClassRepr(final DependencyContext context, final DataInput in) {
  super(in);
  try {
    this.myContext = context;
    myFileName = DataInputOutputUtil.readINT(in);
    mySuperClass = (TypeRepr.ClassType)TypeRepr.externalizer(context).read(in);
    myInterfaces = (Set<TypeRepr.AbstractType>)RW.read(TypeRepr.externalizer(context), new THashSet<TypeRepr.AbstractType>(1), in);
    myFields = (Set<FieldRepr>)RW.read(FieldRepr.externalizer(context), new THashSet<FieldRepr>(), in);
    myMethods = (Set<MethodRepr>)RW.read(MethodRepr.externalizer(context), new THashSet<MethodRepr>(), in);
    myAnnotationTargets = (Set<ElemType>)RW.read(UsageRepr.AnnotationUsage.elementTypeExternalizer, EnumSet.noneOf(ElemType.class), in);

    final String s = RW.readUTF(in);

    myRetentionPolicy = s.length() == 0 ? null : RetentionPolicy.valueOf(s);

    myOuterClassName = DataInputOutputUtil.readINT(in);
    int flags = DataInputOutputUtil.readINT(in);
    myIsLocal = (flags & LOCAL_MASK) != 0;
    myIsAnonymous = (flags & ANONYMOUS_MASK) != 0;
    myUsages =(Set<UsageRepr.Usage>)RW.read(UsageRepr.externalizer(context), new THashSet<UsageRepr.Usage>(), in);
  }
  catch (IOException e) {
    throw new BuildDataCorruptedException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ClassRepr.java


示例4: save

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
@Override
public void save(final DataOutput out) {
  try {
    super.save(out);
    DataInputOutputUtil.writeINT(out, myFileName);
    mySuperClass.save(out);
    RW.save(myInterfaces, out);
    RW.save(myFields, out);
    RW.save(myMethods, out);
    RW.save(myAnnotationTargets, UsageRepr.AnnotationUsage.elementTypeExternalizer, out);
    RW.writeUTF(out, myRetentionPolicy == null ? "" : myRetentionPolicy.toString());
    DataInputOutputUtil.writeINT(out, myOuterClassName);
    DataInputOutputUtil.writeINT(out, (myIsLocal ? LOCAL_MASK:0) | (myIsAnonymous ? ANONYMOUS_MASK : 0));

    RW.save(myUsages, UsageRepr.externalizer(myContext), out);
  }
  catch (IOException e) {
    throw new BuildDataCorruptedException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ClassRepr.java


示例5: persistAttribute

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
@Override
public void persistAttribute(@NotNull Project project, @NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException {
  final DataInputStream iStream = PERSISTENCE.readAttribute(fileOrDir);
  if (iStream != null) {
    try {
      final int oldLevelOrdinal = DataInputOutputUtil.readINT(iStream);
      if (oldLevelOrdinal == level.ordinal()) return;
    }
    finally {
      iStream.close();
    }
  }

  final DataOutputStream oStream = PERSISTENCE.writeAttribute(fileOrDir);
  DataInputOutputUtil.writeINT(oStream, level.ordinal());
  oStream.close();

  for (VirtualFile child : fileOrDir.getChildren()) {
    if (!child.isDirectory() && StdFileTypes.JAVA.equals(child.getFileType())) {
      PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(child);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:JavaLanguageLevelPusher.java


示例6: readChange

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
public static Change readChange(DataInput in) throws IOException {
  int type = DataInputOutputUtil.readINT(in);
  switch (type) {
    case 1:
      return new CreateFileChange(in);
    case 2:
      return new CreateDirectoryChange(in);
    case 3:
      return new ContentChange(in);
    case 4:
      return new RenameChange(in);
    case 5:
      return new ROStatusChange(in);
    case 6:
      return new MoveChange(in);
    case 7:
      return new DeleteChange(in);
    case 8:
      return new PutLabelChange(in);
    case 9:
      return new PutSystemLabelChange(in);
  }
  throw new IOException("unexpected change type: " + type);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:StreamUtil.java


示例7: writeChange

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
public static void writeChange(DataOutput out, Change change) throws IOException {
  int id = -1;

  Class c = change.getClass();
  if (c.equals(CreateFileChange.class)) id = 1;
  if (c.equals(CreateDirectoryChange.class)) id = 2;
  if (c.equals(ContentChange.class)) id = 3;
  if (c.equals(RenameChange.class)) id = 4;
  if (c.equals(ROStatusChange.class)) id = 5;
  if (c.equals(MoveChange.class)) id = 6;
  if (c.equals(DeleteChange.class)) id = 7;
  if (c.equals(PutLabelChange.class)) id = 8;
  if (c.equals(PutSystemLabelChange.class)) id = 9;

  if (id == -1) throw new IOException("unexpected change type: " + c);

  DataInputOutputUtil.writeINT(out, id);
  change.write(out);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StreamUtil.java


示例8: saveToFile

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
private void saveToFile(@NotNull T instance) throws IOException {
  FileOutputStream fileOutputStream = new FileOutputStream(myFile, true);
  DataOutputStream output = new DataOutputStream(new BufferedOutputStream(fileOutputStream));

  try {
    if (myFile.length() == 0) {
      DataInputOutputUtil.writeTIME(output, FSRecords.getCreationTimestamp());
      DataInputOutputUtil.writeINT(output, myVersion);
    }
    myKeyDescriptor.save(output, instance);
  } finally {
    try {
      output.close();
      fileOutputStream.getFD().sync();
    }  catch (IOException ignore) {}
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:VfsDependentEnum.java


示例9: writeCompressedWithoutOriginalBufferLength

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
public static int writeCompressedWithoutOriginalBufferLength(@NotNull DataOutput out, @NotNull byte[] bytes, int length) throws IOException {
  long started = DUMP_COMPRESSION_STATS ? System.nanoTime() : 0;

  final byte[] compressedOutputBuffer = spareBufferLocal.getBuffer(Snappy.maxCompressedLength(length));
  int compressedSize = Snappy.compress(bytes, 0, length, compressedOutputBuffer, 0);

  final long time = (DUMP_COMPRESSION_STATS ? System.nanoTime() : 0) - started;
  mySizeAfterCompression.addAndGet(compressedSize);
  mySizeBeforeCompression.addAndGet(length);
  int requests = myCompressionRequests.incrementAndGet();
  long l = myCompressionTime.addAndGet(time);

  if (DUMP_COMPRESSION_STATS && requests % 1000  == 0) {
    System.out.println("Compressed " + requests + " times, size:" + mySizeBeforeCompression + "->" + mySizeAfterCompression + " for " + (l  / 1000000) + "ms");
  }

  DataInputOutputUtil.writeINT(out, compressedSize);
  out.write(compressedOutputBuffer, 0, compressedSize);

  return compressedSize;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CompressionUtil.java


示例10: readCompressedWithoutOriginalBufferLength

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
@NotNull
public static byte[] readCompressedWithoutOriginalBufferLength(@NotNull DataInput in) throws IOException {
  int size = DataInputOutputUtil.readINT(in);

  byte[] bytes = spareBufferLocal.getBuffer(size);
  in.readFully(bytes, 0, size);

  int decompressedRequests = myDecompressionRequests.incrementAndGet();
  long started = DUMP_COMPRESSION_STATS ? System.nanoTime() : 0;

  byte[] decompressedResult = Snappy.uncompress(bytes, 0, size);

  long doneTime = (DUMP_COMPRESSION_STATS ? System.nanoTime() : 0) - started;
  long decompressedSize = myDecompressedSize.addAndGet(size);
  long decompressedTime = myDecompressionTime.addAndGet(doneTime);
  if (DUMP_COMPRESSION_STATS && decompressedRequests % 1000 == 0) {
    System.out.println("Decompressed " + decompressedRequests + " times, size: " + decompressedSize  + " for " + (decompressedTime / 1000000) + "ms");
  }

  return decompressedResult;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CompressionUtil.java


示例11: SerializedStubTree

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
public SerializedStubTree(DataInput in) throws IOException {
  if (PersistentHashMapValueStorage.COMPRESSION_ENABLED) {
    int serializedStubsLength = DataInputOutputUtil.readINT(in);
    byte[] bytes = new byte[serializedStubsLength];
    in.readFully(bytes);
    myBytes = bytes;
    myLength = myBytes.length;
    myByteContentLength = DataInputOutputUtil.readLONG(in);
    myCharContentLength = DataInputOutputUtil.readINT(in);
  } else {
    myBytes = CompressionUtil.readCompressed(in);
    myLength = myBytes.length;
    myByteContentLength = in.readLong();
    myCharContentLength = in.readInt();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:SerializedStubTree.java


示例12: save

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
@Override
public void save(@NotNull final DataOutput out, @NotNull final StubIdList value) throws IOException {
  int size = value.size();
  if (size == 0) {
    DataInputOutputUtil.writeINT(out, Integer.MAX_VALUE);
  }
  else if (size == 1) {
    DataInputOutputUtil.writeINT(out, value.get(0)); // most often case
  }
  else {
    DataInputOutputUtil.writeINT(out, -size);
    for(int i = 0; i < size; ++i) {
      DataInputOutputUtil.writeINT(out, value.get(i));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:StubIndexImpl.java


示例13: read

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
@NotNull
@Override
public StubIdList read(@NotNull final DataInput in) throws IOException {
  int size = DataInputOutputUtil.readINT(in);
  if (size == Integer.MAX_VALUE) {
    return new StubIdList();
  }
  else if (size >= 0) {
    return new StubIdList(size);
  }
  else {
    size = -size;
    int[] result = new int[size];
    for(int i = 0; i < size; ++i) {
      result[i] = DataInputOutputUtil.readINT(in);
    }
    return new StubIdList(result, size);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StubIndexImpl.java


示例14: getIndexingStampInfo

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
public static String getIndexingStampInfo(VirtualFile file) {
  try {
    DataInputStream stream = INDEXED_STAMP.readAttribute(file);
    if (stream == null) {
      return "no data";
    }

    long stamp = DataInputOutputUtil.readTIME(stream);
    long size = DataInputOutputUtil.readLONG(stream);
    stream.close();
    return "indexed at " + stamp + " with size " + size;
  }
  catch (IOException e) {
    return ExceptionUtil.getThrowableText(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:StubUpdatingIndex.java


示例15: deserialize

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
@NotNull
private Stub deserialize(@NotNull StubInputStream stream, @Nullable Stub parentStub) throws IOException, SerializerNotFoundException {
  final int id = DataInputOutputUtil.readINT(stream);
  final ObjectStubSerializer serializer = getClassById(id);
  if (serializer == null) {
    String externalId = null;
    try {
      externalId = myNameStorage.valueOf(id);
    } catch (Throwable ignore) {}
    throw new SerializerNotFoundException("No serializer registered for stub: ID=" + id + ", externalId:" + externalId + "; parent stub class=" + (parentStub != null? parentStub.getClass().getName() : "null"));
  }

  Stub stub = serializer.deserialize(stream, parentStub);
  int childCount = DataInputOutputUtil.readINT(stream);
  for (int i = 0; i < childCount; i++) {
    deserialize(stream, stub);
  }
  return stub;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StubSerializationHelper.java


示例16: saveTo

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
@Override
public void saveTo(DataOutput out, DataExternalizer<Value> externalizer) throws IOException {
  if (needsCompacting()) {
    getMergedData().saveTo(out, externalizer);
  } else {
    final TIntHashSet set = myInvalidated;
    if (set != null && set.size() > 0) {
      for (int inputId : set.toArray()) {
        DataInputOutputUtil.writeINT(out, -inputId); // mark inputId as invalid, to be processed on load in ValueContainerImpl.readFrom
      }
    }

    final ValueContainer<Value> toAppend = getAddedDelta();
    if (toAppend != null && toAppend.size() > 0) {
      toAppend.saveTo(out, externalizer);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ChangeTrackingValueContainer.java


示例17: versionDiffers

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
public static boolean versionDiffers(@NotNull File versionFile, final int currentIndexVersion) {
  try {
    ourLastStamp = Math.max(ourLastStamp, versionFile.lastModified());
    final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(versionFile)));
    try {
      final int savedIndexVersion = DataInputOutputUtil.readINT(in);
      final int commonVersion = DataInputOutputUtil.readINT(in);
      final long vfsCreationStamp = DataInputOutputUtil.readTIME(in);
      return savedIndexVersion != currentIndexVersion ||
             commonVersion != VERSION ||
             vfsCreationStamp != FSRecords.getCreationTimestamp()
        ;

    }
    finally {
      in.close();
    }
  }
  catch (IOException e) {
    return true;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:IndexingStamp.java


示例18: save

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
@Override
public void save(@NotNull DataOutput out, TIntArrayList list) throws IOException {
  if (list.size() == 2) {
    DataInputOutputUtil.writeINT(out, list.getQuick(0));
    DataInputOutputUtil.writeINT(out, list.getQuick(1));
  }
  else {
    DataInputOutputUtil.writeINT(out, -list.size());
    int prev = 0;
    for (int i = 0, len = list.size(); i < len; i+=2) {
      int value = list.getQuick(i);
      DataInputOutputUtil.writeINT(out, value - prev);
      prev = value;
      DataInputOutputUtil.writeINT(out, list.getQuick(i + 1));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DuplicatesIndex.java


示例19: persistAttribute

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
public void persistAttribute(@NotNull Project project, @NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException {
  final DataInputStream iStream = PERSISTENCE.readAttribute(fileOrDir);
  if (iStream != null) {
    try {
      final int oldLevelOrdinal = DataInputOutputUtil.readINT(iStream);
      if (oldLevelOrdinal == level.ordinal()) return;
    }
    finally {
      iStream.close();
    }
  }

  final DataOutputStream oStream = PERSISTENCE.writeAttribute(fileOrDir);
  DataInputOutputUtil.writeINT(oStream, level.ordinal());
  oStream.close();

  for (VirtualFile child : fileOrDir.getChildren()) {
    final FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFileName(child.getName());
    if (!child.isDirectory() && PythonFileType.INSTANCE.equals(fileType)) {
      clearSdkPathCache(child);
      PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(child);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PythonLanguageLevelPusher.java


示例20: read

import com.intellij.util.io.DataInputOutputUtil; //导入依赖的package包/类
@Nullable
@Override
public Set<MyResourceInfo> read(@NotNull DataInput in) throws IOException {
  final int size = DataInputOutputUtil.readINT(in);

  if (size < 0 || size > 65535) {
    // Something is very wrong; trigger an index rebuild
    throw new IOException("Corrupt Index: Size " + size);
  }

  if (size == 0) {
    return Collections.emptySet();
  }
  final Set<MyResourceInfo> result = Sets.newHashSetWithExpectedSize(size);

  for (int i = 0; i < size; i++) {
    final String type = IOUtil.readUTF(in);
    final String name = IOUtil.readUTF(in);
    final String context = IOUtil.readUTF(in);
    final int offset = DataInputOutputUtil.readINT(in);
    result.add(new MyResourceInfo(new ResourceEntry(type, name, context), offset));
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AndroidValueResourcesIndex.java



注:本文中的com.intellij.util.io.DataInputOutputUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ModAPIManager类代码示例发布时间:2022-05-22
下一篇:
Java HttpClientFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap