com.squareup.wire.schema.Location.base()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中com.squareup.wire.schema.Location.base()方法的一些代码示例,展示了Location.base()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Location.base()方法的具体详情如下:
包路径:com.squareup.wire.schema.Location
类名称:Location
方法名:base

Location.base介绍

[英]Returns the base of this location; typically a directory or .jar file.
[中]返回此位置的基;通常是一个目录或目录。jar文件。

代码示例

代码示例来源:origin: square/wire

/**
 * Computes all possible {@code .wire} profile files for the {@code .proto} at {@code location}
 * and adds them to {@code result}.
 */
void pathsToAttempt(Multimap<Path, String> sink, Location location) {
 Path base = fileSystem.getPath(location.base());
 String path = location.path();
 while (!path.isEmpty()) {
  String parent = path.substring(0, path.lastIndexOf('/', path.length() - 2) + 1);
  String profilePath = parent + name + ".wire";
  sink.put(base, profilePath);
  path = parent;
 }
}

代码示例来源:origin: square/wire

@Override public String toString() {
  StringBuilder result = new StringBuilder();
  if (!base().isEmpty()) {
   result.append(base()).append(File.separator);
  }
  result.append(path());
  if (line() != -1) {
   result.append(" at ").append(line());
   if (column() != -1) {
    result.append(':').append(column());
   }
  }
  return result.toString();
 }
}

代码示例来源:origin: square/wire

public Location at(int line, int column) {
 return new AutoValue_Location(base(), path(), line, column);
}

代码示例来源:origin: square/wire

@Test public void locateInZipFile() throws IOException {
 Files.createDirectories(fileSystem.getPath("/source"));
 Path zip = fileSystem.getPath("/source/protos.zip");
 ZipOutputStream zipOutputStream = new ZipOutputStream(Files.newOutputStream(zip));
 zipOutputStream.putNextEntry(new ZipEntry("a/b/message.proto"));
 zipOutputStream.write("message Message {}".getBytes(UTF_8));
 zipOutputStream.close();
 Schema schema = new SchemaLoader()
   .addSource(zip)
   .addProto("a/b/message.proto")
   .load();
 Type message = schema.getType("Message");
 assertThat(message).isNotNull();
 assertThat(message.location().base()).isEqualTo("/source/protos.zip");
 assertThat(message.location().path()).isEqualTo("a/b/message.proto");
}

代码示例来源:origin: square/wire

@Test public void loadAllFilesWhenNoneSpecified() throws IOException {
 Files.createDirectories(fileSystem.getPath("/source"));
 writeFile("/source/message1.proto", "message Message1 {}");
 writeFile("/source/message2.proto", "message Message2 {}");
 writeFile("/source/readme.txt", "Here be protos!");
 Schema schema = new SchemaLoader()
   .addSource(fileSystem.getPath("/source"))
   .load();
 Type message1 = schema.getType("Message1");
 assertThat(message1).isNotNull();
 assertThat(message1.location().base()).isEqualTo("/source");
 assertThat(message1.location().path()).isEqualTo("message1.proto");
 Type message2 = schema.getType("Message2");
 assertThat(message2).isNotNull();
 assertThat(message2.location().base()).isEqualTo("/source");
 assertThat(message2.location().path()).isEqualTo("message2.proto");
}

代码示例来源:origin: ppdai-incubator/raptor

/**
 * Computes all possible {@code .wire} profile files for the {@code .proto} at {@code location}
 * and adds them to {@code result}.
 */
void pathsToAttempt(Multimap<Path, String> sink, Location location) {
 Path base = fileSystem.getPath(location.base());
 String path = location.path();
 while (!path.isEmpty()) {
  String parent = path.substring(0, path.lastIndexOf('/', path.length() - 2) + 1);
  String profilePath = parent + name + ".wire";
  sink.put(base, profilePath);
  path = parent;
 }
}

代码示例来源:origin: com.squareup.wire/wire-schema

@Override public String toString() {
  StringBuilder result = new StringBuilder();
  if (!base().isEmpty()) {
   result.append(base()).append(File.separator);
  }
  result.append(path());
  if (line() != -1) {
   result.append(" at ").append(line());
   if (column() != -1) {
    result.append(':').append(column());
   }
  }
  return result.toString();
 }
}

代码示例来源:origin: ppdai-incubator/raptor

@Override public String toString() {
  StringBuilder result = new StringBuilder();
  if (!base().isEmpty()) {
   result.append(base()).append(File.separator);
  }
  result.append(path());
  if (line() != -1) {
   result.append(" at ").append(line());
   if (column() != -1) {
    result.append(':').append(column());
   }
  }
  return result.toString();
 }
}

代码示例来源:origin: ppdai-incubator/raptor

@Override
public boolean equals(Object o) {
 if (o == this) {
  return true;
 }
 if (o instanceof Location) {
  Location that = (Location) o;
  return (this.base.equals(that.base()))
     && (this.path.equals(that.path()))
     && (this.line == that.line())
     && (this.column == that.column());
 }
 return false;
}

代码示例来源:origin: ppdai-incubator/raptor

public Location at(int line, int column) {
 return new AutoValue_Location(base(), path(), line, column);
}

代码示例来源:origin: com.squareup.wire/wire-schema

public Location at(int line, int column) {
 return new AutoValue_Location(base(), path(), line, column);
}

相关文章