use of com.zimbra.soap.util.JaxbNodeInfo in project zm-mailbox by Zimbra.
the class XmlElementDescription method addXmlInfo.
/**
* Populate {@link desc} with value, attribute and sub-element information
*/
private static void addXmlInfo(XmlElementDescription desc, JaxbInfo jaxbInfo) {
JaxbValueInfo valueInfo = jaxbInfo.getElementValue();
if (valueInfo != null) {
desc.valueFieldName = valueInfo.getFieldName();
desc.valueType = ValueDescription.create(desc.valueFieldName, valueInfo.getAtomClass());
desc.elementText = desc.valueType.getRepresentation();
}
for (JaxbAttributeInfo attrInfo : jaxbInfo.getAttributes()) {
desc.attribs.add(XmlAttributeDescription.create(desc, attrInfo));
}
for (JaxbNodeInfo nodeInfo : jaxbInfo.getJaxbNodeInfos()) {
if (nodeInfo instanceof WrappedElementInfo) {
desc.children.add(XmlElementDescription.createForWrappedElement(desc, (WrappedElementInfo) nodeInfo));
} else if (nodeInfo instanceof JaxbElementInfo) {
desc.children.add(XmlElementDescription.createForElement(desc, (JaxbElementInfo) nodeInfo));
} else if (nodeInfo instanceof JaxbPseudoNodeChoiceInfo) {
JaxbPseudoNodeChoiceInfo jaxbChoice = (JaxbPseudoNodeChoiceInfo) nodeInfo;
ChoiceNode choiceNode = new ChoiceNode(jaxbChoice.isMultiElement());
desc.children.add(choiceNode);
for (JaxbElementInfo choice : jaxbChoice.getElements()) {
choiceNode.addChild(XmlElementDescription.createForElement(desc, choice));
}
}
}
}
use of com.zimbra.soap.util.JaxbNodeInfo in project zm-mailbox by Zimbra.
the class JaxbToElementTest method jaxbInfoSuperclassElems.
@Test
public void jaxbInfoSuperclassElems() throws Exception {
JaxbInfo jaxbInfo = JaxbInfo.getFromCache(CreateAccountRequest.class);
Iterable<String> attrNames = jaxbInfo.getAttributeNames();
Assert.assertEquals("Number of attributes for CreateAccountRequest", 2, Iterables.size(attrNames));
Iterable<String> elemNames = jaxbInfo.getElementNames();
Assert.assertEquals("Number of elements for CreateAccountRequest", 1, Iterables.size(elemNames));
Assert.assertTrue("Has <a>", -1 != Iterables.indexOf(elemNames, Predicates.equalTo(MailConstants.E_A)));
Iterable<JaxbNodeInfo> nodeInfos = jaxbInfo.getJaxbNodeInfos();
Assert.assertEquals("Number of nodeInfos for CreateAccountRequest", 1, Iterables.size(nodeInfos));
JaxbNodeInfo nodeInfo = Iterables.get(nodeInfos, 0);
Assert.assertEquals("NodeInfo name ", MailConstants.E_A, nodeInfo.getName());
if (!(nodeInfo instanceof JaxbElementInfo)) {
Assert.fail("Expecting JaxbElementInfo but got " + nodeInfo.getClass().getName());
} else {
JaxbElementInfo elemInfo = (JaxbElementInfo) nodeInfo;
Assert.assertEquals("Class associated with <a>", Attr.class, elemInfo.getAtomClass());
}
JaxbNodeInfo node = jaxbInfo.getElemNodeInfo(MailConstants.E_A);
Assert.assertNotNull("has NodeInfo for Element <a>", node);
Assert.assertTrue("hasElement <a>", jaxbInfo.hasElement(MailConstants.E_A));
}
use of com.zimbra.soap.util.JaxbNodeInfo in project zm-mailbox by Zimbra.
the class XmlElementDescription method createForWrappedElement.
private static XmlElementDescription createForWrappedElement(DescriptionNode parent, WrappedElementInfo nodeInfo) {
XmlElementDescription desc = new XmlElementDescription(true, true, false);
desc.parent = parent;
desc.minOccurs = 1;
desc.targetNamespace = nodeInfo.getNamespace();
desc.name = nodeInfo.getName();
desc.isInnerRecursionElement = false;
desc.jaxbClass = null;
desc.typeName = "";
desc.typeIdString = "";
desc.elementText = "";
desc.fieldName = null;
for (JaxbNodeInfo child : nodeInfo.getElements()) {
if (child instanceof JaxbElementInfo) {
desc.children.add(XmlElementDescription.createForElement(desc, (JaxbElementInfo) child));
} else if (child instanceof JaxbPseudoNodeChoiceInfo) {
JaxbPseudoNodeChoiceInfo jaxbChoice = (JaxbPseudoNodeChoiceInfo) child;
ChoiceNode choiceNode = new ChoiceNode(jaxbChoice.isMultiElement());
desc.children.add(choiceNode);
for (JaxbElementInfo choice : jaxbChoice.getElements()) {
choiceNode.addChild(XmlElementDescription.createForElement(desc, choice));
}
}
}
return desc;
}
Aggregations