// get the start- and endvertices from the graph. We could run into problems if
// formats with the same extension exists that have different lossy/lossless
// settings. Since I don't know such a format we simply take the first matching
// vertex.
Vertex startVertex = null;
for (Edge edge : edges) {
if (edge.getSourceVertex().getFormat().equalsIgnoreCase(sourceFormat)) {
startVertex = edge.getSourceVertex();
break;
}
}
if (startVertex == null) {
return null;
}
Vertex targetVertex = null;
for (Edge edge : edges) {
if (edge.getTargetVertex().getFormat().equalsIgnoreCase(targetFormat)) {
targetVertex = edge.getTargetVertex();
break;
}
}
if (targetVertex == null) {
return null;
}
runDijkstra(startVertex);
ret = new ArrayList<ConversionStep>();
Vertex predecessor = null;
Vertex activeVertex = targetVertex;
while ((predecessor = activeVertex.getPredecessor()) != null) {
Edge edge = findEdge(predecessor, activeVertex);
ret.add(0, new ConversionStep(activeVertex.getFormat(), edge.getConversionExtension()));
activeVertex = predecessor;
}
// add to cache
cache.add(sourceFormat, targetFormat, ret);