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

项目:intellij-ce-playground    文件:EnumeratedMethodIncompleteSignature.java   
public static DataExternalizer<EnumeratedMethodIncompleteSignature> createDataExternalizer() {
  return new DataExternalizer<EnumeratedMethodIncompleteSignature>() {
    @Override
    public void save(@NotNull final DataOutput out, final EnumeratedMethodIncompleteSignature value) throws IOException {
      out.writeInt(value.getOwner());
      out.writeInt(value.getName());
      out.writeBoolean(value.isStatic());
    }

    @Override
    public EnumeratedMethodIncompleteSignature read(@NotNull final DataInput in) throws IOException {
      return new EnumeratedMethodIncompleteSignature(in.readInt(),
                                                     in.readInt(),
                                                     in.readBoolean());
    }
  };
}
项目:intellij-ce-playground    文件:ObjectObjectPersistentMultiMaplet.java   
public ObjectObjectPersistentMultiMaplet(final File file,
                                      final KeyDescriptor<K> keyExternalizer,
                                      final DataExternalizer<V> valueExternalizer,
                                      final CollectionFactory<V> collectionFactory) throws IOException {
  myValueExternalizer = valueExternalizer;
  myMap = new PersistentHashMap<K, Collection<V>>(file, keyExternalizer, new CollectionDataExternalizer<V>(valueExternalizer, collectionFactory));
  myCache = new SLRUCache<K, Collection>(CACHE_SIZE, CACHE_SIZE, keyExternalizer) {
    @NotNull
    @Override
    public Collection createValue(K key) {
      try {
        final Collection<V> collection = myMap.get(key);
        return collection == null? NULL_COLLECTION : collection;
      }
      catch (IOException e) {
        throw new BuildDataCorruptedException(e);
      }
    }
  };
}
项目:intellij-ce-playground    文件:IntObjectPersistentMultiMaplet.java   
public IntObjectPersistentMultiMaplet(final File file,
                                      final KeyDescriptor<Integer> keyExternalizer,
                                      final DataExternalizer<V> valueExternalizer,
                                      final CollectionFactory<V> collectionFactory) throws IOException {
  myValueExternalizer = valueExternalizer;
  myMap = new PersistentHashMap<Integer, Collection<V>>(file, keyExternalizer, new CollectionDataExternalizer<V>(valueExternalizer, collectionFactory));
  myCache = new SLRUCache<Integer, Collection>(CACHE_SIZE, CACHE_SIZE) {
    @NotNull
    @Override
    public Collection createValue(Integer key) {
      try {
        final Collection<V> collection = myMap.get(key);
        return collection == null? NULL_COLLECTION : collection;
      }
      catch (IOException e) {
        throw new BuildDataCorruptedException(e);
      }
    }
  };
}
项目:intellij-ce-playground    文件:TestStateStorage.java   
@NotNull
private static ThrowableComputable<PersistentHashMap<String, Record>, IOException> getComputable(final File file) {
  return new ThrowableComputable<PersistentHashMap<String, Record>, IOException>() {
    @Override
    public PersistentHashMap<String, Record> compute() throws IOException {
      return new PersistentHashMap<String, Record>(file, new EnumeratorStringDescriptor(), new DataExternalizer<Record>() {
        @Override
        public void save(@NotNull DataOutput out, Record value) throws IOException {
          out.writeInt(value.magnitude);
          out.writeLong(value.date.getTime());
        }

        @Override
        public Record read(@NotNull DataInput in) throws IOException {
          return new Record(in.readInt(), new Date(in.readLong()));
        }
      });
    }
  };
}
项目:intellij-ce-playground    文件:ChangeTrackingValueContainer.java   
@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);
    }
  }
}
项目:intellij-ce-playground    文件:XmlNamespaceIndex.java   
@NotNull
@Override
public DataExternalizer<XsdNamespaceBuilder> getValueExternalizer() {
  return new DataExternalizer<XsdNamespaceBuilder>() {
    @Override
    public void save(@NotNull DataOutput out, XsdNamespaceBuilder value) throws IOException {
      IOUtil.writeUTF(out, value.getNamespace() == null ? "" : value.getNamespace());
      IOUtil.writeUTF(out, value.getVersion() == null ? "" : value.getVersion());
      writeList(out, value.getTags());
      writeList(out, value.getRootTags());
    }

    @Override
    public XsdNamespaceBuilder read(@NotNull DataInput in) throws IOException {

      return new XsdNamespaceBuilder(IOUtil.readUTF(in),
                                     IOUtil.readUTF(in),
                                     readList(in),
                                     readList(in));
    }
  };
}
项目:CMaker    文件:CMakeFileIndexExtension.java   
@NotNull
@Override
public DataExternalizer<CMakeCommandExpr> getValueExternalizer() {
    return new DataExternalizer<CMakeCommandExpr>() {
        @Override
        public void save(@NotNull DataOutput dataOutput, CMakeCommandExpr cMakeCommandExpr) throws IOException {
            dataOutput.writeChars(cMakeCommandExpr.getText());
        }

        @Override
        public CMakeCommandExpr read(@NotNull DataInput dataInput) throws IOException {
            // Create new file from string content and return first file element
            // TODO:
            String name = "test.dummy.cmake";
            CMakeFile tmp = (CMakeFile) PsiFileFactory.getInstance(null).
                    createFileFromText(name, CMakeFileType.INSTANCE, dataInput.readLine());
            return (CMakeCommandExpr) tmp.getFirstChild().getFirstChild().getFirstChild();
        }
    };
}
项目:tools-idea    文件:ObjectObjectPersistentMultiMaplet.java   
public ObjectObjectPersistentMultiMaplet(final File file,
                                      final KeyDescriptor<K> keyExternalizer,
                                      final DataExternalizer<V> valueExternalizer,
                                      final CollectionFactory<V> collectionFactory) throws IOException {
  myValueExternalizer = valueExternalizer;
  myMap = new PersistentHashMap<K, Collection<V>>(file, keyExternalizer, new CollectionDataExternalizer<V>(valueExternalizer, collectionFactory));
  myCache = new SLRUCache<K, Collection>(CACHE_SIZE, CACHE_SIZE) {
    @NotNull
    @Override
    public Collection createValue(K key) {
      try {
        final Collection<V> collection = myMap.get(key);
        return collection == null? NULL_COLLECTION : collection;
      }
      catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  };
}
项目:tools-idea    文件:IntObjectPersistentMaplet.java   
public IntObjectPersistentMaplet(final File file, final DataExternalizer<V> externalizer) {
  try {
    myMap = new PersistentHashMap<Integer, V>(file, new IntInlineKeyDescriptor(), externalizer);
    myCache = new SLRUCache<Integer, Object>(CACHE_SIZE, CACHE_SIZE) {
      @NotNull
      @Override
      public Object createValue(Integer key) {
        try {
          final V v1 = myMap.get(key);
          return v1 == null? NULL_OBJ : v1;
        }
        catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
    };
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
项目:tools-idea    文件:IntObjectPersistentMultiMaplet.java   
public IntObjectPersistentMultiMaplet(final File file,
                                      final KeyDescriptor<Integer> keyExternalizer,
                                      final DataExternalizer<V> valueExternalizer,
                                      final CollectionFactory<V> collectionFactory) throws IOException {
  myValueExternalizer = valueExternalizer;
  myMap = new PersistentHashMap<Integer, Collection<V>>(file, keyExternalizer, new CollectionDataExternalizer<V>(valueExternalizer, collectionFactory));
  myCache = new SLRUCache<Integer, Collection>(CACHE_SIZE, CACHE_SIZE) {
    @NotNull
    @Override
    public Collection createValue(Integer key) {
      try {
        final Collection<V> collection = myMap.get(key);
        return collection == null? NULL_COLLECTION : collection;
      }
      catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  };
}
项目:tools-idea    文件:TypeRepr.java   
ClassType(final DependencyContext context, final DataInput in) {
  try {
    className = in.readInt();
    final int size = in.readInt();
    if (size == 0) {
      typeArgs = EMPTY_TYPE_ARRAY;
    }
    else {
      typeArgs = new AbstractType[size];
      final DataExternalizer<AbstractType> externalizer = externalizer(context);
      for (int i = 0; i < size; i++) {
        typeArgs[i] = externalizer.read(in);
      }
    }
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
项目:tools-idea    文件:MethodShortSignature.java   
public static DataExternalizer<MethodShortSignature> createDataExternalizer() {
  final EnumeratorStringDescriptor stringDescriptor = new EnumeratorStringDescriptor();
  return new DataExternalizer<MethodShortSignature>() {

    @Override
    public void save(final DataOutput out, final MethodShortSignature value) throws IOException {
      stringDescriptor.save(out, value.getName());
      stringDescriptor.save(out, value.getSignature());
    }

    @Override
    public MethodShortSignature read(final DataInput in) throws IOException {
      return new MethodShortSignature(stringDescriptor.read(in), stringDescriptor.read(in));
    }
  };
}
项目:tools-idea    文件:XmlNamespaceIndex.java   
@Override
public DataExternalizer<XsdNamespaceBuilder> getValueExternalizer() {
  return new DataExternalizer<XsdNamespaceBuilder>() {
    @Override
    public void save(DataOutput out, XsdNamespaceBuilder value) throws IOException {
      out.writeUTF(value.getNamespace() == null ? "" : value.getNamespace());
      out.writeUTF(value.getVersion() == null ? "" : value.getVersion());
      out.writeInt(value.getTags().size());
      for (String s : value.getTags()) {
        out.writeUTF(s);
      }
    }

    @Override
    public XsdNamespaceBuilder read(DataInput in) throws IOException {

      int count;
      XsdNamespaceBuilder builder = new XsdNamespaceBuilder(in.readUTF(), in.readUTF(), new ArrayList<String>(count = in.readInt()));
      for (int i = 0; i < count; i++) {
        builder.getTags().add(in.readUTF());
      }
      return builder;
    }
  };
}
项目:consulo    文件:VcsLogFullDetailsIndex.java   
public VcsLogFullDetailsIndex(@Nonnull String logId,
                              @Nonnull String name,
                              final int version,
                              @Nonnull DataIndexer<Integer, T, VcsFullCommitDetails> indexer,
                              @Nonnull DataExternalizer<T> externalizer,
                              @Nonnull FatalErrorHandler fatalErrorHandler,
                              @Nonnull Disposable disposableParent)
        throws IOException {
  myID = ID.create(name);
  myName = name;
  myLogId = logId;
  myIndexer = indexer;
  myFatalErrorHandler = fatalErrorHandler;

  myMapReduceIndex = new MyMapReduceIndex(myIndexer, externalizer, version);

  Disposer.register(disposableParent, this);
}
项目:consulo    文件:ChangeTrackingValueContainer.java   
@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 UpdatableValueContainer<Value> toAppend = getAddedDelta();
    if (toAppend != null && toAppend.size() > 0) {
      toAppend.saveTo(out, externalizer);
    }
  }
}
项目:consulo    文件:TestStateStorage.java   
@Nonnull
private static ThrowableComputable<PersistentHashMap<String, Record>, IOException> getComputable(final File file) {
  return () -> new PersistentHashMap<>(file, EnumeratorStringDescriptor.INSTANCE, new DataExternalizer<Record>() {
    @Override
    public void save(@Nonnull DataOutput out, Record value) throws IOException {
      out.writeInt(value.magnitude);
      out.writeLong(value.date.getTime());
      out.writeLong(value.configurationHash);
    }

    @Override
    public Record read(@Nonnull DataInput in) throws IOException {
      return new Record(in.readInt(), new Date(in.readLong()), in.readLong());
    }
  }, 4096, CURRENT_VERSION);
}
项目:intellij-ce-playground    文件:ClassFilesIndexStorageBase.java   
public ClassFilesIndexStorageBase(final File indexDir, final KeyDescriptor<K> keyDescriptor, final DataExternalizer<V> valueExternalizer)
  throws IOException {
  myIndexFile = getIndexFile(indexDir);
  myKeyDescriptor = keyDescriptor;
  myValueExternalizer = valueExternalizer;
  initialize();
}
项目:intellij-ce-playground    文件:ClassFilesIndexStorageWriter.java   
public ClassFilesIndexStorageWriter(final File indexDir,
                                    final KeyDescriptor<K> keyDescriptor,
                                    final DataExternalizer<V> valueExternalizer,
                                    final Mappings mappings) throws IOException {
  super(indexDir, keyDescriptor, valueExternalizer);
  myMappings = mappings;
}
项目:intellij-ce-playground    文件:RW.java   
public static <X> void save(final Collection<X> x, final DataExternalizer<X> e, final DataOutput out) {
  try {
    DataInputOutputUtil.writeINT(out, x.size());

    for (X y : x) {
      e.save(out, y);
    }
  }
  catch (IOException c) {
    throw new BuildDataCorruptedException(c);
  }
}
项目:intellij-ce-playground    文件:RW.java   
public static <X> X[] read(final DataExternalizer<X> e, final DataInput in, final X[] result) {
  try {
    for (int i = 0; i < result.length; i++) {
      result[i] = e.read(in);
    }

    return result;
  }
  catch (IOException x) {
    throw new BuildDataCorruptedException(x);
  }
}
项目:intellij-ce-playground    文件:RW.java   
public static <X> Collection<X> read(final DataExternalizer<X> e, final Collection<X> acc, final DataInput in) {
  try {
    final int size = DataInputOutputUtil.readINT(in);

    for (int i = 0; i<size; i++) {
      acc.add(e.read(in));
    }

    return acc;
  }
  catch (IOException x) {
    throw new BuildDataCorruptedException(x);
  }
}
项目:intellij-ce-playground    文件:FieldRepr.java   
public static DataExternalizer<FieldRepr> externalizer(final DependencyContext context) {
  return new DataExternalizer<FieldRepr>() {
    @Override
    public void save(@NotNull final DataOutput out, final FieldRepr value) throws IOException {
      value.save(out);
    }

    @Override
    public FieldRepr read(@NotNull final DataInput in) throws IOException {
      return new FieldRepr(context, in);
    }
  };
}
项目:intellij-ce-playground    文件:MethodRepr.java   
public MethodRepr(final DependencyContext context, final DataInput in) {
  super(context, in);
  try {
    final DataExternalizer<TypeRepr.AbstractType> externalizer = TypeRepr.externalizer(context);
    final int size = DataInputOutputUtil.readINT(in);
    myArgumentTypes = RW.read(externalizer, in, new TypeRepr.AbstractType[size]);
    myExceptions = (Set<TypeRepr.AbstractType>)RW.read(externalizer, new THashSet<TypeRepr.AbstractType>(0), in);
  }
  catch (IOException e) {
    throw new BuildDataCorruptedException(e);
  }
}
项目:intellij-ce-playground    文件:MethodRepr.java   
public static DataExternalizer<MethodRepr> externalizer(final DependencyContext context) {
  return new DataExternalizer<MethodRepr>() {
    @Override
    public void save(@NotNull final DataOutput out, final MethodRepr value) throws IOException {
      value.save(out);
    }

    @Override
    public MethodRepr read(@NotNull DataInput in) throws IOException {
      return new MethodRepr(context, in);
    }
  };
}
项目:intellij-ce-playground    文件:ClassRepr.java   
public static DataExternalizer<ClassRepr> externalizer(final DependencyContext context) {
  return new DataExternalizer<ClassRepr>() {
    @Override
    public void save(@NotNull final DataOutput out, final ClassRepr value) throws IOException {
      value.save(out);
    }

    @Override
    public ClassRepr read(@NotNull final DataInput in) throws IOException {
      return new ClassRepr(context, in);
    }
  };
}
项目:intellij-ce-playground    文件:UsageRepr.java   
private MethodUsage(final DependencyContext context, final DataInput in) {
  super(in);
  try {
    final DataExternalizer<TypeRepr.AbstractType> externalizer = TypeRepr.externalizer(context);
    int argumentTypes = DataInputOutputUtil.readINT(in);
    myArgumentTypes = RW.read(externalizer, in, argumentTypes != 0 ? new TypeRepr.AbstractType[argumentTypes]: TypeRepr.AbstractType.EMPTY_TYPE_ARRAY);
    myReturnType = externalizer.read(in);
  }
  catch (IOException e) {
    throw new BuildDataCorruptedException(e);
  }
}
项目:intellij-ce-playground    文件:UsageRepr.java   
private AnnotationUsage(final DependencyContext context, final DataInput in) {
  final DataExternalizer<TypeRepr.AbstractType> externalizer = TypeRepr.externalizer(context);

  try {
    myType = (TypeRepr.ClassType)externalizer.read(in);
    myUsedArguments = RW.read(new TIntHashSet(DEFAULT_SET_CAPACITY, DEFAULT_SET_LOAD_FACTOR), in);
    myUsedTargets = (EnumSet<ElemType>)RW.read(elementTypeExternalizer, EnumSet.noneOf(ElemType.class), in);
  }
  catch (IOException e) {
    throw new BuildDataCorruptedException(e);
  }
}
项目:intellij-ce-playground    文件:RefQueueIndex.java   
@NotNull
@Override
public DataExternalizer<Void> getValueExternalizer() {
  return new DataExternalizer<Void>() {
    @Override
    public void save(@NotNull DataOutput out, Void value) {

    }

    @Override
    public Void read(@NotNull DataInput in) {
      return null;
    }
  };
}
项目:intellij-ce-playground    文件:StateCache.java   
private PersistentHashMap<String, T> createMap(final File file) throws IOException {
  return new PersistentHashMap<String,T>(file, new EnumeratorStringDescriptor(), new DataExternalizer<T>() {
    public void save(@NotNull final DataOutput out, final T value) throws IOException {
      StateCache.this.write(value, out);
    }

    public T read(@NotNull final DataInput in) throws IOException {
      return StateCache.this.read(in);
    }
  });
}
项目:intellij-ce-playground    文件:SmallMapSerializer.java   
public SmallMapSerializer(final File file, final KeyDescriptor<K> keyDescriptor, final DataExternalizer<V> valueExternalizer) {
  myFile = file;
  myKeyDescriptor = keyDescriptor;
  myValueExternalizer = valueExternalizer;
  myMap = new HashMap<KeyWrapper<K>, V>();
  init();
}
项目:intellij-ce-playground    文件:ValueContainerMap.java   
ValueContainerMap(@NotNull final File file,
                  @NotNull KeyDescriptor<Key> keyKeyDescriptor,
                  @NotNull DataExternalizer<Value> valueExternalizer,
                  boolean keyIsUniqueForIndexedFile
                  ) throws IOException {
  super(file, keyKeyDescriptor, new ValueContainerExternalizer<Value>(valueExternalizer));
  myValueExternalizer = valueExternalizer;
  myKeyIsUniqueForIndexedFile = keyIsUniqueForIndexedFile;
}
项目:tools-idea    文件:RW.java   
public static <X> void save(final Collection<X> x, final DataExternalizer<X> e, final DataOutput out) {
  try {
    out.writeInt(x.size());

    for (X y : x) {
      e.save(out, y);
    }
  }
  catch (IOException c) {
    throw new RuntimeException(c);
  }
}
项目:tools-idea    文件:RW.java   
public static <X> X[] read(final DataExternalizer<X> e, final DataInput in, final X[] result) {
  try {
    for (int i = 0; i < result.length; i++) {
      result[i] = e.read(in);
    }

    return result;
  }
  catch (IOException x) {
    throw new RuntimeException(x);
  }
}
项目:tools-idea    文件:RW.java   
public static <X> Collection<X> read(final DataExternalizer<X> e, final Collection<X> acc, final DataInput in) {
  try {
    final int size = in.readInt();

    for (int i = 0; i<size; i++) {
      acc.add(e.read(in));
    }

    return acc;
  }
  catch (IOException x) {
    throw new RuntimeException(x);
  }
}
项目:tools-idea    文件:FieldRepr.java   
public static DataExternalizer<FieldRepr> externalizer(final DependencyContext context) {
  return new DataExternalizer<FieldRepr>() {
    @Override
    public void save(final DataOutput out, final FieldRepr value) throws IOException {
      value.save(out);
    }

    @Override
    public FieldRepr read(final DataInput in) throws IOException {
      return new FieldRepr(context, in);
    }
  };
}
项目:tools-idea    文件:MethodRepr.java   
public MethodRepr(final DependencyContext context, final DataInput in) {
  super(context, in);
  try {
    final DataExternalizer<TypeRepr.AbstractType> externalizer = TypeRepr.externalizer(context);
    final int size = in.readInt();
    myArgumentTypes = RW.read(externalizer, in, new TypeRepr.AbstractType[size]);
    myExceptions = (Set<TypeRepr.AbstractType>)RW.read(externalizer, new HashSet<TypeRepr.AbstractType>(), in);
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
项目:tools-idea    文件:MethodRepr.java   
public static DataExternalizer<MethodRepr> externalizer(final DependencyContext context) {
  return new DataExternalizer<MethodRepr>() {
    @Override
    public void save(final DataOutput out, final MethodRepr value) throws IOException {
      value.save(out);
    }

    @Override
    public MethodRepr read(DataInput in) throws IOException {
      return new MethodRepr(context, in);
    }
  };
}
项目:tools-idea    文件:ClassRepr.java   
public static DataExternalizer<ClassRepr> externalizer(final DependencyContext context) {
  return new DataExternalizer<ClassRepr>() {
    @Override
    public void save(final DataOutput out, final ClassRepr value) throws IOException {
      value.save(out);
    }

    @Override
    public ClassRepr read(final DataInput in) throws IOException {
      return new ClassRepr(context, in);
    }
  };
}
项目:tools-idea    文件:IntIntPersistentMaplet.java   
public IntIntPersistentMaplet(final File file, final KeyDescriptor<Integer> k) {
  try {
    myMap = new PersistentHashMap<Integer, Integer>(file, k, new DataExternalizer<Integer>() {
      @Override
      public void save(DataOutput out, Integer value) throws IOException {
        out.writeInt(value);
      }

      @Override
      public Integer read(DataInput in) throws IOException {
        return in.readInt();
      }
    });
    myCache = new SLRUCache<Integer, Object>(CACHE_SIZE, CACHE_SIZE) {
      @NotNull
      @Override
      public Object createValue(Integer key) {
        try {
          final Integer v1 = myMap.get(key);
          return v1 == null? NULL_OBJ : v1;
        }
        catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
    };
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
项目:tools-idea    文件:UsageRepr.java   
private MethodUsage(final DependencyContext context, final DataInput in) {
  super(in);
  try {
    final DataExternalizer<TypeRepr.AbstractType> externalizer = TypeRepr.externalizer(context);
    myArgumentTypes = RW.read(externalizer, in, new TypeRepr.AbstractType[in.readInt()]);
    myReturnType = externalizer.read(in);
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}