OK, I think I may have missed a step here. Right now, I have:
1) A file stream with the top level message descriptor - fds
2) A hash map with all the dependency descriptors - fdl
final FileDescriptorSet fds = FileDescriptorSet.parseFrom(new
FileInputStream(myFile)); // load the file however you feel
appropriate - but close your streams : )
// special note - if you have custom options, you will
need to create an ExtensionRegistry with them and use it while
parsing
the FileDescriptorSet
try {
Map<String, FileDescriptor> fdl = new HashMap<String,
FileDescriptor>();
FileDescriptor current = null;
for (FileDescriptorProto fdp : fds.getFileList()) {
final List<String> dependencyList =
fdp.getDependencyList();
final FileDescriptor[] fda = new
FileDescriptor[dependencyList
.size()];
for (int i = 0; i < fda.length; i++) {
FileDescriptor fddd =
fdl.get(dependencyList.get(i));
if (fddd == null) {
// missing imports! - this should not happen
unless you left off the --include_imports directive
} else {
fda[i] = fddd;
}
}
current = FileDescriptor.buildFrom(fdp, fda);
fdl.put(current.getName(), current);
}
// the "fdl" object now has all the descriptors - grab
the
one you need.
} catch (DescriptorValidationException e) {
// panic ?
}
How do I link of glue them all together? Do I loop through fdl and
somehow add links in fds?
Thanks again,
Dale