public void addEmployeeDescriptor(boolean methodAccess) {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");

    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("@id");
    descriptor.addMapping(idMapping);

    XMLDirectMapping firstNameMapping = new XMLDirectMapping();
    firstNameMapping.setAttributeName("firstName");
    firstNameMapping.setXPath("first-name/text()");
    descriptor.addMapping(firstNameMapping);

    XMLDirectMapping lastNameMapping = new XMLDirectMapping();
    lastNameMapping.setAttributeName("lastName");
    lastNameMapping.setXPath("last-name/text()");
    descriptor.addMapping(lastNameMapping);

    XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
    addressMapping.setAttributeName("address");
    addressMapping.setReferenceClass(Address.class);
    addressMapping.setXPath("address");
    descriptor.addMapping(addressMapping);

    XMLCompositeCollectionMapping phoneMapping = new XMLCompositeCollectionMapping();
    phoneMapping.setAttributeName("phoneNumbers");
    phoneMapping.setReferenceClass(PhoneNumber.class);
    phoneMapping.setXPath("phone-numbers/number");
    phoneMapping.setContainerPolicy(ContainerPolicy.buildPolicyFor(ArrayList.class));
    descriptor.addMapping(phoneMapping);
    this.addDescriptor(descriptor);
  }
  public void addAddressDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Address.class);

    XMLDirectMapping streetMapping = new XMLDirectMapping();
    streetMapping.setAttributeName("street");
    streetMapping.setXPath("street/text()");
    descriptor.addMapping(streetMapping);

    XMLDirectMapping cityMapping = new XMLDirectMapping();
    cityMapping.setAttributeName("city");
    cityMapping.setXPath("city/text()");
    descriptor.addMapping(cityMapping);

    XMLDirectMapping stateMapping = new XMLDirectMapping();
    stateMapping.setAttributeName("state");
    stateMapping.setXPath("state/text()");
    descriptor.addMapping(stateMapping);

    XMLDirectMapping countryMapping = new XMLDirectMapping();
    countryMapping.setAttributeName("country");
    countryMapping.setXPath("country/text()");
    descriptor.addMapping(countryMapping);

    this.addDescriptor(descriptor);
  }
  public ClassDescriptor buildXMLBinaryDataCollectionMappingDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(XMLBinaryDataCollectionMapping.class);

    descriptor.getInheritancePolicy().setParentClass(XMLCompositeDirectCollectionMapping.class);

    XMLDirectMapping swaRefMapping = new XMLDirectMapping();
    swaRefMapping.setAttributeName("isSwaRef");
    swaRefMapping.setXPath(getPrimaryNamespaceXPath() + "is-swa-ref/text()");
    descriptor.addMapping(swaRefMapping);

    XMLDirectMapping mimeTypeMapping = new XMLDirectMapping();
    mimeTypeMapping.setAttributeName("mimeTypePolicy");
    mimeTypeMapping.setGetMethodName("getMimeType");
    mimeTypeMapping.setSetMethodName("setMimeType");
    mimeTypeMapping.setXPath(getPrimaryNamespaceXPath() + "mime-type/text()");
    descriptor.addMapping(mimeTypeMapping);

    XMLDirectMapping shouldInlineMapping = new XMLDirectMapping();
    shouldInlineMapping.setAttributeName("shouldInlineBinaryData");
    shouldInlineMapping.setXPath(getPrimaryNamespaceXPath() + "should-inline-data");
    descriptor.addMapping(shouldInlineMapping);

    return descriptor;
  }
 private XMLDescriptor getEmployeeDescriptor() {
   XMLDescriptor descriptor = new XMLDescriptor();
   descriptor.setJavaClass(Employee.class);
   descriptor.setDefaultRootElement("employee");
   // create id mapping
   XMLDirectMapping idMapping = new XMLDirectMapping();
   idMapping.setAttributeName("id");
   idMapping.setXPath("@id");
   descriptor.addMapping(idMapping);
   // create name mapping
   XMLDirectMapping nameMapping = new XMLDirectMapping();
   nameMapping.setAttributeName("name");
   nameMapping.setXPath("name/text()");
   descriptor.addMapping(nameMapping);
   // create address mapping
   XMLCollectionReferenceMapping addressMapping = new XMLCollectionReferenceMapping();
   addressMapping.useCollectionClass(ArrayList.class);
   addressMapping.setUsesSingleNode(true);
   addressMapping.setAttributeName("addresses");
   addressMapping.setXPath("grouping-element");
   addressMapping.setReferenceClass(Address.class);
   addressMapping.addSourceToTargetKeyFieldAssociation("address/id-city/text()", "city/text()");
   addressMapping.addSourceToTargetKeyFieldAssociation("address/id-zip/text()", "zip/text()");
   descriptor.addMapping(addressMapping);
   return descriptor;
 }
 private XMLDescriptor getAddressDescriptor() {
   XMLDescriptor descriptor = new XMLDescriptor();
   descriptor.setJavaClass(Address.class);
   descriptor.addPrimaryKeyFieldName("@aid");
   descriptor.setDefaultRootElement("address");
   // create id mapping
   XMLDirectMapping idMapping = new XMLDirectMapping();
   idMapping.setAttributeName("id");
   idMapping.setXPath("@aid");
   descriptor.addMapping(idMapping);
   // create street mapping
   XMLDirectMapping streetMapping = new XMLDirectMapping();
   streetMapping.setAttributeName("street");
   streetMapping.setXPath("street/text()");
   descriptor.addMapping(streetMapping);
   // create city mapping
   XMLDirectMapping cityMapping = new XMLDirectMapping();
   cityMapping.setAttributeName("city");
   cityMapping.setXPath("city/text()");
   descriptor.addMapping(cityMapping);
   // create country mapping
   XMLDirectMapping countryMapping = new XMLDirectMapping();
   countryMapping.setAttributeName("country");
   countryMapping.setXPath("country/text()");
   descriptor.addMapping(countryMapping);
   // create zip mapping
   XMLDirectMapping zipMapping = new XMLDirectMapping();
   zipMapping.setAttributeName("zip");
   zipMapping.setXPath("zip/text()");
   descriptor.addMapping(zipMapping);
   return descriptor;
 }
  private XMLDescriptor getEmailAddressDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(EmailAddress.class);

    XMLDirectMapping userIDMapping = new XMLDirectMapping();
    userIDMapping.setAttributeName("userID");
    userIDMapping.setXPath("user-id/text()");
    descriptor.addMapping(userIDMapping);

    XMLDirectMapping domainMapping = new XMLDirectMapping();
    domainMapping.setAttributeName("domain");
    domainMapping.setXPath("domain/text()");
    descriptor.addMapping(domainMapping);
    return descriptor;
  }
  protected XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    // descriptor.setDefaultRootElement("employee");
    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setXPath("id/text()");
    idMapping.setAttributeName("id");
    descriptor.addMapping(idMapping);

    XMLCompositeObjectMapping emailMapping = new XMLCompositeObjectMapping();
    emailMapping.setAttributeName("emailAddress");
    emailMapping.setXPath("info/email-address");
    emailMapping.setGetMethodName("getEmailAddress");
    emailMapping.setSetMethodName("setEmailAddress");
    emailMapping.setReferenceClass(EmailAddress.class);
    descriptor.addMapping(emailMapping);

    URL schemaURL =
        ClassLoader.getSystemResource("org/eclipse/persistence/testing/oxm/jaxb/Employee.xsd");
    XMLSchemaURLReference schemaRef = new XMLSchemaURLReference(schemaURL);
    schemaRef.setType(XMLSchemaURLReference.COMPLEX_TYPE);
    schemaRef.setSchemaContext("employee-root");
    descriptor.setSchemaReference(schemaRef);

    /*
    NamespaceResolver try_test = new NamespaceResolver();
    try_test.put("xsi", XMLConstants.SCHEMA_INSTANCE_URL);
    descriptor.setNamespaceResolver(try_test);*/
    return descriptor;
  }
  /**
   * INTERNAL: Convenience method that sets up class indicator and @sdoRef attribute.
   *
   * @param xdesc
   * @param pCls
   */
  private void addClassIndicator(XMLDescriptor xdesc, Class pCls, boolean isInheritanceRoot) {
    XMLField field = (XMLField) getXmlDescriptor().buildField("@xsi:type");
    xdesc.getInheritancePolicy().setClassIndicatorField(field);

    String parentIndicator = getName();
    String parentPrefix = xdesc.getNamespaceResolver().resolveNamespaceURI(getURI());
    if (parentPrefix != null) {
      parentIndicator =
          parentPrefix + SDOConstants.SDO_XPATH_NS_SEPARATOR_FRAGMENT + parentIndicator;
    }
    xdesc.getInheritancePolicy().addClassIndicator(pCls, parentIndicator);

    // only add the @sdoRef attribute if necessary
    if (xdesc.getMappingForAttributeName(SDO_REF_MAPPING_ATTRIBUTE_NAME) == null) {
      String sdoPrefix =
          ((SDOTypeHelper) aHelperContext.getTypeHelper()).getPrefix(SDOConstants.SDO_URL);
      XMLDirectMapping sdoRefMapping = new XMLDirectMapping();
      sdoRefMapping.setAttributeName(SDO_REF_MAPPING_ATTRIBUTE_NAME);

      XMLField xmlField =
          new XMLField(
              "@"
                  + sdoPrefix
                  + SDOConstants.SDO_XPATH_NS_SEPARATOR_FRAGMENT
                  + SDOConstants.CHANGESUMMARY_REF);
      xmlField.getXPathFragment().setNamespaceURI(SDOConstants.SDO_URL);
      xmlField.getLastXPathFragment().setNamespaceURI(SDOConstants.SDO_URL);

      sdoRefMapping.setField(xmlField);
      xdesc.addMapping(sdoRefMapping);
    }
  }
  public ClassDescriptor buildDatabaseLoginConfigDescriptor() {
    ClassDescriptor descriptor = super.buildDatabaseLoginConfigDescriptor();

    XMLDirectMapping bindAllParametersMapping =
        (XMLDirectMapping) descriptor.getMappingForAttributeName("m_bindAllParameters");
    bindAllParametersMapping.setNullValue(Boolean.valueOf(BIND_ALL_PARAMETERS_DEFAULT));

    XMLDirectMapping validateConnectionHealthOnErrorMapping = new XMLDirectMapping();
    validateConnectionHealthOnErrorMapping.setAttributeName("connectionHealthValidatedOnError");
    validateConnectionHealthOnErrorMapping.setGetMethodName("isConnectionHealthValidatedOnError");
    validateConnectionHealthOnErrorMapping.setSetMethodName("setConnectionHealthValidatedOnError");
    validateConnectionHealthOnErrorMapping.setXPath("connection-health-validated-on-error/text()");
    validateConnectionHealthOnErrorMapping.setNullPolicy(new NullPolicy(null, false, false, false));
    validateConnectionHealthOnErrorMapping.setNullValue(true);
    descriptor.addMapping(validateConnectionHealthOnErrorMapping);

    XMLDirectMapping delayBetweenReconnectAttempts = new XMLDirectMapping();
    delayBetweenReconnectAttempts.setAttributeName("delayBetweenConnectionAttempts");
    delayBetweenReconnectAttempts.setGetMethodName("getDelayBetweenConnectionAttempts");
    delayBetweenReconnectAttempts.setSetMethodName("setDelayBetweenConnectionAttempts");
    delayBetweenReconnectAttempts.setXPath("delay-between-reconnect-attempts/text()");
    delayBetweenReconnectAttempts.setNullPolicy(new NullPolicy(null, false, false, false));
    descriptor.addMapping(delayBetweenReconnectAttempts);

    XMLDirectMapping queryRetryAttemptCount = new XMLDirectMapping();
    queryRetryAttemptCount.setAttributeName("queryRetryAttemptCount");
    queryRetryAttemptCount.setGetMethodName("getQueryRetryAttemptCount");
    queryRetryAttemptCount.setSetMethodName("setQueryRetryAttemptCount");
    queryRetryAttemptCount.setXPath("query-retry-attempt-count/text()");
    queryRetryAttemptCount.setNullPolicy(new NullPolicy(null, false, false, false));
    descriptor.addMapping(queryRetryAttemptCount);

    XMLDirectMapping pingSQLMapping = new XMLDirectMapping();
    pingSQLMapping.setAttributeName("pingSQL");
    pingSQLMapping.setGetMethodName("getPingSQL");
    pingSQLMapping.setSetMethodName("setPingSQL");
    pingSQLMapping.setXPath("ping-sql/text()");
    pingSQLMapping.setNullPolicy(new NullPolicy(null, false, false, false));
    descriptor.addMapping(pingSQLMapping);

    return descriptor;
  }
  public void addAddressDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Address.class);

    XMLDirectMapping street = new XMLDirectMapping();
    street.setAttributeName("street");
    street.setXPath("street/text()");
    descriptor.addMapping(street);

    this.addDescriptor(descriptor);
  }
  public void addPhoneNumberDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(PhoneNumber.class);

    XMLDirectMapping numberMapping = new XMLDirectMapping();
    numberMapping.setAttributeName("number");
    numberMapping.setXPath("text()");
    descriptor.addMapping(numberMapping);

    this.addDescriptor(descriptor);
  }
  public XMLDescriptor getAddressDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Address.class);

    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("street");
    idMapping.setXPath("@street");
    xmlDescriptor.addMapping(idMapping);

    return xmlDescriptor;
  }
  public void addPhoneNumberDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(PhoneNumber.class);
    descriptor.setDefaultRootElement("phone-number");

    XMLDirectMapping num = new XMLDirectMapping();
    num.setAttributeName("number");
    num.setXPath("text()");
    descriptor.addMapping(num);

    this.addDescriptor(descriptor);
  }
 protected ClassDescriptor buildAddressDescriptor() {
   XMLDescriptor descriptor = new XMLDescriptor();
   descriptor.setJavaClass(Address.class);
   descriptor.setDefaultRootElement("address");
   XMLDirectMapping mapping = new XMLDirectMapping();
   mapping.setAttributeName("address_content");
   mapping.setGetMethodName("getContent");
   mapping.setSetMethodName("setContent");
   mapping.setXPath("text()");
   descriptor.addMapping(mapping);
   return descriptor;
 }
  public XMLDescriptor addAddressDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Address.class);
    descriptor.setDefaultRootElement("address");

    XMLDirectMapping street = new XMLDirectMapping();
    street.setAttributeName("street");
    street.setXPath("street/text()");
    descriptor.addMapping(street);

    this.addDescriptor(descriptor);
    return descriptor;
  }
  private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Employee.class);
    xmlDescriptor.setDefaultRootElement("DEFAULT:employee");

    NamespaceResolver nsResolver = new NamespaceResolver();
    nsResolver.put("DEFAULT", "http://www.example.com/EMPLOYEE");
    xmlDescriptor.setNamespaceResolver(nsResolver);

    // Unqualified attributes are in the null namespace
    // rather than the default namespace
    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("DEFAULT:personal-info/@id");
    xmlDescriptor.addMapping(idMapping);

    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setXPath("DEFAULT:personal-info/DEFAULT:name/text()");
    xmlDescriptor.addMapping(nameMapping);

    return xmlDescriptor;
  }
  public ClassDescriptor buildOc4jJGroupsTransportManagerConfigDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Oc4jJGroupsTransportManagerConfig.class);
    descriptor.getInheritancePolicy().setParentClass(TransportManagerConfig.class);

    XMLDirectMapping useSingleThreadedNotificationMapping = new XMLDirectMapping();
    useSingleThreadedNotificationMapping.setAttributeName("m_useSingleThreadedNotification");
    useSingleThreadedNotificationMapping.setGetMethodName("useSingleThreadedNotification");
    useSingleThreadedNotificationMapping.setSetMethodName("setUseSingleThreadedNotification");
    useSingleThreadedNotificationMapping.setXPath("use-single-threaded-notification/text()");
    useSingleThreadedNotificationMapping.setNullValue(
        Boolean.valueOf(USE_SINGLE_THREADED_NOTIFICATION_DEFAULT));
    descriptor.addMapping(useSingleThreadedNotificationMapping);

    XMLDirectMapping topicNameMapping = new XMLDirectMapping();
    topicNameMapping.setAttributeName("m_topicName");
    topicNameMapping.setGetMethodName("getTopicName");
    topicNameMapping.setSetMethodName("setTopicName");
    topicNameMapping.setXPath("topic-name/text()");
    descriptor.addMapping(topicNameMapping);

    return descriptor;
  }
  private XMLDescriptor getAddressDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Address.class);

    NamespaceResolver nsResolver = new NamespaceResolver();
    nsResolver.put("ns", "urn:example");
    xmlDescriptor.setNamespaceResolver(nsResolver);

    XMLDirectMapping streetMapping = new XMLDirectMapping();
    streetMapping.setAttributeName("street");
    streetMapping.setXPath("text()");
    xmlDescriptor.addMapping(streetMapping);

    return xmlDescriptor;
  }
  public void addAddressDescriptor(boolean methodAccess) {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Address.class);

    XMLDirectMapping streetMapping = new XMLDirectMapping();
    streetMapping.setAttributeName("street");
    streetMapping.setXPath("street/text()");
    descriptor.addMapping(streetMapping);

    XMLDirectMapping cityMapping = new XMLDirectMapping();
    cityMapping.setAttributeName("city");
    cityMapping.setXPath("city/text()");
    descriptor.addMapping(cityMapping);

    XMLDirectMapping stateMapping = new XMLDirectMapping();
    stateMapping.setAttributeName("state");
    stateMapping.setXPath("state/text()");
    descriptor.addMapping(stateMapping);

    XMLDirectMapping countryMapping = new XMLDirectMapping();
    countryMapping.setAttributeName("country");
    countryMapping.setXPath("country/text()");
    descriptor.addMapping(countryMapping);

    XMLInverseReferenceMapping owningEmployee = new XMLInverseReferenceMapping();
    owningEmployee.setReferenceClass(Employee.class);
    owningEmployee.setMappedBy("address");
    owningEmployee.setAttributeName("owningEmployee");
    if (methodAccess) {
      owningEmployee.setSetMethodName("setOwningEmployee");
      owningEmployee.setGetMethodName("getOwningEmployee");
    }
    descriptor.addMapping(owningEmployee);

    this.addDescriptor(descriptor);
  }
 public void setMixed(boolean isMixed) {
   String textAttribute = "text";
   XMLDirectMapping textMapping =
       (XMLDirectMapping) xmlDescriptor.getMappingForAttributeName(textAttribute);
   if (isMixed) {
     if (null == textMapping) {
       textMapping = new XMLDirectMapping();
       textMapping.setAttributeName(textAttribute);
       textMapping.setXPath("text()");
       xmlDescriptor.addMapping(textMapping);
     }
   } else {
     xmlDescriptor.removeMappingForAttributeName(textAttribute);
   }
 }
  public ClassDescriptor buildChildDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(AnyCollectionChild.class);
    descriptor.setDefaultRootElement("child");
    descriptor.addRootElement("someChild");

    XMLDirectMapping mapping = new XMLDirectMapping();
    mapping.setAttributeName("content");
    mapping.setGetMethodName("getContent");
    mapping.setSetMethodName("setContent");
    mapping.setXPath("text()");
    descriptor.addMapping(mapping);

    return descriptor;
  }
  /** INTERNAL: */
  public void postInitialize() {
    String idPropName = (String) get(SDOConstants.ID_PROPERTY);
    if (idPropName != null) {
      SDOProperty idProp = getProperty(idPropName);
      if (idProp != null) {
        String targetxpath = idProp.getQualifiedXPath(getURI(), true);
        getXmlDescriptor().addPrimaryKeyFieldName(targetxpath);
      }
    }
    setFinalized(true);
    if (null != nonFinalizedReferencingProps) {
      for (int i = 0; i < nonFinalizedReferencingProps.size(); i++) {
        SDOProperty nextProp = nonFinalizedReferencingProps.get(i);
        String nextURI = (String) getNonFinalizedMappingURIs().get(i);
        nextProp.buildMapping(nextURI, nextProp.getIndexInType());
      }
    }
    // set @sdoRef attribute mapping for complex types that are not involved in inheritance
    if (!isDataType() && !isSubType() && !isBaseType()) {
      String sdoPrefix =
          ((SDOTypeHelper) aHelperContext.getTypeHelper()).getPrefix(SDOConstants.SDO_URL);
      XMLDirectMapping sdoRefMapping = new XMLDirectMapping();
      sdoRefMapping.setAttributeName(SDO_REF_MAPPING_ATTRIBUTE_NAME);

      XMLField xmlField =
          new XMLField(
              "@"
                  + sdoPrefix
                  + SDOConstants.SDO_XPATH_NS_SEPARATOR_FRAGMENT
                  + SDOConstants.CHANGESUMMARY_REF);
      xmlField.getXPathFragment().setNamespaceURI(SDOConstants.SDO_URL);
      xmlField.getLastXPathFragment().setNamespaceURI(SDOConstants.SDO_URL);
      sdoRefMapping.setField(xmlField);
      xmlDescriptor.addMapping(sdoRefMapping);
    }
    if (!isDataType()) {
      getImplClass();
      if (!isAbstract() && !isWrapperType()) {
        TypeInstantiationPolicy tip = new TypeInstantiationPolicy(this);
        this.xmlDescriptor.setInstantiationPolicy(tip);
      }
    }
  }
  private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");

    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("@id");
    descriptor.addMapping(idMapping);

    XMLCompositeCollectionMapping emailMapping = new XMLCompositeCollectionMapping();
    emailMapping.setAttributeName("emailAddresses");
    emailMapping.setReferenceClass(EmailAddress.class);
    emailMapping.setXPath("email-addresses/email-address");
    emailMapping.setReuseContainer(true);
    descriptor.addMapping(emailMapping);

    return descriptor;
  }
  private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");

    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("@id");
    descriptor.addMapping(idMapping);

    XMLField field = new XMLField("photo");
    field.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);

    XMLBinaryDataMapping photoMapping = new XMLBinaryDataMapping();
    photoMapping.setAttributeName("photo");
    photoMapping.setField(field);
    descriptor.addMapping(photoMapping);

    return descriptor;
  }
  public void addPhoneNumberDescriptor(boolean methodAccess) {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(PhoneNumber.class);

    XMLDirectMapping numberMapping = new XMLDirectMapping();
    numberMapping.setAttributeName("number");
    numberMapping.setXPath("text()");
    descriptor.addMapping(numberMapping);

    XMLInverseReferenceMapping owningEmployee = new XMLInverseReferenceMapping();
    owningEmployee.setReferenceClass(Employee.class);
    owningEmployee.setMappedBy("phoneNumbers");
    owningEmployee.setAttributeName("owningEmployee");
    if (methodAccess) {
      owningEmployee.setSetMethodName("setOwningEmployee");
      owningEmployee.setGetMethodName("getOwningEmployee");
    }
    descriptor.addMapping(owningEmployee);

    this.addDescriptor(descriptor);
  }
  public ClassDescriptor buildXMLLoginConfigDescriptor() {
    ClassDescriptor descriptor = super.buildXMLLoginConfigDescriptor();

    XMLDirectMapping equalNamespaceResolversMapping = new XMLDirectMapping();
    equalNamespaceResolversMapping.setAttributeName("m_equalNamespaceResolvers");
    equalNamespaceResolversMapping.setGetMethodName("getEqualNamespaceResolvers");
    equalNamespaceResolversMapping.setSetMethodName("setEqualNamespaceResolvers");
    equalNamespaceResolversMapping.setXPath("equal-namespace-resolvers/text()");
    equalNamespaceResolversMapping.setNullValue(Boolean.TRUE);
    descriptor.addMapping(equalNamespaceResolversMapping);

    XMLCompositeObjectMapping documentPreservationPolicyMapping = new XMLCompositeObjectMapping();
    documentPreservationPolicyMapping.setReferenceClass(DocumentPreservationPolicyConfig.class);
    documentPreservationPolicyMapping.setAttributeName("m_documentPreservationPolicy");
    documentPreservationPolicyMapping.setGetMethodName("getDocumentPreservationPolicy");
    documentPreservationPolicyMapping.setSetMethodName("setDocumentPreservationPolicy");
    documentPreservationPolicyMapping.setXPath("document-preservation-policy");
    descriptor.addMapping(documentPreservationPolicyMapping);

    return descriptor;
  }
  private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");

    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("@id");
    descriptor.addMapping(idMapping);

    XMLCompositeDirectCollectionMapping responsibilitiesMapping =
        new XMLCompositeDirectCollectionMapping();
    responsibilitiesMapping.setAttributeName("responsibilities");
    ObjectTypeConverter objectTypeConverter = new ObjectTypeConverter(responsibilitiesMapping);
    objectTypeConverter.addConversionValue("A", "Cut the grass");
    objectTypeConverter.addConversionValue("B", "Wash the dishes");
    responsibilitiesMapping.setValueConverter(objectTypeConverter);
    responsibilitiesMapping.setXPath("responsibilities/list/responsibility/text()");
    descriptor.addMapping(responsibilitiesMapping);

    return descriptor;
  }
  public static XMLDescriptor buildDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(MWEisOneToManyMapping.class);
    descriptor.getInheritancePolicy().setParentClass(MWEisReferenceMapping.class);

    // use an object type mapping so we can preserve object identity
    ObjectTypeConverter foreignKeyLocationConverter = new ObjectTypeConverter();
    foreignKeyLocationConverter.addConversionValue(KEYS_ON_TARGET, KEYS_ON_TARGET);
    foreignKeyLocationConverter.addConversionValue(KEYS_ON_SOURCE, KEYS_ON_SOURCE);
    XMLDirectMapping foreignKeyLocationMapping = new XMLDirectMapping();
    foreignKeyLocationMapping.setAttributeName("foreignKeyLocation");
    foreignKeyLocationMapping.setXPath("foreign-key-location/text()");
    foreignKeyLocationMapping.setNullValue(KEYS_ON_SOURCE);
    foreignKeyLocationMapping.setConverter(foreignKeyLocationConverter);
    descriptor.addMapping(foreignKeyLocationMapping);

    XMLCompositeObjectMapping groupingElementMapping = new XMLCompositeObjectMapping();
    groupingElementMapping.setAttributeName("foreignKeyGroupingElement");
    groupingElementMapping.setReferenceClass(MWXmlField.class);
    groupingElementMapping.setGetMethodName("getGroupingElementForTopLink");
    groupingElementMapping.setSetMethodName("setGroupingElementForTopLink");
    groupingElementMapping.setXPath("foreign-key-grouping-element");
    descriptor.addMapping(groupingElementMapping);

    XMLCompositeObjectMapping containerPolicyMapping = new XMLCompositeObjectMapping();
    containerPolicyMapping.setAttributeName("containerPolicy");
    containerPolicyMapping.setReferenceClass(MWContainerPolicy.MWContainerPolicyRoot.class);
    containerPolicyMapping.setXPath("container-policy");
    descriptor.addMapping(containerPolicyMapping);

    XMLCompositeObjectMapping deleteAllInteractionMapping = new XMLCompositeObjectMapping();
    deleteAllInteractionMapping.setAttributeName("deleteAllInteraction");
    deleteAllInteractionMapping.setReferenceClass(MWEisInteraction.class);
    deleteAllInteractionMapping.setXPath("delete-all-interaction");
    descriptor.addMapping(deleteAllInteractionMapping);

    return descriptor;
  }
  private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(
        org.eclipse.persistence.testing.oxm.mappings.transformation.Employee.class);
    xmlDescriptor.setDefaultRootElement("ns:root");

    XMLSchemaURLReference schemaReference = new XMLSchemaURLReference();
    URL url = ClassLoader.getSystemResource(XML_SCHEMA_RESOURCE);
    schemaReference.setURL(url);
    xmlDescriptor.setSchemaReference(schemaReference);

    NamespaceResolver nsResolver = new NamespaceResolver();
    nsResolver.put("ns", "ElemDecl/maxOccurs");
    nsResolver.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    xmlDescriptor.setNamespaceResolver(nsResolver);

    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setXPath("ns:Local");
    xmlDescriptor.addMapping(nameMapping);

    return xmlDescriptor;
  }
 @SuppressWarnings("unchecked")
 @Override
 public void handleSqlType(String sqlTypeName, int typecode, String targetTypeName) {
   if (!stac.isEmpty()) {
     ListenerHelper listenerHelper = stac.pop();
     if (listenerHelper.isAttribute()) {
       AttributeFieldHelper attributeFieldHelper = (AttributeFieldHelper) listenerHelper;
       attributeFieldHelper.setSqlTypeName(sqlTypeName);
       String fieldName = attributeFieldHelper.attributeFieldName();
       String attributeName = fieldName.toLowerCase();
       ListenerHelper listenerHelper2 = stac.peek();
       if (listenerHelper2.isObject()) {
         ObjectTypeHelper objectTypeHelper = (ObjectTypeHelper) listenerHelper2;
         XMLDescriptor xdesc = descriptorMap.get(objectTypeHelper.objectTypename());
         DatabaseMapping dm = xdesc.getMappingForAttributeName(attributeName);
         if (dm == null) {
           XMLDirectMapping fieldMapping = new XMLDirectMapping();
           fieldMapping.setAttributeName(attributeName);
           XMLField xField = new XMLField(attributeName + "/text()");
           xField.setRequired(true);
           QName qnameFromDatabaseType = qnameFromDatabaseType(listenerHelper);
           xField.setSchemaType(qnameFromDatabaseType);
           // special case to avoid Calendar problems
           if (qnameFromDatabaseType == DATE_QNAME) {
             fieldMapping.setAttributeClassification(java.sql.Date.class);
             xField.addXMLConversion(DATE_QNAME, java.sql.Date.class);
             xField.addJavaConversion(java.sql.Date.class, DATE_QNAME);
             xdesc.getNamespaceResolver().put(SCHEMA_PREFIX, W3C_XML_SCHEMA_NS_URI);
           } else {
             Class attributeClass =
                 (Class) XMLConversionManager.getDefaultXMLTypes().get(qnameFromDatabaseType);
             if (attributeClass == null) {
               attributeClass = Object_Class;
             }
             fieldMapping.setAttributeClassification(attributeClass);
           }
           fieldMapping.setField(xField);
           AbstractNullPolicy nullPolicy = fieldMapping.getNullPolicy();
           nullPolicy.setNullRepresentedByEmptyNode(false);
           nullPolicy.setMarshalNullRepresentation(XSI_NIL);
           nullPolicy.setNullRepresentedByXsiNil(true);
           fieldMapping.setNullPolicy(nullPolicy);
           xdesc
               .getNamespaceResolver()
               .put(
                   SCHEMA_INSTANCE_PREFIX,
                   W3C_XML_SCHEMA_INSTANCE_NS_URI); // to support xsi:nil policy
           xdesc.addMapping(fieldMapping);
         }
         // last attribute, pop ObjectTypeHelper off stack
         int numAttributes = objectTypeHelper.decrNumAttributes();
         if (numAttributes == 0) {
           stac.pop();
         }
       } else if (listenerHelper2.isArray()) {
         SqlArrayTypeHelper sqlArrayTypeHelper = (SqlArrayTypeHelper) listenerHelper2;
         XMLDescriptor xdesc = descriptorMap.get(sqlArrayTypeHelper.arrayTypename());
         DatabaseMapping dm = xdesc.getMappingForAttributeName(attributeName);
         if (dm == null) {
           XMLCompositeDirectCollectionMapping dirCollectMapping =
               new XMLCompositeDirectCollectionMapping();
           SqltypeHelper componentType = new SqltypeHelper(sqlTypeName);
           dirCollectMapping.setAttributeElementClass(
               attributeClassFromDatabaseType((DefaultListenerHelper) componentType));
           dirCollectMapping.setAttributeName(attributeName);
           dirCollectMapping.setUsesSingleNode(true);
           dirCollectMapping.setXPath(attributeName + "/text()");
           XMLField xField = (XMLField) dirCollectMapping.getField();
           xField.setRequired(true);
           xField.setSchemaType(qnameFromDatabaseType(componentType));
           dirCollectMapping.useCollectionClassName("java.util.ArrayList");
           AbstractNullPolicy nullPolicy = dirCollectMapping.getNullPolicy();
           nullPolicy.setNullRepresentedByEmptyNode(false);
           nullPolicy.setMarshalNullRepresentation(XSI_NIL);
           nullPolicy.setNullRepresentedByXsiNil(true);
           dirCollectMapping.setNullPolicy(nullPolicy);
           xdesc
               .getNamespaceResolver()
               .put(
                   SCHEMA_INSTANCE_PREFIX,
                   W3C_XML_SCHEMA_INSTANCE_NS_URI); // to support xsi:nil policy
           xdesc.addMapping(dirCollectMapping);
         }
       }
     } else if (listenerHelper.isArray()) {
       SqlArrayTypeHelper sqlArrayTypeHelper2 = (SqlArrayTypeHelper) listenerHelper;
       XMLDescriptor xdesc = descriptorMap.get(sqlArrayTypeHelper2.arrayTypename());
       DatabaseMapping dm = xdesc.getMappingForAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME);
       if (dm == null) {
         XMLCompositeDirectCollectionMapping itemsMapping =
             new XMLCompositeDirectCollectionMapping();
         SqltypeHelper componentType = new SqltypeHelper(sqlTypeName);
         itemsMapping.setAttributeElementClass(
             attributeClassFromDatabaseType((DefaultListenerHelper) componentType));
         itemsMapping.setAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME);
         itemsMapping.setUsesSingleNode(true);
         itemsMapping.setXPath(ITEM_MAPPING_NAME + "/text()");
         XMLField xField = (XMLField) itemsMapping.getField();
         xField.setRequired(true);
         xField.setSchemaType(qnameFromDatabaseType(componentType));
         itemsMapping.useCollectionClassName("java.util.ArrayList");
         AbstractNullPolicy nullPolicy = itemsMapping.getNullPolicy();
         nullPolicy.setNullRepresentedByEmptyNode(false);
         nullPolicy.setMarshalNullRepresentation(XSI_NIL);
         nullPolicy.setNullRepresentedByXsiNil(true);
         itemsMapping.setNullPolicy(nullPolicy);
         xdesc
             .getNamespaceResolver()
             .put(
                 SCHEMA_INSTANCE_PREFIX,
                 W3C_XML_SCHEMA_INSTANCE_NS_URI); // to support xsi:nil policy
         xdesc.addMapping(itemsMapping);
       }
       ListenerHelper listenerHelper2 = stac.peek();
       if (listenerHelper2.isAttribute()) {
         // type built above used in field definition of object further up stack
         stac.pop();
         AttributeFieldHelper fieldHelper = (AttributeFieldHelper) listenerHelper2;
         ListenerHelper listenerHelper3 = stac.peek();
         if (listenerHelper3.isObject()) {
           ObjectTypeHelper objectTypeHelper = (ObjectTypeHelper) listenerHelper3;
           XMLDescriptor xdesc2 = descriptorMap.get(objectTypeHelper.objectTypename());
           String fieldName = fieldHelper.attributeFieldName();
           DatabaseMapping dm2 = xdesc2.getMappingForAttributeName(fieldName.toLowerCase());
           if (dm2 == null) {
             XMLCompositeDirectCollectionMapping fieldMapping =
                 new XMLCompositeDirectCollectionMapping();
             SqltypeHelper componentType = new SqltypeHelper(sqlTypeName);
             fieldMapping.setAttributeElementClass(
                 attributeClassFromDatabaseType((DefaultListenerHelper) componentType));
             fieldMapping.setAttributeName(fieldName.toLowerCase());
             XMLField field =
                 new XMLField(fieldName.toLowerCase() + "/" + ITEM_MAPPING_NAME + "/text()");
             field.setRequired(true);
             fieldMapping.setField(field);
             field.setSchemaType(qnameFromDatabaseType(componentType));
             fieldMapping.useCollectionClassName("java.util.ArrayList");
             AbstractNullPolicy nullPolicy = fieldMapping.getNullPolicy();
             nullPolicy.setNullRepresentedByEmptyNode(false);
             nullPolicy.setMarshalNullRepresentation(XSI_NIL);
             nullPolicy.setNullRepresentedByXsiNil(true);
             fieldMapping.setNullPolicy(nullPolicy);
             xdesc2
                 .getNamespaceResolver()
                 .put(
                     SCHEMA_INSTANCE_PREFIX,
                     W3C_XML_SCHEMA_INSTANCE_NS_URI); // to support xsi:nil policy
             xdesc2.addMapping(fieldMapping);
           }
           // last attribute, pop ObjectTypeHelper off stack
           int numAttributes = objectTypeHelper.decrNumAttributes();
           if (numAttributes == 0) {
             stac.pop();
           }
         }
       }
     }
   }
 }