gpt4 book ai didi

org.eclipse.persistence.platform.xml.XMLPlatform类的使用及代码示例

转载 作者:知者 更新时间:2024-03-21 03:11:05 35 4
gpt4 key购买 nike

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

XMLPlatform介绍

暂无

代码示例

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

public Document getInitializedDocument() throws SAXException {
  if (document == null) {
    try {
      document = xmlPlatform.createDocument();
      nodes.add(document);
    } catch (Exception e) {
      throw new SAXException(e);
    }
  }
  return document;
}

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

/**
 * Set the XML from an XML reader.
 */
public void transformFromXML(Reader reader) {
  XMLParser parser = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLParser();
  Document document = parser.parse(reader);
  setDOM(document.getDocumentElement());
}

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

private static InputSource createInputSourceFromSource(Source aSource) {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  StreamResult result = new StreamResult(baos);
  XMLTransformer t = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLTransformer();
  t.transform(aSource, result);
  ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
  InputSource inputSource = new InputSource(bais);
  inputSource.setSystemId(aSource.getSystemId());
  return inputSource;
}

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

public DirectToXMLTypeMapping() {
  super();
  this.xmlTransformer = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLTransformer();
  this.xmlTransformer.setFormattedOutput(false);
  this.xmlParser = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLParser();
  this.xmlComparer = new XMLComparer();
}

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

public String getDefaultNamespaceURI() {
  if(null != defaultNamespaceURI) {
    return defaultNamespaceURI;
  } else if(dom != null) {
    return XMLPlatformFactory.getInstance().getXMLPlatform().resolveNamespacePrefix(dom, null);
  }
  return null;
}

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

public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, AbstractSession executionSession) {
  Object value = ((DOMRecord)row).getIndicatingNoEntry(this.getField(), true);
  if (value instanceof Element) {
    XMLPlatformFactory.getInstance().getXMLPlatform().namespaceQualifyFragment((Element)value);
  }
  return value;
}

代码示例来源: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: org.eclipse.persistence/org.eclipse.persistence.core

private XMLParser getXMLParser() {
  if (xmlParser == null || shouldReset) {
    XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
    xmlPlatform.setDisableSecureProcessing(isSecureProcessingDisabled());
    xmlParser = xmlPlatform.newXMLParser();
    xmlParser.setNamespaceAware(true);
    if (null != errorHandler) {
      xmlParser.setErrorHandler(errorHandler);
    }
    if (null != entityResolver) {
      xmlParser.setEntityResolver(entityResolver);
    }
    xmlParser.setValidationMode(validationMode);
    xmlParser.setWhitespacePreserving(isWhitespacePreserving);
    shouldReset = false;
  }
  return xmlParser;
}

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

UnmarshallerHandler handler = this.xmlUnmarshaller.getUnmarshallerHandler();
XMLPlatform xmlPlat = XMLPlatformFactory.getInstance().getXMLPlatform();
xmlPlat.setDisableSecureProcessing(isSecureProcessingDisabled());
XMLTransformer transformer = xmlPLatform.newXMLTransformer();
SAXResult result = new SAXResult(handler);
transformer.transform(source, result);

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

public boolean isValid(Document document, ErrorHandler errorHandler) {
  try {
    XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
    return xmlPlatform.validateDocument(document, getURL(), errorHandler);
  } catch (XMLPlatformException e) {
    if (e.getErrorCode() == XMLPlatformException.XML_PLATFORM_PARSER_ERROR_RESOLVING_XML_SCHEMA) {
      throw XMLMarshalException.errorResolvingXMLSchema(e);
    } else {
      return false;
    }
  }
}

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

public NodeList selectNodes(Node contextNode, XML_FIELD xmlField, XMLNamespaceResolver xmlNamespaceResolver, AbstractNullPolicy nullPolicy, boolean omitText, boolean concatinateTextNodes) {
  try {
    if (contextNode == null) {
      return null;
    }
    XPathFragment xPathFragment = xmlField.getXPathFragment();
    // allow the platform to handle the advanced case
    if (xPathFragment.shouldExecuteSelectNodes()) {
      return xmlPlatform.selectNodesAdvanced(contextNode, xmlField.getXPath(), xmlNamespaceResolver);
    }
    return selectNodes(contextNode, xPathFragment, xmlNamespaceResolver, nullPolicy, omitText, concatinateTextNodes);
  } catch (Exception x) {
    throw XMLMarshalException.invalidXPathString(xmlField.getXPath(), x);
  }
}

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

return xmlPlatform.selectSingleNodeAdvanced(contextNode, xmlField.getXPath(), xmlNamespaceResolver);

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

public String resolveNamespacePrefix(String prefix) {
  XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
  return xmlPlatform.resolveNamespacePrefix(currentNode, prefix);
}

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

public DirectToXMLTypeMapping() {
  super();
  this.xmlTransformer = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLTransformer();
  this.xmlTransformer.setFormattedOutput(false);
  this.xmlParser = XMLPlatformFactory.getInstance().getXMLPlatform().newXMLParser();
  this.xmlComparer = new XMLComparer();
}

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

public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey cacheKey, AbstractSession executionSession, boolean isTargetProtected, Boolean[] wasCacheUsed) {
  DOMRecord domRecord = (DOMRecord) row;
  Object value = domRecord.getIndicatingNoEntry(this.getField(), true);
  if(value == domRecord) {
    value = domRecord.getDOM();
  }
  if (value instanceof Element) {
    XMLPlatformFactory.getInstance().getXMLPlatform().namespaceQualifyFragment((Element)value);
  }
  return value;
}

代码示例来源: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/org.eclipse.persistence.core

private XMLParser getParser() {
  if (parser == null || shouldReset) {
    XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
    xmlPlatform.setDisableSecureProcessing(isSecureProcessingDisabled());
    parser = xmlPlatform.newXMLParser(parserFeatures);
    parser.setNamespaceAware(true);
    if (errorHandler != null) {
      parser.setErrorHandler(errorHandler);
    }
    if (entityResolver != null) {
      parser.setEntityResolver(entityResolver);
    }
    if (schemas != null) {
      try {
        parser.setXMLSchemas(schemas);
      } catch (XMLPlatformException e) {
        throw XMLMarshalException.errorSettingSchemas(e, schemas);
      }
    }
    if (schema != null) {
      parser.setXMLSchema(schema);
    }
    parser.setValidationMode(validationMode);
    parser.setWhitespacePreserving(isWhitespacePreserving);
    shouldReset = false;
  }
  return parser;
}

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

public boolean isValid(Document document, ErrorHandler errorHandler) {
  try {
    XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
    return xmlPlatform.validateDocument(document, getURL(), errorHandler);
  } catch (XMLPlatformException e) {
    if (e.getErrorCode() == XMLPlatformException.XML_PLATFORM_PARSER_ERROR_RESOLVING_XML_SCHEMA) {
      throw XMLMarshalException.errorResolvingXMLSchema(e);
    } else {
      return false;
    }
  }
}

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

public NodeList selectNodes(Node contextNode, XML_FIELD xmlField, XMLNamespaceResolver xmlNamespaceResolver, AbstractNullPolicy nullPolicy, boolean omitText, boolean concatinateTextNodes) {
  try {
    if (contextNode == null) {
      return null;
    }
    XPathFragment xPathFragment = xmlField.getXPathFragment();
    // allow the platform to handle the advanced case
    if (xPathFragment.shouldExecuteSelectNodes()) {
      return xmlPlatform.selectNodesAdvanced(contextNode, xmlField.getXPath(), xmlNamespaceResolver);
    }
    return selectNodes(contextNode, xPathFragment, xmlNamespaceResolver, nullPolicy, omitText, concatinateTextNodes);
  } catch (Exception x) {
    throw XMLMarshalException.invalidXPathString(xmlField.getXPath(), x);
  }
}

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

return xmlPlatform.selectSingleNodeAdvanced(contextNode, xmlField.getXPath(), xmlNamespaceResolver);

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