gpt4 book ai didi

org.eclipse.persistence.internal.oxm.XMLConversionManager.getDefaultJavaTypes()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 12:16:40 26 4
gpt4 key购买 nike

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

XMLConversionManager.getDefaultJavaTypes介绍

暂无

代码示例

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

/**
 * @since EclipseLink 2.6.0
 * @param javaType The type you want to find a corresponding schema type for.
 * @return the schema type for the Java class.
 */
@Override
public QName schemaType(Class<?> javaType) {
   return (QName) getDefaultJavaTypes().get(javaType);
}

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

/**
 * @since EclipseLink 2.6.0
 * @param javaType The type you want to find a corresponding schema type for.
 * @return the schema type for the Java class.
 */
@Override
public QName schemaType(Class<?> javaType) {
   return (QName) getDefaultJavaTypes().get(javaType);
}

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

private boolean isPrimitiveWrapper(Class clazz){
    return  XMLConversionManager.getDefaultJavaTypes().get(clazz) != null    
    ||ClassConstants.XML_GREGORIAN_CALENDAR.isAssignableFrom(clazz)
    ||ClassConstants.DURATION.isAssignableFrom(clazz);
  }
}

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

/**
 * Return the qualified XML Schema type for a given class
 * @param javaClass The class to use as a key in the lookup
 * @return QName The qualified XML Schema type, if no corresponding match found returns null
 */
public QName getXMLType(Class javaClass) {
  if (userJavaTypes != null) {
    QName theQName = (QName)userJavaTypes.get(javaClass);
    if (theQName !=null) {
      return theQName;
    }
  }
  return (QName)XMLConversionManager.getDefaultJavaTypes().get(javaClass);
}

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

/**
 * Indicates if the javaType map contains a key equal to
 * the provided Java class' name.
 * 
 * @param jClass
 * @return
 */
private boolean isBuiltInJavaType(Class jClass) {
  return XMLConversionManager.getDefaultJavaTypes().containsKey(jClass.getName()) || jClass.getName().startsWith("java.") || jClass.getName().startsWith("javax.");
}

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

/**
   * Returns the built in Java type QName for a given Class
   *  
   * @param jClass
   * @return
   */
  private QName getBuiltInJavaType(Class jClass) {
    if (!isBuiltInJavaType(jClass)) {
      return null;
    }
    return (QName) XMLConversionManager.getDefaultJavaTypes().get(jClass.getName());
  }
}

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

private boolean isSimpleXMLRoot(XMLRoot xmlRoot) {
  Class xmlRootObjectClass = xmlRoot.getObject().getClass();
  if (XMLConversionManager.getDefaultJavaTypes().get(xmlRootObjectClass) != null || ClassConstants.List_Class.isAssignableFrom(xmlRootObjectClass) || ClassConstants.XML_GREGORIAN_CALENDAR.isAssignableFrom(xmlRootObjectClass) || ClassConstants.DURATION.isAssignableFrom(xmlRootObjectClass)) {
    return true;
  } else if(xmlRoot.getObject() instanceof org.w3c.dom.Node) {
    return true;
  }
  return false;
}

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

/**
 * INTERNAL:
 * Get the QName which the given Type corresponds to.
 * Valid types should be all the boundTypes used to create the JAXBContext.
 * If the JAXBContext was not created with the construction that takes a Type[] then
 * this will be return null.
 */
private QName getSchemaTypeForTypeMappingInfo(Type type) {
  QName name = null;
  //Check for annotation overrides
  if (type instanceof Class) {
    name = generator.getAnnotationsProcessor().getUserDefinedSchemaTypes().get(((Class) type).getName());
    if (name == null) {
      Class theClass = (Class) type;
      //Change default for byte[] to Base64 (JAXB 2.0 default)
      if (type == CoreClassConstants.ABYTE || type == CoreClassConstants.APBYTE || type == Image.class || type == Source.class || theClass.getCanonicalName().equals("javax.activation.DataHandler")) {
        name = Constants.BASE_64_BINARY_QNAME;
      } else if (type == CoreClassConstants.OBJECT) {
        name = Constants.ANY_TYPE_QNAME;
      } else if (type == CoreClassConstants.XML_GREGORIAN_CALENDAR) {
        name = Constants.ANY_SIMPLE_TYPE_QNAME;
      } else {
        name = (QName) XMLConversionManager.getDefaultJavaTypes().get(type);
      }
    }
  }
  return name;
}

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

/**
 * INTERNAL:
 * Get the QName which the given Type corresponds to.
 * Valid types should be all the boundTypes used to create the JAXBContext.
 * If the JAXBContext was not created with the construction that takes a Type[] then
 * this will be return null.
 */
private QName getSchemaTypeForTypeMappingInfo(Type type) {
  QName name = null;
  //Check for annotation overrides
  if (type instanceof Class) {
    name = generator.getAnnotationsProcessor().getUserDefinedSchemaTypes().get(((Class) type).getName());
    if (name == null) {
      Class theClass = (Class) type;
      //Change default for byte[] to Base64 (JAXB 2.0 default)
      if (type == CoreClassConstants.ABYTE || type == CoreClassConstants.APBYTE || type == Image.class || type == Source.class || theClass.getCanonicalName().equals("javax.activation.DataHandler")) {
        name = Constants.BASE_64_BINARY_QNAME;
      } else if (type == CoreClassConstants.OBJECT) {
        name = Constants.ANY_TYPE_QNAME;
      } else if (type == CoreClassConstants.XML_GREGORIAN_CALENDAR) {
        name = Constants.ANY_SIMPLE_TYPE_QNAME;
      } else {
        name = (QName) XMLConversionManager.getDefaultJavaTypes().get(type);
      }
    }
  }
  return name;
}

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

/**
 * Ensures that XSD dateTimes will always be unmarshalled as XMLGregorianCalendars, and never
 * as GregorianCalendars.  CALENDAR entries are removed from the default XMLConversionManager,
 * and replaced with XML_GREGORIAN_CALENDAR.
 */
private static void fixDateTimeConversion(DynamicJAXBContext ctx) {
  XMLConversionManager conversionManager = (XMLConversionManager) ctx.getXMLContext().getSession().getDatasourcePlatform().getConversionManager();
  Map defaultXmlTypes = conversionManager.getDefaultXMLTypes();
  defaultXmlTypes.remove(Constants.DATE_TIME_QNAME);
  defaultXmlTypes.put(Constants.DATE_TIME_QNAME, CoreClassConstants.XML_GREGORIAN_CALENDAR);
  Map defaultJavaTypes = conversionManager.getDefaultJavaTypes();
  defaultJavaTypes.remove(CoreClassConstants.CALENDAR);
  defaultJavaTypes.put(CoreClassConstants.XML_GREGORIAN_CALENDAR, Constants.DATE_TIME_QNAME);
}

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

/**
 * Ensures that XSD dateTimes will always be unmarshalled as XMLGregorianCalendars, and never
 * as GregorianCalendars.  CALENDAR entries are removed from the default XMLConversionManager,
 * and replaced with XML_GREGORIAN_CALENDAR.
 */
private static void fixDateTimeConversion(DynamicJAXBContext ctx) {
  XMLConversionManager conversionManager = (XMLConversionManager) ctx.getXMLContext().getSession().getDatasourcePlatform().getConversionManager();
  Map defaultXmlTypes = conversionManager.getDefaultXMLTypes();
  defaultXmlTypes.remove(Constants.DATE_TIME_QNAME);
  defaultXmlTypes.put(Constants.DATE_TIME_QNAME, CoreClassConstants.XML_GREGORIAN_CALENDAR);
  Map defaultJavaTypes = conversionManager.getDefaultJavaTypes();
  defaultJavaTypes.remove(CoreClassConstants.CALENDAR);
  defaultJavaTypes.put(CoreClassConstants.XML_GREGORIAN_CALENDAR, Constants.DATE_TIME_QNAME);
}

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

/**
 * Return the schema type for a given xmlfield.  If the field does not have a schema type set,
 * the attribute classification will be used if non-null.  Otherwise, ClassConstants.STRING
 * will be returned.
 * 
 * @param xmlField
 * @param attrClass
 * @param workingSchema
 * @return
 */
protected String getSchemaTypeForElement(XMLField xmlField, Class attrClass, Schema workingSchema) {
  String schemaTypeString = null;
  QName schemaType = xmlField.getSchemaType();
  if (schemaType != null) {
    schemaTypeString = getSchemaTypeString(schemaType, workingSchema);
  } else {
    if (attrClass != null && !attrClass.equals(ClassConstants.STRING)) {
      QName qName = (QName) XMLConversionManager.getDefaultJavaTypes().get(attrClass);
      if (qName != null) {
        schemaTypeString = getSchemaTypeString(qName, workingSchema);
      }
    } else {
      // default to string
      schemaTypeString = getSchemaTypeString(XMLConstants.STRING_QNAME, workingSchema);
    }
  }
  return schemaTypeString;
}

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

public JAXBElement unmarshal(XMLStreamReader streamReader, Class javaClass) throws JAXBException {
  if(null == streamReader || null == javaClass) {
    throw new IllegalArgumentException();
  }
  try {
    XMLStreamReaderReader staxReader = new XMLStreamReaderReader(xmlUnmarshaller);
    XMLStreamReaderInputSource inputSource = new XMLStreamReaderInputSource(streamReader);
    if(XMLConversionManager.getDefaultJavaTypes().get(javaClass) != null ||CoreClassConstants.XML_GREGORIAN_CALENDAR.isAssignableFrom(javaClass) ||CoreClassConstants.DURATION.isAssignableFrom(javaClass)) {
      PrimitiveContentHandler primitiveContentHandler = new PrimitiveContentHandler(javaClass);
      staxReader.setContentHandler(primitiveContentHandler);
      staxReader.parse(inputSource);
      return primitiveContentHandler.getJaxbElement();
    }
    Class classToUnmarshalTo = getClassToUnmarshalTo(javaClass);
    JAXBElement unmarshalled = validateAndBuildJAXBElement(xmlUnmarshaller.unmarshal(staxReader, inputSource, classToUnmarshalTo), javaClass); // xmlbindings + object (xmlelement) + "nomappings.SomeClass" + "jaxb.stax.EndEventRoot"
    if(classToUnmarshalTo != javaClass){
      JAXBElement returnVal = new JAXBElement(unmarshalled.getName(), javaClass, unmarshalled.getScope(), unmarshalled.getValue());
      return returnVal;
    }
    return unmarshalled;
  } catch (XMLMarshalException xmlMarshalException) {
    throw handleXMLMarshalException(xmlMarshalException); // Exception [EclipseLink-25004] cvc-maxInclusive-valid: Value '1234567' is not facet-valid with respect to maxInclusive '999999' for type 'id-type'.
  } catch (Exception e) {
    throw new JAXBException(e);
  }
}

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

@Override
public JAXBElement unmarshal(XMLStreamReader streamReader, Class javaClass) throws JAXBException {
  if(null == streamReader || null == javaClass) {
    throw new IllegalArgumentException();
  }
  try {
    XMLStreamReaderReader staxReader = new XMLStreamReaderReader(xmlUnmarshaller);
    XMLStreamReaderInputSource inputSource = new XMLStreamReaderInputSource(streamReader);
    if(XMLConversionManager.getDefaultJavaTypes().get(javaClass) != null ||CoreClassConstants.XML_GREGORIAN_CALENDAR.isAssignableFrom(javaClass) ||CoreClassConstants.DURATION.isAssignableFrom(javaClass)) {
      PrimitiveContentHandler primitiveContentHandler = new PrimitiveContentHandler(javaClass);
      staxReader.setContentHandler(primitiveContentHandler);
      staxReader.parse(inputSource);
      return primitiveContentHandler.getJaxbElement();
    }
    Class classToUnmarshalTo = getClassToUnmarshalTo(javaClass);
    JAXBElement unmarshalled = validateAndBuildJAXBElement(xmlUnmarshaller.unmarshal(staxReader, inputSource, classToUnmarshalTo), javaClass); // xmlbindings + object (xmlelement) + "nomappings.SomeClass" + "jaxb.stax.EndEventRoot"
    if(classToUnmarshalTo != javaClass){
      JAXBElement returnVal = new JAXBElement(unmarshalled.getName(), javaClass, unmarshalled.getScope(), unmarshalled.getValue());
      return returnVal;
    }
    return unmarshalled;
  } catch (XMLMarshalException xmlMarshalException) {
    throw handleXMLMarshalException(xmlMarshalException); // Exception [EclipseLink-25004] cvc-maxInclusive-valid: Value '1234567' is not facet-valid with respect to maxInclusive '999999' for type 'id-type'.
  } catch (Exception e) {
    throw new JAXBException(e);
  }
}

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

/**
 * Create and return a SimpleType for a given XMLDescriptor.
 * 
 * @param desc
 * @param workingSchema
 * @return
 */
protected SimpleType buildSimpleType(XMLDescriptor desc, Schema workingSchema, boolean global) {
  SimpleType st;
  if (global) {
    st = buildNewSimpleType(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
  } else {
    st = new SimpleType();
  }
  DatabaseMapping mapping = desc.getMappings().get(0);
  QName qname = (QName) XMLConversionManager.getDefaultJavaTypes().get(mapping.getAttributeClassification());
  String baseType = qname.getLocalPart();
  if (qname.getNamespaceURI() != null) {
    String prefix = workingSchema.getNamespaceResolver().resolveNamespaceURI(qname.getNamespaceURI());
    if (prefix == null) {
      prefix = workingSchema.getNamespaceResolver().generatePrefix();
      workingSchema.getNamespaceResolver().put(prefix, qname.getNamespaceURI());
    }
    baseType = prefix + XMLConstants.COLON + baseType;
  }
  Restriction restriction = new Restriction();
  restriction.setBaseType(baseType);
  st.setRestriction(restriction);
  return st;
}

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

QName schemaType = (QName)xmlConversionManager.getDefaultJavaTypes().get(nextMapping.getAttributeClassification());
if(schemaType != null && ((XMLField)nextMapping.getField()).getSchemaType() == null) {
  ((XMLField)nextMapping.getField()).setSchemaType(schemaType);

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

Schema schema = schemaForNamespace.get(nsKey);
QName typeAsQName = (QName) XMLConversionManager.getDefaultJavaTypes().get(tClass);
if (typeAsQName == null) {

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

QName schemaType = (QName)xmlConversionManager.getDefaultJavaTypes().get(((AbstractCompositeDirectCollectionMapping)nextMapping).getAttributeElementClass());
if(schemaType != null) {
 ((XMLField)nextMapping.getField()).setSchemaType(schemaType);

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

xmlroot.setSchemaType((QName) org.eclipse.persistence.internal.oxm.XMLConversionManager.getDefaultJavaTypes().get(elt.getDeclaredType()));

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

if (XMLConversionManager.getDefaultJavaTypes().get(referenceClass) != null ||ClassConstants.XML_GREGORIAN_CALENDAR.isAssignableFrom(referenceClass)
    ||ClassConstants.DURATION.isAssignableFrom(referenceClass)){

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