本文整理了Java中org.eclipse.persistence.exceptions.XMLMarshalException
类的一些代码示例,展示了XMLMarshalException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLMarshalException
类的具体详情如下:
包路径:org.eclipse.persistence.exceptions.XMLMarshalException
类名称:XMLMarshalException
[英]Purpose: XMLMarshalExceptions are raised when issues are encountered during XMLMarshaller or XMLUnmarshaller operations.
[中]目的:在XMLMarshaller或XMLUnmarshaller操作期间遇到问题时,会引发XMLMarshaller异常。
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public void defaultNamespaceDeclaration(String defaultNamespace){
try{
xmlStreamWriter.writeDefaultNamespace(defaultNamespace);
} catch(XMLStreamException e) {
throw XMLMarshalException.marshalException(e);
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.moxy
private JAXBException handleXMLMarshalException(XMLMarshalException xmlMarshalException) {
if(xmlMarshalException.getErrorCode() == XMLMarshalException.NULL_ARGUMENT) {
throw new IllegalArgumentException(xmlMarshalException);
} else {
return new UnmarshalException(xmlMarshalException);
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* PUBLIC:
* Read and parse the XML document from the url and map the XML data into an object.
* The url must reference a valid XML document, and be mapped by a project used to
* create the XMLContext.
* @param url The url to unmarshal from
* @param clazz The type of object to return.
* @return the object which resulted from unmarshalling the given url
* @throws XMLMarshalException if an error occurred during unmarshalling
*/
public Object unmarshal(URL url, Class clazz) throws XMLMarshalException {
if ((null == url) || (null == clazz)) {
throw XMLMarshalException.nullArgumentException();
}
return platformUnmarshaller.unmarshal(url, clazz);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
private void handleXMLMarshalException(XMLMarshalException xmlException) throws IOException {
if(xmlException.getErrorCode() == XMLMarshalException.NO_DESCRIPTOR_WITH_MATCHING_ROOT_ELEMENT || xmlException.getErrorCode() == XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT){
throw SDOException.globalPropertyNotFound();
} else if (xmlException.getCause() instanceof IOException) {
throw (IOException) xmlException.getCause();
} else{
throw xmlException;
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public static XMLMarshalException unmappedContentHandlerDoesntImplement(Exception nestedException, String className) {
Object[] args = { className };
XMLMarshalException exception = new XMLMarshalException(ExceptionMessageGenerator.buildMessage(XMLMarshalException.class, UNMAPPED_CONTENTHANDLER_DOESNT_IMPLEMENT, args), nestedException);
exception.setErrorCode(UNMAPPED_CONTENTHANDLER_DOESNT_IMPLEMENT);
exception.setInternalException(nestedException);
return exception;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public static XMLMarshalException nullArgumentException() {
Object[] args = { };
XMLMarshalException exception = new XMLMarshalException(ExceptionMessageGenerator.buildMessage(XMLMarshalException.class, NULL_ARGUMENT, args));
exception.setErrorCode(NULL_ARGUMENT);
return exception;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* INTERNAL:
* Return the namespace uri for the prefix of the given local name
*/
private String resolveNamespace(NamespaceResolver namespaceResolver, String localName) {
int colonIndex = localName.indexOf(':');
if (colonIndex < 0) {
// handle target/default namespace
if (namespaceResolver != null) {
return namespaceResolver.resolveNamespacePrefix(Constants.EMPTY_STRING);
}
return null;
} else {
if (namespaceResolver == null) {
//throw an exception if the name has a : in it but the namespaceresolver is null
throw XMLMarshalException.namespaceResolverNotSpecified(localName);
}
String prefix = localName.substring(0, colonIndex);
String uri = namespaceResolver.resolveNamespacePrefix(prefix);
if (uri == null) {
//throw an exception if the prefix is not found in the namespaceresolver
throw XMLMarshalException.namespaceNotFound(prefix);
}
return uri;
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
writerRecord.flush();
}catch(XMLMarshalException xme){
if(xme.getErrorCode() == XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT){
if(aHelperContext != ((SDOType)rootObject.getType()).getHelperContext()){
throw SDOException.dataObjectNotFromHelperContext();
writer.flush();
} catch(IOException ex) {
throw XMLMarshalException.marshalException(ex);
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
private EclipseLinkException convertSAXException(SAXException saxException) {
Exception internalException = saxException.getException();
if (internalException != null) {
if (EclipseLinkException.class.isAssignableFrom(internalException.getClass())) {
return (EclipseLinkException) internalException;
} else {
return XMLMarshalException.unmarshalException(internalException);
}
}
return XMLMarshalException.unmarshalException(saxException);
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
unmarshalRecord = xmlUnmarshaller.createUnmarshalRecord(xmlDescriptor, session);
} catch (XMLMarshalException xme) {
if (xme.getErrorCode() == XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT) {
isPrimitiveWrapper = isPrimitiveWrapper(clazz);
if (isPrimitiveWrapper) {
throw XMLMarshalException.unmarshalException(e);
} catch (SAXException e) {
throw convertSAXException(e);
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public SAXUnmarshaller(Unmarshaller xmlUnmarshaller, Map<String, Boolean> parserFeatures) throws XMLMarshalException {
super();
this.parserFeatures = parserFeatures;
try {
this.xmlUnmarshaller = xmlUnmarshaller;
} catch (Exception e) {
throw XMLMarshalException.errorInstantiatingSchemaPlatform(e);
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Return the descriptor for the root object.
*/
private XMLDescriptor getDescriptor(Class clazz, AbstractSession session) throws XMLMarshalException {
XMLDescriptor descriptor = (XMLDescriptor) session.getDescriptor(clazz);
if (descriptor == null) {
throw XMLMarshalException.descriptorNotFoundInProject(clazz.getName());
}
return descriptor;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
protected AbstractRecord buildCompositeRow(Object attributeValue, AbstractSession session, XMLDescriptor referenceDescriptor, AbstractRecord parentRow, DatabaseField field, Object originalObject, boolean wasXMLRoot) {
String defaultRootElementString = null;
if(referenceDescriptor != null){
defaultRootElementString = referenceDescriptor.getDefaultRootElement();
if (!wasXMLRoot && defaultRootElementString == null) {
throw XMLMarshalException.defaultRootElementNotSpecified((XMLDescriptor) descriptor);
}
}
if ((field == null) && (referenceDescriptor != null) && (defaultRootElementString != null)) {
field = referenceDescriptor.buildField(defaultRootElementString);
}
if ((field != null) && (referenceDescriptor != null)) {
((XMLRecord) parentRow).setLeafElementType(referenceDescriptor.getDefaultRootElementType());
XMLObjectBuilder objectBuilder = (XMLObjectBuilder) referenceDescriptor.getObjectBuilder();
XMLRecord child = (XMLRecord) objectBuilder.createRecordFor(attributeValue, (XMLField) field, (XMLRecord) parentRow, this);
child.setNamespaceResolver(((XMLRecord) parentRow).getNamespaceResolver());
objectBuilder.buildIntoNestedRow(child, originalObject, attributeValue, session, referenceDescriptor, (XMLField) field, wasXMLRoot);
return child;
}
return null;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo
/**
* Return a QName representing the value of the xsi:type attribute or null if one is not present
*/
private QName getTypeAttributeQName(Attributes atts) {
int attributeSize = atts.getLength();
for (int i = 0; i < attributeSize; i++) {
String stringValue = atts.getValue(i);
String uri = atts.getURI(i);
String attrName = atts.getLocalName(i);
if (javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI.equals(uri) && XMLConstants.SCHEMA_TYPE_ATTRIBUTE.equals(attrName)) {
int colonIndex = stringValue.indexOf(':');
String localPrefix = stringValue.substring(0, colonIndex);
String localURI = unmarshalNamespaceResolver.getNamespaceURI(localPrefix);
if (localURI != null) {
String localName = stringValue.substring(colonIndex + 1, stringValue.length());
QName theQName = new QName(localURI, localName);
currentSchemaType = theQName;
return theQName;
} else {
throw XMLMarshalException.namespaceNotFound(localPrefix);
}
}
}
return null;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
final XMLMarshalException e = XMLMarshalException.missingIDForIDRef(
Object.class.getName(), primaryKey.getPrimaryKey());
if (handler != null) {
final SAXParseException saxParseException = new SAXParseException(e.getLocalizedMessage(), null, e);
try {
handler.warning(saxParseException);
final XMLMarshalException e = XMLMarshalException.missingIDForIDRef(
referenceTargetClass.getName(), primaryKey.getPrimaryKey());
if (handler != null) {
SAXParseException saxParseException = new SAXParseException(e.getLocalizedMessage(), null, e);
try {
handler.warning(saxParseException);
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* INTERNAL:
* Exception when an XMLMarshalException happens
*/
public static SDOException xmlMarshalExceptionOccurred(XMLMarshalException nestedException, String rootElementURI, String rootElementName) {
Object[] args = { nestedException.getLocalizedMessage(), rootElementURI, rootElementName};
SDOException exception = new SDOException(ExceptionMessageGenerator.buildMessage(SDOException.class, XMLMARSHAL_EXCEPTION_OCCURRED, args), nestedException);
exception.setErrorCode(XMLMARSHAL_EXCEPTION_OCCURRED);
return exception;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public static XMLMarshalException errorProcessingIDResolver(String methodName, Object resolver, Throwable nestedException) {
Object[] args = {methodName, resolver};
XMLMarshalException exception = new XMLMarshalException(ExceptionMessageGenerator.buildMessage(XMLMarshalException.class, ERROR_PROCESSING_ID_RESOLVER, args));
exception.setErrorCode(ERROR_PROCESSING_ID_RESOLVER);
exception.setInternalException(nestedException);
return exception;
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Return the namespace uri for the prefix of the given local name
*/
private String resolveNamespace(NamespaceResolver namespaceResolver, String localName) {
int colonIndex = localName.indexOf(':');
if (colonIndex < 0) {
// handle target/default namespace
if (namespaceResolver != null) {
return namespaceResolver.resolveNamespacePrefix(XMLConstants.EMPTY_STRING);
}
return null;
} else {
if (namespaceResolver == null) {
//throw an exception if the name has a : in it but the namespaceresolver is null
throw XMLMarshalException.namespaceResolverNotSpecified(localName);
}
String prefix = localName.substring(0, colonIndex);
String uri = namespaceResolver.resolveNamespacePrefix(prefix);
if (uri == null) {
//throw an exception if the prefix is not found in the namespaceresolver
throw XMLMarshalException.namespaceNotFound(prefix);
}
return uri;
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public static XMLMarshalException errorInvokingPrefixMapperMethod(String methodName, Object prefixMapper) {
Object[] args = {methodName, prefixMapper};
XMLMarshalException exception = new XMLMarshalException(ExceptionMessageGenerator.buildMessage(XMLMarshalException.class, ERROR_INVOKING_NAMESPACE_PREFIX_MAPPER, args));
exception.setErrorCode(ERROR_INVOKING_NAMESPACE_PREFIX_MAPPER);
return exception;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo
writerRecord.flush();
}catch(XMLMarshalException xme){
if(xme.getErrorCode() == XMLMarshalException.DESCRIPTOR_NOT_FOUND_IN_PROJECT){
if(aHelperContext != ((SDOType)rootObject.getType()).getHelperContext()){
throw SDOException.dataObjectNotFromHelperContext();
writer.flush();
} catch(IOException ex) {
throw XMLMarshalException.marshalException(ex);
内容来源于网络,如有侵权,请联系作者删除!