public XMLDescriptor addEmployeeDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(Employee.class); descriptor.setDefaultRootElement("employee"); XMLCompositeObjectMapping addr = new XMLCompositeObjectMapping(); addr.setAttributeName("address"); addr.setXPath("address"); addr.setReferenceClass(Address.class); descriptor.addMapping(addr); XMLCompositeCollectionMapping phone = new XMLCompositeCollectionMapping(); phone.setAttributeName("phoneNumbers"); phone.setXPath("phone-number"); phone.setReferenceClass(PhoneNumber.class); phone.useCollectionClass(ArrayList.class); descriptor.addMapping(phone); XMLAnyObjectMapping object = new XMLAnyObjectMapping(); object.setAttributeName("anyObject"); object.setXPath("any-object"); descriptor.addMapping(object); XMLAnyCollectionMapping anyCollection = new XMLAnyCollectionMapping(); anyCollection.setAttributeName("anyCollection"); anyCollection.setXPath("any-collection"); anyCollection.useCollectionClass(ArrayList.class); descriptor.addMapping(anyCollection); this.addDescriptor(descriptor); return descriptor; }
public ClassDescriptor buildRootDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(AnyCollectionRoot.class); descriptor.setDefaultRootElement("root"); XMLAnyCollectionMapping mapping = new XMLAnyCollectionMapping(); mapping.setAttributeName("any"); mapping.setGetMethodName("getAny"); mapping.setSetMethodName("setAny"); descriptor.addMapping(mapping); return descriptor; }
protected void addOpenMappings() { XMLAnyCollectionMapping anyMapping = new XMLAnyCollectionMapping(); anyMapping.setAttributeName(ANY_MAPPING_ATTRIBUTE_NAME); anyMapping.setGetMethodName(ANY_MAPPING_GET_METHOD_NAME); anyMapping.setSetMethodName(ANY_MAPPING_SET_METHOD_NAME); anyMapping.setUseXMLRoot(true); getXmlDescriptor().addMapping(anyMapping); XMLAnyAttributeMapping anyAttrMapping = new XMLAnyAttributeMapping(); anyAttrMapping.setAttributeName("openContentPropertiesAttributes"); anyAttrMapping.setGetMethodName("_getOpenContentPropertiesAttributesMap"); anyAttrMapping.setSetMethodName("_setOpenContentPropertiesAttributesMap"); getXmlDescriptor().addMapping(anyAttrMapping); }
public ClassDescriptor buildRootDescriptor() { XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(Root.class); descriptor.setDefaultRootElement("root"); XMLAnyCollectionMapping mapping = new XMLAnyCollectionMapping(); mapping.setAttributeName("any"); mapping.setGetMethodName("getAny"); mapping.setSetMethodName("setAny"); mapping.setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT); descriptor.addMapping(mapping); return descriptor; }
protected ClassDescriptor buildRootDescriptor( // boolean firstMappingIsAnyCollection, // boolean firstMappingXPathSet, // boolean secondMappingIsAnyCollection, // boolean secondMappingXPathSet) { // XMLDescriptor descriptor = new XMLDescriptor(); descriptor.setJavaClass(Customer.class); descriptor.setDefaultRootElement("customer"); DatabaseMapping anyMapping1 = null; // First Mapping if (!firstMappingIsAnyCollection) { anyMapping1 = new XMLAnyObjectMapping(); ((XMLAnyObjectMapping) anyMapping1).setAttributeName("anyObject"); // ((XMLAnyObjectMapping) anyMapping1).setGetMethodName("getAnyObject"); // ((XMLAnyObjectMapping) anyMapping1).setSetMethodName("setAnyObject"); if (firstMappingXPathSet) { // set first mapping XPath ((XMLAnyObjectMapping) anyMapping1).setXPath(MAPPING_XPATH_OBJ); } descriptor.addMapping((XMLAnyObjectMapping) anyMapping1); } else { anyMapping1 = new XMLAnyCollectionMapping(); ((XMLAnyCollectionMapping) anyMapping1).setAttributeName("contactMethods"); // ((XMLAnyCollectionMapping) anyMapping1).setGetMethodName("getAnyCollection"); // ((XMLAnyCollectionMapping) anyMapping1).setSetMethodName("setAnyCollection"); if (firstMappingXPathSet) { // set first mapping XPath ((XMLAnyCollectionMapping) anyMapping1).setXPath(MAPPING_XPATH); } descriptor.addMapping((XMLAnyCollectionMapping) anyMapping1); } // Second Mapping DatabaseMapping anyMapping2 = null; if (!secondMappingIsAnyCollection) { anyMapping2 = new XMLAnyObjectMapping(); ((XMLAnyObjectMapping) anyMapping2).setAttributeName("anyObject"); // ((XMLAnyObjectMapping) anyMapping2).setGetMethodName("getAnyObject"); // ((XMLAnyObjectMapping) anyMapping2).setSetMethodName("setAnyObject"); if (secondMappingXPathSet) { // set second mapping XPath ((XMLAnyObjectMapping) anyMapping2).setXPath(MAPPING_XPATH_OBJ); } descriptor.addMapping((XMLAnyObjectMapping) anyMapping2); } else { anyMapping2 = new XMLAnyCollectionMapping(); ((XMLAnyCollectionMapping) anyMapping2).setAttributeName("contactMethods"); // ((XMLAnyCollectionMapping) anyMapping2).setGetMethodName("getAnyCollection"); // ((XMLAnyCollectionMapping) anyMapping2).setSetMethodName("setAnyCollection"); if (secondMappingXPathSet) { // set second mapping XPath ((XMLAnyCollectionMapping) anyMapping2).setXPath(MAPPING_XPATH); } descriptor.addMapping((XMLAnyCollectionMapping) anyMapping2); } return descriptor; }