Package com.jetbrains.lang.dart.ide.index

Source Code of com.jetbrains.lang.dart.ide.index.DartComponentInfoExternalizer

package com.jetbrains.lang.dart.ide.index;

import com.intellij.util.io.DataExternalizer;
import com.jetbrains.lang.dart.DartComponentType;
import org.jetbrains.annotations.NotNull;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
* @author: Fedor.Korotkov
*/
public class DartComponentInfoExternalizer implements DataExternalizer<DartComponentInfo> {
  @Override
  public void save(@NotNull DataOutput out, DartComponentInfo componentInfo) throws IOException {
    out.writeUTF(componentInfo.getValue());
    final DartComponentType dartComponentType = componentInfo.getType();
    final int key = dartComponentType == null ? -1 : dartComponentType.getKey();
    out.writeInt(key);
    final String libraryId = componentInfo.getLibraryId();
    out.writeBoolean(libraryId != null);
    if (libraryId != null) {
      out.writeUTF(libraryId);
    }
  }

  @Override
  public DartComponentInfo read(@NotNull DataInput in) throws IOException {
    final String value = in.readUTF();
    final int key = in.readInt();
    final boolean haveLibraryId = in.readBoolean();
    final String libraryId = haveLibraryId ? in.readUTF() : null;
    return new DartComponentInfo(value, DartComponentType.valueOf(key), libraryId);
  }
}
TOP

Related Classes of com.jetbrains.lang.dart.ide.index.DartComponentInfoExternalizer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.