org.eclipse.persistence.exceptions.XMLMarshalException.validateException()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(101)

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

XMLMarshalException.validateException介绍

暂无

代码示例

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

private void validateNode(org.w3c.dom.Node node) {
  if (getSchema() != null) {
    Validator validator = getSchema().newValidator();
    validator.setErrorHandler(getErrorHandler());
    try {
      validator.validate(new DOMSource(node));
    } catch (Exception e) {
      throw XMLMarshalException.validateException(e);
    }
  }
}

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

private void validateNode(org.w3c.dom.Node node) {
  if (getSchema() != null) {
    Validator validator = getSchema().newValidator();
    validator.setErrorHandler(getErrorHandler());
    try {
      validator.validate(new DOMSource(node));
    } catch (Exception e) {
      throw XMLMarshalException.validateException(e);
    }
  }
}

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

private void validateNode(org.w3c.dom.Node node) {
  if (getSchema() != null) {
    Validator validator = getSchema().newValidator();
    validator.setErrorHandler(getErrorHandler());
    try {
      validator.validate(new DOMSource(node));
    } catch (Exception e) {
      throw XMLMarshalException.validateException(e);
    }
  }
}

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

/**
* Validate the given object.
* @param object A single object to validate
* @return true if this is a valid object, otherwise false
*/
public boolean validate(Object object) throws XMLMarshalException {
  if (object == null) {
    throw XMLMarshalException.nullArgumentException();
  }
  try {
    // Create a new XML Record using the object's class name (not fully qualified) as the root
    String name = ((XMLDescriptor)xmlContext.getSession(object).getDescriptor(object)).getDefaultRootElement();
    if (name == null) {
      String qualifiedName = object.getClass().getName();
      int idx = qualifiedName.lastIndexOf('.');
      name = qualifiedName.substring(idx + 1);
    }
    XMLDescriptor descriptor = marshaller.getDescriptor(object);
    Root root = new Root();
    root.setObject(object);
    root.setLocalName(name);
    XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
    Document doc = xmlPlatform.createDocument();
    marshaller.marshal(root, doc);
    return xmlPlatform.validate(doc.getDocumentElement(), descriptor, getErrorHandler());
  } catch (XMLPlatformException e) {
    throw XMLMarshalException.validateException(e);
  }
}

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

/**
* Validate the given object.
* @param object A single object to validate
* @return true if this is a valid object, otherwise false
*/
public boolean validate(Object object) throws XMLMarshalException {
  if (object == null) {
    throw XMLMarshalException.nullArgumentException();
  }
  try {
    // Create a new XML Record using the object's class name (not fully qualified) as the root            
    String name = ((XMLDescriptor)xmlContext.getSession(object).getDescriptor(object)).getDefaultRootElement();
    if (name == null) {
      String qualifiedName = object.getClass().getName();
      int idx = qualifiedName.lastIndexOf('.');
      name = qualifiedName.substring(idx + 1);
    }
    XMLDescriptor descriptor = marshaller.getDescriptor(object);
    XMLRoot root = new XMLRoot();
    root.setObject(object);
    root.setLocalName(name);
    
    XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
    Document doc = xmlPlatform.createDocument();
    marshaller.marshal(root, doc);
    return xmlPlatform.validate(doc.getDocumentElement(), descriptor, getErrorHandler());
  } catch (XMLPlatformException e) {
    throw XMLMarshalException.validateException(e);
  }
}

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

/**
* Validate the given object.
* @param object A single object to validate
* @return true if this is a valid object, otherwise false
*/
public boolean validate(Object object) throws XMLMarshalException {
  if (object == null) {
    throw XMLMarshalException.nullArgumentException();
  }
  try {
    // Create a new XML Record using the object's class name (not fully qualified) as the root            
    String name = ((XMLDescriptor)xmlContext.getSession(object).getDescriptor(object)).getDefaultRootElement();
    if (name == null) {
      String qualifiedName = object.getClass().getName();
      int idx = qualifiedName.lastIndexOf('.');
      name = qualifiedName.substring(idx + 1);
    }
    XMLDescriptor descriptor = marshaller.getDescriptor(object);
    Root root = new Root();
    root.setObject(object);
    root.setLocalName(name);
    
    XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
    Document doc = xmlPlatform.createDocument();
    marshaller.marshal(root, doc);
    return xmlPlatform.validate(doc.getDocumentElement(), descriptor, getErrorHandler());
  } catch (XMLPlatformException e) {
    throw XMLMarshalException.validateException(e);
  }
}

相关文章

XMLMarshalException类方法