*/
OutputBuffer getLinkBuffer(final Fragment fragment,
final boolean toEnclosing) {
String linkText = null;
OutputBuffer linkBuffer = null;
FragmentInstance fragmentContext = (FragmentInstance) pageContext.
getDeviceLayoutContext().getCurrentFormatInstance(fragment);
// Check whether to use linkText or backLinkText.
if (null != fragmentContext) {
if (toEnclosing) {
linkBuffer = fragmentContext.getLinkFromBuffer();
if (linkBuffer == null) {
linkText = fragmentContext.getLinkFromText();
}
// To maintain backwards compabillity get linkToText
// if not back link text is specified.
if ((linkBuffer == null || linkBuffer.isEmpty()) &&
(linkText == null || linkText.length() == 0)) {
linkBuffer = fragmentContext.getLinkToBuffer();
if (linkBuffer == null) {
linkText = fragmentContext.getLinkToText();
}
}
} else {
linkBuffer = fragmentContext.getLinkToBuffer();
if (linkBuffer == null) {
linkText = fragmentContext.getLinkToText();
}
}
}
// Extract project to resolve policy expressions against.