if (! XMLStyles.isValidPhraseTag(element.getName())) {
throw new ConversionException(
"Invalid element: " + element.getName() + ". The only "
+ "accepted tag name is '" + xmlStyle.getPhraseTagName() + "'.");
}
Phrase returnPhrase = new Phrase();
String attributeValue;
attributeValue = XMLStyles.getTitleAttributeValue(element);
if (! attributeValue.equals("")) {
try {
returnPhrase.setTitle(attributeValue);
} catch (NumberFormatException e) {
throw new ConversionException(
"Invalid attribute value: " + attributeValue + ". The "
+ "attribute '" + xmlStyle.getTitleAttributeName() + "' of element '"
+ xmlStyle.getPhraseTagName() + "' must represent a Java integer.");
}
}
attributeValue = XMLStyles.getStartTimeAttributeValue(element);
if (! attributeValue.equals("")) {
try {
returnPhrase.setStartTime(
Double.valueOf(attributeValue).doubleValue());
} catch (NumberFormatException e) {
throw new ConversionException(
"Invalid attribute value: " + attributeValue + ". The "
+ "attribute '" + xmlStyle.getStartTimeAttributeName() + "' of element '"
+ xmlStyle.getPhraseTagName() + "' must represent a Java double.");
}
}
attributeValue = XMLStyles.getInstrumentAttributeValue(element);
if (! attributeValue.equals("")) {
try {
returnPhrase.setInstrument(Integer.parseInt(attributeValue));
} catch (NumberFormatException e) {
throw new ConversionException(
"Invalid attribute value: " + attributeValue + ". The "
+ "attribute '" + xmlStyle.getInstrumentAttributeName() + "' of element '"
+ xmlStyle.getPhraseTagName() + "' must represent a Java integer.");
}
}
attributeValue = XMLStyles.getTempoAttributeValue(element);
if (! attributeValue.equals("")) {
try {
returnPhrase.setTempo(
Double.valueOf(attributeValue).doubleValue());
} catch (NumberFormatException e) {
throw new ConversionException(
"Invalid attribute value: " + attributeValue + ". The "
+ "attribute '" + xmlStyle.getTempoAttributeName() + "' of element '"
+ xmlStyle.getPhraseTagName() + "' must represent a Java double.");
}
}
attributeValue = XMLStyles.getAppendAttributeValue(element);
if (! attributeValue.equals("")) {
returnPhrase.setAppend(new Boolean(attributeValue).booleanValue());
}
attributeValue = XMLStyles.getPanAttributeValue(element);
if (! attributeValue.equals("")) {
try {
returnPhrase.setPan(
Double.valueOf(attributeValue).doubleValue());
} catch (NumberFormatException e) {
throw new ConversionException(
"Invalid attribute value: " + attributeValue + ". The "
+ "attribute '" + xmlStyle.getPanAttributeName() + "' of element '"
+ xmlStyle.getPhraseTagName() + "' must represent a Java double.");
}
}
Element[] elements = element.getChildren();
for (int i = 0; i < elements.length; i++) {
if (XMLStyles.isValidNoteTag(elements[i].getName())) {
returnPhrase.addNote(elementToNote(elements[i]));
}
}
return returnPhrase;
}