final Set<String> preferredCodespaces, final boolean isBrief)
{
values = new ArrayList<Object>(2); // In the vast majority of cases, we will have only one value.
units = new ArrayList<Object>(2);
identifiers = new LinkedHashMap<String,Set<Object>>();
ReferenceIdentifier name = object.getName();
if (name != null) { // Paranoiac check.
final String codespace = name.getCodeSpace();
if (preferredCodespaces == null || preferredCodespaces.contains(codespace)) {
addIdentifier(codespace, name.getCode()); // Value needs to be a String here.
name = null;
}
}
/*
* For detailed content, add aliases.
* For brief content, add the first alias if we have not been able to add the name.
*/
if (!isBrief || identifiers.isEmpty()) {
final Collection<GenericName> aliases = object.getAlias();
if (aliases != null) { // Paranoiac check.
for (GenericName alias : aliases) {
String codespace = NameToIdentifier.getCodeSpace(alias, locale);
if (codespace != null) {
alias = alias.tip();
} else {
final NameSpace scope = alias.scope();
if (scope != null && !scope.isGlobal()) {
codespace = NameToIdentifier.toString(scope.name().tip(), locale);
}
}
if (preferredCodespaces == null || preferredCodespaces.contains(codespace)) {
addIdentifier(codespace, NameToIdentifier.toString(alias, locale));
name = null;
if (isBrief) {
break;
}
}
}
}
}
/*
* If we found no name and no alias in the codespaces requested by the user,
* unconditionally add the name regardless its namespace.
*/
if (name != null) {
addIdentifier(name.getCodeSpace(), name.getCode()); // Value needs to be a String here.
}
/*
* Add identifiers (detailed mode only).
*/
if (!isBrief) {