예제 #1
0
 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
   try {
     repositoryName = RepositoryName.create((String) in.readObject());
   } catch (LabelSyntaxException e) {
     throw new IOException("Error serializing repository name: " + e.getMessage());
   }
 }
예제 #2
0
 /**
  * Extracts the repository name from a PathFragment that was created with {@code
  * PackageIdentifier.getPathFragment}.
  *
  * @return a {@code Pair} of the extracted repository name and the path fragment with stripped of
  *     "external/"-prefix and repository name, or null if none was found or the repository name
  *     was invalid.
  */
 public static Pair<RepositoryName, PathFragment> fromPathFragment(PathFragment path) {
   if (path.segmentCount() < 2 || !path.getSegment(0).equals(Label.EXTERNAL_PATH_PREFIX)) {
     return null;
   }
   try {
     RepositoryName repoName = RepositoryName.create("@" + path.getSegment(1));
     PathFragment subPath = path.subFragment(2, path.segmentCount());
     return Pair.of(repoName, subPath);
   } catch (LabelSyntaxException e) {
     return null;
   }
 }
예제 #3
0
 private void writeObject(ObjectOutputStream out) throws IOException {
   out.writeObject(repositoryName.toString());
 }