/** * Return a human readable representation of this translation path, used by the logging * methods to print trace information. */ @SuppressWarnings("unchecked") @Override public String toString() { StringBuffer sb = new StringBuffer(); sb.append(getPathCost() + " "); if (sourceReference != null && initialBuilder != null) { sb.append(sourceReference.toString() + "->bytes(" + sourceReference.getResolutionCost() + ")->"); String builderClassName = initialBuilder.getClass().getSimpleName(); String builtType = initialBuilder.getReferenceType().getSimpleName(); sb.append("builder:" + builderClassName + "(" + initialBuilder.getConstructionCost() + "):<" + builtType + ">"); } else if (translators.isEmpty() == false) { sb.append("<" + translators.get(0).getSourceReferenceType().getSimpleName() + ">"); } for (ExternalReferenceTranslatorSPI translator : translators) { sb.append("-" + translator.getClass().getSimpleName() + "(" + translator.getTranslationCost() + ")" + "-"); sb.append("<" + translator.getTargetReferenceType().getSimpleName() + ">"); } return sb.toString(); }
@SuppressWarnings("unchecked") private void relaxNeighbours(Class<ExternalReferenceSPI> u) { log.trace("# relaxing node " + u.getSimpleName()); Set<Class<ExternalReferenceSPI>> alreadySeen = new HashSet<Class<ExternalReferenceSPI>>(); for (ExternalReferenceTranslatorSPI ert : getNeighbours(u)) { // all the translators that translate *to* u Class<ExternalReferenceSPI> v = ert.getSourceReferenceType(); log.trace("# translator found from from '" + v + "' : " + ert.getClass().getSimpleName()); if (alreadySeen.contains(v) == false && isSettled(v) == false) { // Avoid duplicate edges, always take the first one where // such duplicates exist alreadySeen.add(v); if (getShortestDistance(v) > getShortestDistance(u) + ert.getTranslationCost()) { setShortestDistance(v, getShortestDistance(u) + ert.getTranslationCost()); setPredecessor(v, u, ert); unsettledNodes.add(v); } } } }
@SuppressWarnings("unchecked") private void relaxNeighbours(Class<ExternalReferenceSPI> u) { log.trace("# relaxing node " + u.getSimpleName()); Set<Class<ExternalReferenceSPI>> alreadySeen = new HashSet<Class<ExternalReferenceSPI>>(); for (ExternalReferenceTranslatorSPI ert : getNeighbours(u)) { // all the translators that translate *to* u Class<ExternalReferenceSPI> v = ert.getSourceReferenceType(); log.trace("# translator found from from '" + v + "' : " + ert.getClass().getSimpleName()); if (alreadySeen.contains(v) == false && isSettled(v) == false) { // Avoid duplicate edges, always take the first one where // such duplicates exist alreadySeen.add(v); if (getShortestDistance(v) > getShortestDistance(u) + ert.getTranslationCost()) { setShortestDistance(v, getShortestDistance(u) + ert.getTranslationCost()); setPredecessor(v, u, ert); unsettledNodes.add(v); } } } }
+ translator.getTranslationCost() + ")" + "-"); sb.append("<" + translator.getTargetReferenceType().getSimpleName()
+ translator.getTranslationCost() + ")" + "-"); sb.append("<" + translator.getTargetReferenceType().getSimpleName()
/** * Sum of translation costs of all translators in path */ public float getPathCost() { float cost = 0.0f; for (ExternalReferenceTranslatorSPI<?, ?> ert : this) { cost += ert.getTranslationCost(); } // If the source reference and initial builder are non-null then // we're going to start this translation path by downloading a byte // stream from the specified (current) reference and using it to // construct the starting point for the translation path via the // specified builder. if (sourceReference != null) { cost += sourceReference.getResolutionCost(); } if (initialBuilder != null) { cost += initialBuilder.getConstructionCost(); } return cost; }
/** * Sum of translation costs of all translators in path */ public float getPathCost() { float cost = 0.0f; for (ExternalReferenceTranslatorSPI<?, ?> ert : this) { cost += ert.getTranslationCost(); } // If the source reference and initial builder are non-null then // we're going to start this translation path by downloading a byte // stream from the specified (current) reference and using it to // construct the starting point for the translation path via the // specified builder. if (sourceReference != null) { cost += sourceReference.getResolutionCost(); } if (initialBuilder != null) { cost += initialBuilder.getConstructionCost(); } return cost; }
/** * Sum of translation costs of all translators in path */ public float getPathCost() { float cost = 0.0f; for (ExternalReferenceTranslatorSPI<?, ?> ert : this) { cost += ert.getTranslationCost(); } // If the source reference and initial builder are non-null then // we're going to start this translation path by downloading a byte // stream from the specified (current) reference and using it to // construct the starting point for the translation path via the // specified builder. if (sourceReference != null) { cost += sourceReference.getResolutionCost(); } if (initialBuilder != null) { cost += initialBuilder.getConstructionCost(); } return cost; }
@SuppressWarnings("unchecked") private void relaxNeighbours(Class<ExternalReferenceSPI> u) { log.trace("# relaxing node " + u.getSimpleName()); Set<Class<ExternalReferenceSPI>> alreadySeen = new HashSet<Class<ExternalReferenceSPI>>(); for (ExternalReferenceTranslatorSPI ert : getNeighbours(u)) { // all the translators that translate *to* u Class<ExternalReferenceSPI> v = ert.getSourceReferenceType(); log.trace("# translator found from from '" + v + "' : " + ert.getClass().getSimpleName()); if (alreadySeen.contains(v) == false && isSettled(v) == false) { // Avoid duplicate edges, always take the first one where // such duplicates exist alreadySeen.add(v); if (getShortestDistance(v) > getShortestDistance(u) + ert.getTranslationCost()) { setShortestDistance(v, getShortestDistance(u) + ert.getTranslationCost()); setPredecessor(v, u, ert); unsettledNodes.add(v); } } } }