/** * INTERNAL: * Clones itself. */ public Object clone() { // Bug 3037701 - clone the AttributeAccessor DatabaseMapping mapping = null; try { mapping = (DatabaseMapping)super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } mapping.setAttributeAccessor((AttributeAccessor)attributeAccessor.clone()); return mapping; }
/** * INTERNAL: * Clones itself. */ @Override public Object clone() { // Bug 3037701 - clone the AttributeAccessor DatabaseMapping mapping = null; try { mapping = (DatabaseMapping)super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } mapping.setAttributeAccessor((AttributeAccessor)attributeAccessor.clone()); return mapping; }
/** * INTERNAL: * Clones itself. */ @Override public Object clone() { // Bug 3037701 - clone the AttributeAccessor DatabaseMapping mapping = null; try { mapping = (DatabaseMapping)super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } mapping.setAttributeAccessor((AttributeAccessor)attributeAccessor.clone()); return mapping; }
Map<String, Object> properties = new HashMap<String, Object>(1); properties.put(JAXBContextProperties.SESSION_EVENT_LISTENER, new SessionEventAdapter() { @Override public void postLogin(SessionEvent event) { Project project = event.getSession().getProject(); for(ClassDescriptor descriptor : project.getOrderedDescriptors()) { for(DatabaseMapping mapping : descriptor.getMappings()) { mapping.setAttributeAccessor(new MyAttributeAccessor(mapping.getAttributeAccessor())); } } super.preLogin(event); } }); JAXBContext jc = JAXBContext.newInstance(new Class[] {Foo.class}, properties);
public void preInitialize(AbstractSession session) throws DescriptorException { getAttributeAccessor().setIsWriteOnly(this.isWriteOnly()); getAttributeAccessor().setIsReadOnly(this.isReadOnly()); super.preInitialize(session); Iterator<XMLMapping> mappings = getChoiceElementMappings().values().iterator(); while(mappings.hasNext()){ DatabaseMapping nextMapping = (DatabaseMapping)mappings.next(); nextMapping.setAttributeName(this.getAttributeName()); if(nextMapping.getAttributeAccessor() == temporaryAccessor){ nextMapping.setAttributeAccessor(getAttributeAccessor()); } nextMapping.setDescriptor(getDescriptor()); nextMapping.preInitialize(session); } }
public void preInitialize(AbstractSession session) throws DescriptorException { getAttributeAccessor().setIsWriteOnly(this.isWriteOnly()); getAttributeAccessor().setIsReadOnly(this.isReadOnly()); super.preInitialize(session); Iterator<XMLMapping> mappings = getChoiceElementMappings().values().iterator(); while(mappings.hasNext()){ DatabaseMapping nextMapping = (DatabaseMapping)mappings.next(); nextMapping.setDescriptor(getDescriptor()); nextMapping.setAttributeName(this.getAttributeName()); if(nextMapping.getAttributeAccessor() == temporaryAccessor){ nextMapping.setAttributeAccessor(getAttributeAccessor()); } nextMapping.preInitialize(session); } }
@Override protected ClassDescriptor buildXMLCompositeObjectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLCompositeObjectMappingDescriptor(); // Add Null Policy XMLCompositeObjectMapping nullPolicyClassMapping = new XMLCompositeObjectMapping(); nullPolicyClassMapping.setReferenceClass(AbstractNullPolicy.class); nullPolicyClassMapping.setAttributeName("nullPolicy"); nullPolicyClassMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); // Handle translation of (default) Null Policy states. ((DatabaseMapping)nullPolicyClassMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(nullPolicyClassMapping); return descriptor; }
/** * INTERNAL: * Set the getter and setter access methods for this accessor. */ protected void setAccessorMethods(DatabaseMapping mapping) { if (usesPropertyAccess() || usesVirtualAccess()) { if (usesVirtualAccess()) { mapping.setAttributeAccessor(new VirtualAttributeAccessor()); } mapping.setGetMethodName(getGetMethodName()); mapping.setSetMethodName(getSetMethodName()); } }
@Override protected ClassDescriptor buildXMLCompositeObjectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLCompositeObjectMappingDescriptor(); // Add Null Policy XMLCompositeObjectMapping nullPolicyClassMapping = new XMLCompositeObjectMapping(); nullPolicyClassMapping.setReferenceClass(AbstractNullPolicy.class); nullPolicyClassMapping.setAttributeName("nullPolicy"); nullPolicyClassMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); // Handle translation of (default) Null Policy states. ((DatabaseMapping)nullPolicyClassMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(nullPolicyClassMapping); return descriptor; }
@Override protected ClassDescriptor buildXMLCompositeObjectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLCompositeObjectMappingDescriptor(); // Add Null Policy XMLCompositeObjectMapping nullPolicyClassMapping = new XMLCompositeObjectMapping(); nullPolicyClassMapping.setReferenceClass(AbstractNullPolicy.class); nullPolicyClassMapping.setAttributeName("nullPolicy"); nullPolicyClassMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); // Handle translation of (default) Null Policy states. ((DatabaseMapping)nullPolicyClassMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(nullPolicyClassMapping); return descriptor; }
/** * PUBLIC: * This method is invoked reflectively on the reference object to return the value of the * attribute in the object. This method sets the name of the getMethodName. */ public void setGetMethodName(String methodName) { if (methodName == null) { return; } // This is done because setting attribute name by defaults create InstanceVariableAttributeAccessor if (getAttributeAccessor() instanceof InstanceVariableAttributeAccessor) { String attributeName = this.attributeAccessor.getAttributeName(); setAttributeAccessor(new MethodAttributeAccessor()); getAttributeAccessor().setAttributeName(attributeName); } ((MethodAttributeAccessor)getAttributeAccessor()).setGetMethodName(methodName); }
/** * PUBLIC: * This method is invoked reflectively on the reference object to return the value of the * attribute in the object. This method sets the name of the getMethodName. */ public void setGetMethodName(String methodName) { if (methodName == null) { return; } // This is done because setting attribute name by defaults create InstanceVariableAttributeAccessor if (getAttributeAccessor() instanceof InstanceVariableAttributeAccessor) { String attributeName = this.attributeAccessor.getAttributeName(); setAttributeAccessor(new MethodAttributeAccessor()); getAttributeAccessor().setAttributeName(attributeName); } ((MethodAttributeAccessor)getAttributeAccessor()).setGetMethodName(methodName); }
/** * PUBLIC: * This method is invoked reflectively on the reference object to return the value of the * attribute in the object. This method sets the name of the getMethodName. */ public void setGetMethodName(String methodName) { if (methodName == null) { return; } // This is done because setting attribute name by defaults create InstanceVariableAttributeAccessor if (getAttributeAccessor() instanceof InstanceVariableAttributeAccessor) { String attributeName = this.attributeAccessor.getAttributeName(); setAttributeAccessor(new MethodAttributeAccessor()); getAttributeAccessor().setAttributeName(attributeName); } ((MethodAttributeAccessor)getAttributeAccessor()).setGetMethodName(methodName); }
/** * PUBLIC: * Set the methodName used to set the value for the mapping's attribute into the object. */ public void setSetMethodName(String methodName) { if (methodName == null) { return; } // This is done because setting attribute name by defaults create InstanceVariableAttributeAccessor if (!getAttributeAccessor().isMethodAttributeAccessor()) { String attributeName = this.attributeAccessor.getAttributeName(); setAttributeAccessor(new MethodAttributeAccessor()); getAttributeAccessor().setAttributeName(attributeName); } ((MethodAttributeAccessor)getAttributeAccessor()).setSetMethodName(methodName); }
/** * PUBLIC: * Set the methodName used to set the value for the mapping's attribute into the object. */ public void setSetMethodName(String methodName) { if (methodName == null) { return; } // This is done because setting attribute name by defaults create InstanceVariableAttributeAccessor if (!getAttributeAccessor().isMethodAttributeAccessor()) { String attributeName = this.attributeAccessor.getAttributeName(); setAttributeAccessor(new MethodAttributeAccessor()); getAttributeAccessor().setAttributeName(attributeName); } ((MethodAttributeAccessor)getAttributeAccessor()).setSetMethodName(methodName); }
/** * PUBLIC: * Set the methodName used to set the value for the mapping's attribute into the object. */ public void setSetMethodName(String methodName) { if (methodName == null) { return; } // This is done because setting attribute name by defaults create InstanceVariableAttributeAccessor if (!getAttributeAccessor().isMethodAttributeAccessor()) { String attributeName = this.attributeAccessor.getAttributeName(); setAttributeAccessor(new MethodAttributeAccessor()); getAttributeAccessor().setAttributeName(attributeName); } ((MethodAttributeAccessor)getAttributeAccessor()).setSetMethodName(methodName); }
@Override protected ClassDescriptor buildXMLDirectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLDirectMappingDescriptor(); XMLDirectMapping isCDATAMapping = new XMLDirectMapping(); isCDATAMapping.setAttributeName("isCDATA"); isCDATAMapping.setGetMethodName("isCDATA"); isCDATAMapping.setSetMethodName("setIsCDATA"); isCDATAMapping.setXPath(getPrimaryNamespaceXPath() + "is-cdata/text()"); isCDATAMapping.setNullValue(Boolean.FALSE); descriptor.addMapping(isCDATAMapping); // Add Null Policy XMLCompositeObjectMapping aMapping = new XMLCompositeObjectMapping(); aMapping.setReferenceClass(AbstractNullPolicy.class); aMapping.setAttributeName("nullPolicy"); aMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); ((DatabaseMapping)aMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(aMapping); return descriptor; }
@Override protected ClassDescriptor buildXMLDirectMappingDescriptor() { ClassDescriptor descriptor = super.buildXMLDirectMappingDescriptor(); XMLDirectMapping isCDATAMapping = new XMLDirectMapping(); isCDATAMapping.setAttributeName("isCDATA"); isCDATAMapping.setGetMethodName("isCDATA"); isCDATAMapping.setSetMethodName("setIsCDATA"); isCDATAMapping.setXPath(getPrimaryNamespaceXPath() + "is-cdata/text()"); isCDATAMapping.setNullValue(Boolean.FALSE); descriptor.addMapping(isCDATAMapping); // Add Null Policy XMLCompositeObjectMapping aMapping = new XMLCompositeObjectMapping(); aMapping.setReferenceClass(AbstractNullPolicy.class); aMapping.setAttributeName("nullPolicy"); aMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); ((DatabaseMapping)aMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(aMapping); return descriptor; }
@Override protected ClassDescriptor buildXMLCompositeDirectCollectionMappingDescriptor() { XMLDescriptor descriptor = (XMLDescriptor) super.buildXMLCompositeDirectCollectionMappingDescriptor(); XMLCompositeObjectMapping aMapping = new XMLCompositeObjectMapping(); aMapping.setReferenceClass(AbstractNullPolicy.class); aMapping.setAttributeName("nullPolicy"); aMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); ((DatabaseMapping)aMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(aMapping); XMLDirectMapping reuseContainerMapping = new XMLDirectMapping(); reuseContainerMapping.setAttributeName("reuseContainer"); reuseContainerMapping.setGetMethodName("getReuseContainer"); reuseContainerMapping.setSetMethodName("setReuseContainer"); reuseContainerMapping.setXPath(getPrimaryNamespaceXPath() + "reuse-container/text()"); reuseContainerMapping.setNullValue(Boolean.FALSE); descriptor.addMapping(reuseContainerMapping); return descriptor; }
@Override protected ClassDescriptor buildXMLCompositeDirectCollectionMappingDescriptor() { XMLDescriptor descriptor = (XMLDescriptor) super.buildXMLCompositeDirectCollectionMappingDescriptor(); XMLCompositeObjectMapping aMapping = new XMLCompositeObjectMapping(); aMapping.setReferenceClass(AbstractNullPolicy.class); aMapping.setAttributeName("nullPolicy"); aMapping.setXPath(getPrimaryNamespaceXPath() + "null-policy"); ((DatabaseMapping)aMapping).setAttributeAccessor(new NullPolicyAttributeAccessor()); descriptor.addMapping(aMapping); XMLDirectMapping reuseContainerMapping = new XMLDirectMapping(); reuseContainerMapping.setAttributeName("reuseContainer"); reuseContainerMapping.setGetMethodName("getReuseContainer"); reuseContainerMapping.setSetMethodName("setReuseContainer"); reuseContainerMapping.setXPath(getPrimaryNamespaceXPath() + "reuse-container/text()"); reuseContainerMapping.setNullValue(Boolean.FALSE); descriptor.addMapping(reuseContainerMapping); return descriptor; }