gpt4 book ai didi

org.eclipse.persistence.oxm.schema.XMLSchemaReference类的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 23:42:40 27 4
gpt4 key购买 nike

本文整理了Java中org.eclipse.persistence.oxm.schema.XMLSchemaReference类的一些代码示例,展示了XMLSchemaReference类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLSchemaReference类的具体详情如下:
包路径:org.eclipse.persistence.oxm.schema.XMLSchemaReference
类名称:XMLSchemaReference

XMLSchemaReference介绍

[英]Provides a way for a descriptor's reference to its schema to be specified. The schema can be reference through a classpath resource, a file or URL.
[中]提供一种方法,用于指定描述符对其架构的引用。模式可以通过类路径资源、文件或URL进行引用。

代码示例

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

if (xmlRef != null) {
  if (leafType == null) {
    if (xmlRef.getType() == XMLSchemaReference.ELEMENT) {
      return false;
      return true;
  } else if (((xmlRef.getType() == XMLSchemaReference.COMPLEX_TYPE) || (xmlRef.getType() == XMLSchemaReference.SIMPLE_TYPE)) && xmlRef.getSchemaContext() != null && xmlRef.isGlobalDefinition()) {
    QName ctxQName = xmlRef.getSchemaContextAsQName(descriptor.getNamespaceResolver());
    if (!ctxQName.equals(leafType)) {
      writeXsiTypeAttribute(descriptor, xmlRef, isRootElement);

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

private void initializeSchemas() {
  if (!schemasAreInitialized) {
    HashSet schemas = new HashSet();
    Iterator xmlDescriptors;
    XMLDescriptor xmlDescriptor;
    XMLSchemaReference xmlSchemaReference;
    int numberOfSessions = ((XMLContext) context).getSessions().size();
    for (int x = 0; x < numberOfSessions; x++) {
      xmlDescriptors = ((CoreSession)context.getSessions().get(x)).getDescriptors().values().iterator();
      URL schemaURL;
      while (xmlDescriptors.hasNext()) {
        xmlDescriptor = (XMLDescriptor)xmlDescriptors.next();
        xmlSchemaReference = xmlDescriptor.getSchemaReference();
        if (null != xmlSchemaReference) {
          schemaURL = xmlSchemaReference.getURL();
          if (null != schemaURL) {
            schemas.add(schemaURL.toString());
          }
        }
      }
    }
    schemas.remove(null);
    platformUnmarshaller.setSchemas(schemas.toArray());
    schemasAreInitialized = true;
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * <p>INTERNAL:
 */
@SuppressWarnings("rawtypes")
public void buildDescriptorIndex() {
  for (Iterator i = xrService.oxSession.getProject().getOrderedDescriptors().iterator();
    i.hasNext();) {
    XMLDescriptor xd = (XMLDescriptor)i.next();
    XMLSchemaReference schemaReference = xd.getSchemaReference();
    if (schemaReference != null && schemaReference.getType() == XMLSchemaReference.COMPLEX_TYPE) {
      String context = schemaReference.getSchemaContext();
      if (context != null && context.lastIndexOf(SLASH_CHAR) == 0) {
        String elementNameNS = context.substring(1);
        QName elementName = resolveName(elementNameNS, xd.getNamespaceResolver());
        if (elementName == null) {
          continue;
        }
        xrService.descriptorsByQName.put(elementName, xd);
      }
    }
  }
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

String schemaContext = xmlSchemaReference.getSchemaContext();
if ((xmlSchemaReference.getType() == XMLSchemaReference.COMPLEX_TYPE) || (xmlSchemaReference.getType() == XMLSchemaReference.SIMPLE_TYPE)) {
  if ((null != schemaContext) && (schemaContext.lastIndexOf('/') == 0)) {
    schemaContext = schemaContext.substring(1, schemaContext.length());
    QName qname = xmlSchemaReference.getSchemaContextAsQName();
    if (qname != null) {
      if (xmlDescriptor.isWrapper() && xmlDescriptor.getJavaClassName().contains("ObjectWrapper")) {

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

private void writeTypeAttribute(MarshalRecord marshalRecord, XMLDescriptor descriptor, String xsiPrefix) {
  //xsi:type=schemacontext
  String typeValue = descriptor.getSchemaReference().getSchemaContext();
  // handle case where the schema context is set as a QName
  if (typeValue == null) {
    QName contextAsQName = descriptor.getSchemaReference().getSchemaContextAsQName();
    if (contextAsQName == null) {
      return;
    }
    String uri = contextAsQName.getNamespaceURI();
    String localPart = contextAsQName.getLocalPart();
    String prefix = marshalRecord.getNamespaceResolver().resolveNamespaceURI(uri);
    if (prefix == null) {
      String defaultUri = marshalRecord.getNamespaceResolver().getDefaultNamespaceURI();
      if (defaultUri != null && defaultUri.equals(uri)) {
        typeValue = localPart;
      } else {
        prefix = marshalRecord.getNamespaceResolver().generatePrefix();
        marshalRecord.attribute(XMLConstants.XMLNS_URL, prefix, XMLConstants.XMLNS + XMLConstants.COLON + prefix, uri);
        typeValue = prefix + XMLConstants.COLON + localPart;
      }
    } else {
      typeValue = prefix + XMLConstants.COLON + localPart;
    }
  } else {
    typeValue = typeValue.substring(1);
  }
  marshalRecord.attribute(XMLConstants.SCHEMA_INSTANCE_URL, XMLConstants.SCHEMA_TYPE_ATTRIBUTE, xsiPrefix + XMLConstants.COLON + XMLConstants.SCHEMA_TYPE_ATTRIBUTE, typeValue);
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public void writeXsiTypeAttribute(Descriptor xmlDescriptor, XMLSchemaReference xmlRef, boolean addToNamespaceResolver) {
  QName contextAsQName = xmlRef.getSchemaContextAsQName();
  if(contextAsQName == null){
    contextAsQName = xmlRef.getSchemaContextAsQName(namespaceResolver);
  }
  if (contextAsQName != null) {
    writeXsiTypeAttribute(xmlDescriptor, contextAsQName.getNamespaceURI(), contextAsQName.getLocalPart(), null, addToNamespaceResolver);
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

defaultRootElementField.initialize();
if(schemaReference != null && schemaReference.getSchemaContext() != null && (schemaReference.getType() == XMLSchemaReference.COMPLEX_TYPE || schemaReference.getType() == XMLSchemaReference.SIMPLE_TYPE) && getDefaultRootElementType() == null){
      setDefaultRootElementType(schemaReference.getSchemaContextAsQName(getNamespaceResolver()));
    setDefaultRootElementType(schemaReference.getSchemaContextAsQName(getNamespaceResolver()));
  getSchemaReference().initialize(session);

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo

QName qName = schemaReference.getSchemaContextAsQName(entityDescriptor.getNamespaceResolver());
if(null == qName) {
  throw SDOException.sdoJaxbNoSchemaContext(entityClass);
if(entityDescriptor.getSchemaReference().getType() == XMLSchemaReference.COMPLEX_TYPE) {
  wrapperType = getTypeHelper().getType(qName.getNamespaceURI(), qName.getLocalPart());
} else {

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 */
public boolean shouldAddXsiType(XMLRecord record, ClassDescriptor aDescriptor) {
  XMLDescriptor xmlDescriptor = (XMLDescriptor) aDescriptor;
  if ((getReferenceDescriptor() == null) && (xmlDescriptor.getSchemaReference() != null)) {
    if (aDescriptor.hasInheritance()) {
      XMLField indicatorField = (XMLField) aDescriptor.getInheritancePolicy().getClassIndicatorField();
      if ((indicatorField.getLastXPathFragment().getNamespaceURI() != null) //
          && indicatorField.getLastXPathFragment().getNamespaceURI().equals(XMLConstants.SCHEMA_INSTANCE_URL) //
          && indicatorField.getLastXPathFragment().getLocalName().equals(XMLConstants.SCHEMA_TYPE_ATTRIBUTE)) {
        return false;
      }
    }
    XMLSchemaReference xmlRef = xmlDescriptor.getSchemaReference();
    if ((xmlRef.getType() == XMLSchemaReference.COMPLEX_TYPE) && xmlRef.isGlobalDefinition()) {
      QName ctxQName = xmlRef.getSchemaContextAsQName(xmlDescriptor.getNamespaceResolver());
      QName leafType = ((XMLField) getField()).getLeafElementType();
      if ((leafType == null) || (!ctxQName.equals(record.getLeafElementType()))) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

protected void addTypeAttributeIfNeeded(XMLDescriptor descriptor, DatabaseMapping mapping, MarshalRecord marshalRecord) {
  XMLSchemaReference xmlRef = descriptor.getSchemaReference();
  if (xmlCompositeCollectionMapping.shouldAddXsiType(marshalRecord, descriptor) && (xmlRef != null)) {
    addTypeAttribute(descriptor, marshalRecord, xmlRef.getSchemaContext());
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

protected ClassDescriptor buildDatabaseFieldDescriptor() {
  XMLDescriptor descriptor = new XMLDescriptor();
  descriptor.setJavaClass(DatabaseField.class);
  descriptor.setDefaultRootElement("field");
  descriptor.getInheritancePolicy().setClassIndicatorField(new XMLField("@xsi:type"));
  descriptor.getInheritancePolicy().addClassIndicator(DatabaseField.class, getSecondaryNamespaceXPath() + "column");
  descriptor.getInheritancePolicy().addClassIndicator(XMLField.class, getPrimaryNamespaceXPath() + "node");
  descriptor.getInheritancePolicy().addClassIndicator(XMLUnionField.class, getPrimaryNamespaceXPath() + "union-node");
  XMLSchemaReference reference = new XMLSchemaClassPathReference();
  reference.setSchemaContext("/"+ getSecondaryNamespaceXPath() + "column");
  descriptor.setSchemaReference(reference);
  
  XMLDirectMapping tableMapping = new XMLDirectMapping();
  tableMapping.setAttributeName("table");
  tableMapping.setGetMethodName("getTableName");
  tableMapping.setSetMethodName("setTableName");
  tableMapping.setXPath("@table");
  tableMapping.setNullValue("");
  descriptor.addMapping(tableMapping);
  XMLDirectMapping nameMapping = new XMLDirectMapping();
  nameMapping.setAttributeName("name");
  nameMapping.setGetMethodName("getName");
  nameMapping.setSetMethodName("setName");
  nameMapping.setXPath("@name");
  nameMapping.getNullPolicy().setNullRepresentedByEmptyNode(false);
  descriptor.addMapping(nameMapping);
  return descriptor;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo

schemaRef.setSchemaContext(schemaContextWithSlash);
schemaRef.setType(XMLSchemaReference.COMPLEX_TYPE);
getXmlDescriptor().setSchemaReference(schemaRef);

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Validate the given root object.
 * @param rootObject A single root object to validate
 * @return true if this is a valid object, otherwise false
 */
public boolean validateRoot(Object rootObject) throws XMLMarshalException {
  if (rootObject == null) {
    throw XMLMarshalException.nullArgumentException();
  }
  XMLDescriptor xmlDescriptor = (XMLDescriptor)xmlContext.getSession(rootObject).getDescriptor(rootObject);
  Document document = marshaller.objectToXML(rootObject, xmlDescriptor, false);
  if (xmlDescriptor.getSchemaReference() == null) {
    throw XMLMarshalException.schemaReferenceNotSet(xmlDescriptor);
  }
  return xmlDescriptor.getSchemaReference().isValid(document, getErrorHandler());
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

getInstantiationPolicy().initialize(session);
if (getSchemaReference() != null) {
  getSchemaReference().initialize(session);

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

@Override
public void writeXsiTypeAttribute(Descriptor xmlDescriptor, XMLSchemaReference xmlRef, boolean addToNamespaceResolver) {
  QName contextAsQName = xmlRef.getSchemaContextAsQName();
  
  if(contextAsQName == null){
    contextAsQName = xmlRef.getSchemaContextAsQName(namespaceResolver);
  }
  if (contextAsQName != null) {
    writeXsiTypeAttribute(xmlDescriptor, contextAsQName.getNamespaceURI(), contextAsQName.getLocalPart(), null, addToNamespaceResolver);
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

String schemaContext = xmlSchemaReference.getSchemaContext();
if ((xmlSchemaReference.getType() == XMLSchemaReference.COMPLEX_TYPE) || (xmlSchemaReference.getType() == XMLSchemaReference.SIMPLE_TYPE)) {
  if ((null != schemaContext) && (schemaContext.lastIndexOf('/') == 0)) {
    schemaContext = schemaContext.substring(1, schemaContext.length());
    if (null != descriptor.getNamespaceResolver()) {
      String uri = descriptor.getNamespaceResolver().resolveNamespacePrefix(typeFragment.getPrefix());
      if(uri == null && xmlSchemaReference.getSchemaContextAsQName() != null){
        uri = xmlSchemaReference.getSchemaContextAsQName().getNamespaceURI();
    QName qname = xmlSchemaReference.getSchemaContextAsQName();
    if (qname != null) {
      if (descriptor.isWrapper() && descriptor.getJavaClassName().contains("ObjectWrapper")) {

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

defaultRootElementField.initialize();
if(schemaReference != null && schemaReference.getSchemaContext() != null && (schemaReference.getType() == XMLSchemaReference.COMPLEX_TYPE || schemaReference.getType() == XMLSchemaReference.SIMPLE_TYPE) && getDefaultRootElementType() == null){
      setDefaultRootElementType(schemaReference.getSchemaContextAsQName(getNamespaceResolver()));
    setDefaultRootElementType(schemaReference.getSchemaContextAsQName(getNamespaceResolver()));
  getSchemaReference().initialize(session);

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.dbws

/**
 * <p>INTERNAL:
 */
@SuppressWarnings("rawtypes")
public void buildDescriptorIndex() {
  for (Iterator i = xrService.oxSession.getProject().getOrderedDescriptors().iterator();
    i.hasNext();) {
    XMLDescriptor xd = (XMLDescriptor)i.next();
    XMLSchemaReference schemaReference = xd.getSchemaReference();
    if (schemaReference != null && schemaReference.getType() == XMLSchemaReference.COMPLEX_TYPE) {
      String context = schemaReference.getSchemaContext();
      if (context != null && context.lastIndexOf(SLASH_CHAR) == 0) {
        String elementNameNS = context.substring(1);
        QName elementName = resolveName(elementNameNS, xd.getNamespaceResolver());
        if (elementName == null) {
          continue;
        }
        xrService.descriptorsByQName.put(elementName, xd);
      }
    }
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo

String schemaContext = ((SDOType)value.getType()).getXmlDescriptor().getSchemaReference().getSchemaContext();
QName schemaContextQName = ((SDOType)value.getType()).getXmlDescriptor().getSchemaReference().getSchemaContextAsQName(((SDOType)value.getType()).getXmlDescriptor().getNonNullNamespaceResolver());

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

QName qName = schemaReference.getSchemaContextAsQName(entityDescriptor.getNamespaceResolver());
if(null == qName) {
  throw SDOException.sdoJaxbNoSchemaContext(entityClass);
if(entityDescriptor.getSchemaReference().getType() == XMLSchemaReference.COMPLEX_TYPE) {
  wrapperType = getTypeHelper().getType(qName.getNamespaceURI(), qName.getLocalPart());            
} else {

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com