// Only write the links if we have been asked to.
if (!fragment.getPeerLinks()) {
return;
}
FragmentLinkWriter fragmentLinkWriter =
context.getFragmentLinkWriter();
// Walk through the children of the parent (our peers)
Format parent = fragment.getParent();
if (parent != null) {
int numChildren = parent.getNumChildren();
if (logger.isDebugEnabled()) {
logger.debug("Searching " + numChildren + " peers");
}
for (int child = 0; child < numChildren; child++) {
// Check if the peer is a fragment
Format peer = parent.getChildAt(child);
if (logger.isDebugEnabled()) {
logger.debug("Found peer " + peer);
}
if ((peer != null)
&& peer.getFormatType().equals(FormatType.FRAGMENT)) {
Fragment peerFragment = (Fragment) peer;
// Dont write to ourselves
if (!peerFragment.getName().equals(fragment.getName())) {
if (logger.isDebugEnabled()) {
logger.debug("Adding link to peer fragment"
+ peerFragment.getName());
}
fragmentLinkWriter.writeFragmentLink(
context, fragment, peerFragment, true, false);
}
}
}
}