/** Returns the encoded URL for the dynamic generated content, or empty
* the component doesn't belong to any desktop.
*/
private static String getDynamicMediaURI(AbstractComponent comp,
int version, String name, String format) {
final Desktop desktop = comp.getDesktop();
if (desktop == null) return ""; //no avail at client
final StringBuffer sb = new StringBuffer(64).append('/');
Strings.encode(sb, version);
if (name != null || format != null) {
sb.append('/');
boolean bExtRequired = true;
if (name != null && name.length() != 0) {
sb.append(name.replace('\\', '/'));
bExtRequired = name.lastIndexOf('.') < 0;
} else {
sb.append(comp.getId());
}
if (bExtRequired && format != null)
sb.append('.').append(format);
}
return desktop.getDynamicMediaURI(comp, sb.toString()); //already encoded
}