当前位置: 首页>>代码示例>>Java>>正文


Java DataInputOutputUtil类代码示例

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


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


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