if(widgetInstance==null) return map;
// Get i18n-enabled metadata for the Widget's locale and encode it using unicode control characters.
String locales[] = {widgetInstance.getLang()};
IWidget widget = widgetInstance.getWidget();
String author = "";
String email = "";
String href = "";
if (widget.getAuthor() != null){
if (widget.getAuthor().getAuthorName() != null) author = WidgetFormattingUtils.getEncoded(widget.getAuthor().getDir(), widget.getAuthor().getAuthorName());
if (widget.getAuthor().getEmail() != null) email = widget.getAuthor().getEmail();
if (widget.getAuthor().getHref() != null) href = widget.getAuthor().getHref();
}
String name = "";
IName iname = (IName)LocalizationUtils.getLocalizedElement(widget.getNames().toArray(new IName[widget.getNames().size()]), locales, widget.getDefaultLocale());
if (iname != null && iname.getName() != null) name = WidgetFormattingUtils.getEncoded(iname.getDir(), iname.getName());
String shortName = "";
if (iname != null && iname.getShort() != null) shortName = WidgetFormattingUtils.getEncoded(iname.getDir(), iname.getShort());
String description = "";
IDescription idescription = (IDescription)LocalizationUtils.getLocalizedElement(widget.getDescriptions().toArray(new IDescription[widget.getDescriptions().size()]), locales, widget.getDefaultLocale());
if (idescription != null && idescription.getDescription() != null) description = WidgetFormattingUtils.getEncoded(idescription.getDir(), idescription.getDescription());
String version = "";
if (widget.getVersion() != null) version = WidgetFormattingUtils.getEncoded(widget.getDir(), widget.getVersion());
String width = "0";
if (widget.getWidth() != null) width = String.valueOf(widget.getWidth());
String height = "0";
if (widget.getHeight() != null) height = String.valueOf(widget.getHeight());
// Add in metadata
map.put("id", String.valueOf(widget.getIdentifier())); //$NON-NLS-1$
map.put("author", author); //$NON-NLS-1$
map.put("authorEmail", email);//$NON-NLS-1$
map.put("authorHref", href);//$NON-NLS-1$
map.put("name", name);//$NON-NLS-1$
map.put("description", description);//$NON-NLS-1$