DescriptionElement { public static OMElement createElement(final OMElement parent, final IDescription data) { if (data == null || Utils.isNullOrEmpty(data.getText())) return null; final OMFactory f = parent.getOMFactory(); final OMElement description = f.createOMElement(Q_ELEMENT_NAME, parent); final String content = data.getText(); if (!Utils.isNullOrEmpty(content)) description.setText(content); final String lang = data.getLanguage(); if (!Utils.isNullOrEmpty(lang)) description.addAttribute(LN_ATTR_LANG, lang, f.createOMNamespace(NS_URI_ATTR_LANG, NS_PREFIX_ATTR_LANG)); return description; }  static OMElement createElement(final OMElement parent, final IDescription data); static OMElement getElement(final OMElement parent); static Description readElement(final OMElement descrElement); static final QName Q_ELEMENT_NAME; static final String LN_ATTR_LANG; }
@Test public void testCreateElementWithLang() { Description description = new Description("Some descriptive text", "en-CA"); OMElement dElement = DescriptionElement.createElement(createParent(), description); assertNotNull(dElement); assertEquals(Q_ELEMENT_NAME, dElement.getQName()); assertEquals(description.getLanguage(), dElement.getAttributeValue(LANG_ATTR_NAME)); assertEquals(description.getText(), dElement.getText()); }
@Test public void testCreateElementNoLang() { Description description = new Description("Some descriptive text"); OMElement dElement = DescriptionElement.createElement(createParent(), description); assertNotNull(dElement); assertEquals(Q_ELEMENT_NAME, dElement.getQName()); assertNull(description.getLanguage(), dElement.getAttributeValue(LANG_ATTR_NAME)); assertEquals(description.getText(), dElement.getText()); }