*/
public static void updateMetadata(String entryName, Variant variant,
boolean applyDefault, MetadataService metadataService) {
if (variant != null) {
String[] tokens = entryName.split("\\.");
Metadata current;
// We found a potential variant
for (int j = 1; j < tokens.length; j++) {
current = metadataService.getMetadata(tokens[j]);
if (current != null) {
// Metadata extension detected
if (current instanceof MediaType) {
variant.setMediaType((MediaType) current);
} else if (current instanceof CharacterSet) {
variant.setCharacterSet((CharacterSet) current);
} else if (current instanceof Encoding) {
// Do we need to add this metadata?
boolean found = false;
for (int i = 0; !found
&& i < variant.getEncodings().size(); i++) {
found = current.includes(variant.getEncodings()
.get(i));
}
if (!found) {
variant.getEncodings().add((Encoding) current);
}
} else if (current instanceof Language) {
// Do we need to add this metadata?
boolean found = false;
for (int i = 0; !found
&& i < variant.getLanguages().size(); i++) {
found = current.includes(variant.getLanguages()
.get(i));
}
if (!found) {
variant.getLanguages().add((Language) current);
}