gpt4 book ai didi

org.eclipse.persistence.internal.oxm.XPathFragment类的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 05:37:05 30 4
gpt4 key购买 nike

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

XPathFragment介绍

[英]INTERNAL:

Purpose: Represents a token from an XPath statement.

For example the following XPath statment a/b[2]/text() corresponds to three XPathFragments: "a", "b[2]", and "text()".

Responsibilities:

  • Maintain name, namespace, and prefix information.
  • Maintain information about the corresponding node type.
  • Maintain index information if any. The XPathFragment corresponding to b[2] would have an index value of 2.
    [中]内部:
    用途:表示XPath语句中的标记。
    例如,下面的XPath语句a/b[2]/text()对应于三个XPathFragments:“a”、“b[2]”和“text()。
    责任:
    *维护名称、命名空间和前缀信息。
    *维护有关相应节点类型的信息。
    *维护索引信息(如有)。对应于b[2]的XPathFragment的索引值为2。

代码示例

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

public boolean equals(Object object) {
  try {
    if(null == object) {
      return false;
    } else if (this == object) {
      return true;
    }
    XPathFragment xPathFragment = (XPathFragment)object;
    return ((nameIsText && xPathFragment.nameIsText()) || (localName == xPathFragment.getLocalName()) || ((localName != null) && localName.equals(xPathFragment.getLocalName()))) && ((namespaceURI == xPathFragment.getNamespaceURI()) || ((namespaceURI != null) && namespaceURI.equals(xPathFragment.getNamespaceURI()))) && (this.indexValue == xPathFragment.getIndexValue()) && (nameIsText == xPathFragment.nameIsText());
  } catch (ClassCastException e) {
    return false;
  }
}

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

public SequencedMarshalContext(List<Setting> settings) {
  super();
  indexFragment = new XPathFragment();
  this.settings = settings;
}

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

public boolean isOwningNode(XPathFragment xPathFragment) {
   XPathFragment nextFragment = xPathFragment.getNextFragment();
   if (nextFragment == null || xmlCompositeDirectCollectionMapping.usesSingleNode()) {
     return xPathFragment.isAttribute() || xPathFragment.nameIsText();
   } else {
     return  (nextFragment != null) && (nextFragment.nameIsText() || nextFragment.isAttribute());
   }
}

代码示例来源:origin: com.sun.jersey/jersey-json

@Override
public Collection<QName> getExpectedAttributes() {
  final List<QName> attributes = new LinkedList<QName>();
  final XPathNodeWrapper currentNodeWrapper = getCurrentNodeWrapper();
  final Map<XPathFragment, XPathNode> attributeChildrenMap =
      currentNodeWrapper == null ? null :currentNodeWrapper.xPathNode.getAttributeChildrenMap();
  if (attributeChildrenMap != null) {
    for(Map.Entry<XPathFragment, XPathNode> entry : attributeChildrenMap.entrySet()) {
      attributes.add(new QName(entry.getKey().getNamespaceURI(), entry.getKey().getLocalName()));
    }
  }
  return attributes;
}

代码示例来源:origin: com.sun.jersey/jersey-json

public Map<String, EntityType> getEntitiesTypesMap(boolean isAttribute) {
  Map<String, EntityType> entitiesTypes = isAttribute ? attributeTypeMap : elementTypeMap;
  if (entitiesTypes.isEmpty()) {
    final Map<XPathFragment, XPathNode> nodeMap =
        isAttribute ? xPathNode.getAttributeChildrenMap() : xPathNode.getNonAttributeChildrenMap();
    if (nodeMap != null) {
      for(Map.Entry<XPathFragment, XPathNode> entry : nodeMap.entrySet()) {
        entitiesTypes.put(entry.getKey().getLocalName(), new EntityType(entry.getKey().getXMLField().getType()));
      }
    }
  }
  return entitiesTypes;
}

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

/**
 * Indicate if the XPathFragment is an attribute or text() node.
 */
public boolean isOwningNode(XPathFragment xPathFragment) {
  return xPathFragment.isAttribute() || xPathFragment.nameIsText();
}

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

private void initializeXPathFragment(XPathFragment xPathFragment) {    
  String localName = xPathFragment.getLocalName();
  if(localName !=null && !localName.equals(XMLConstants.EMPTY_STRING)){
    if(null == xPathFragment.getNamespaceURI()) {
      if(xPathFragment.hasNamespace()) {
        if(null == namespaceResolver) {
          throw XMLMarshalException.namespaceNotFound(xPathFragment.getShortName());
        } else {
          String uri = namespaceResolver.resolveNamespacePrefix(xPathFragment.getPrefix());
          if(null == uri && null != xPathFragment.getPrefix()) {
            throw XMLMarshalException.namespaceNotFound(xPathFragment.getShortName());
          }
          xPathFragment.setNamespaceURI(uri);
        }
      }
      else if(!xPathFragment.isAttribute() && null != namespaceResolver) {
        xPathFragment.setNamespaceURI(namespaceResolver.getDefaultNamespaceURI());
      }
    }
  }
  XPathFragment nextXPathFragment = xPathFragment.getNextFragment();
  if(null != nextXPathFragment) {
    initializeXPathFragment(nextXPathFragment);
  }
}

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

public void initialize(DatabaseMapping mapping, Session session) {
  XPathFragment fragment = associatedField.getXPathFragment();
  while(fragment.getNextFragment() != null && !(fragment.getNextFragment().nameIsText())) {
    fragment = fragment.getNextFragment();
  }
  if(fragment.hasNamespace() && associatedField.getNamespaceResolver() != null){
    String uri = associatedField.getNamespaceResolver().resolveNamespacePrefix(fragment.getPrefix());
    fragment.setNamespaceURI(uri);
  }
  this.rootFragment = fragment;
  this.mapping = mapping;
}

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

List<XPathFragment> matchingFragments = new ArrayList<XPathFragment>();
for(XPathFragment nextFragment:xpathFragments) {
  if((nextChild.getNodeType() == Node.TEXT_NODE || nextChild.getNodeType() == Node.CDATA_SECTION_NODE) && nextFragment.nameIsText()) {
    addXMLEntry(nextChild, nextFragment.getXMLField(), entries);
  } else if(nextChild.getNodeType() == Node.ATTRIBUTE_NODE && nextFragment.isAttribute()) {
    String attributeNamespaceURI = null;
    if (nextFragment.hasNamespace()) {
      attributeNamespaceURI = xmlNamespaceResolver.resolveNamespacePrefix(nextFragment.getPrefix());
    if(sameName(nextChild, nextFragment.getLocalName()) && sameNamespaceURI(nextChild, attributeNamespaceURI)) {
      addXMLEntry(nextChild, nextFragment.getXMLField(), entries);
    if(nextFragment.hasNamespace()) {
      elementNamespaceURI = xmlNamespaceResolver.resolveNamespacePrefix(nextFragment.getPrefix());
    if(sameName(nextChild, nextFragment.getLocalName()) && sameNamespaceURI(nextChild, elementNamespaceURI)) {
      if(nextFragment.getNextFragment() == null) {
        addXMLEntry(nextChild, nextFragment.getXMLField(), entries);
      } else {
        matchingFragments.add(nextFragment.getNextFragment());

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

private Node selectSingleAttribute(Node contextNode, XPathFragment xPathFragment, XMLNamespaceResolver xmlNamespaceResolver) {
  if (xPathFragment.hasNamespace()) {
    if(Node.ELEMENT_NODE == contextNode.getNodeType()) {
      String attributeNamespaceURI = xmlNamespaceResolver.resolveNamespacePrefix(xPathFragment.getPrefix());
      return contextNode.getAttributes().getNamedItemNS(attributeNamespaceURI, xPathFragment.getLocalName());
    } else {
      return null;
    }
  } else {
    if(Node.ELEMENT_NODE == contextNode.getNodeType()) {
      return contextNode.getAttributes().getNamedItem(xPathFragment.getShortName());
    } else {
      return null;
    }
  }
}

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

schemaType = schemaType.trim();
if(schemaType.length() > 0) {
  XPathFragment frag = new XPathFragment();
frag.setXPath(schemaType);
if (frag.hasNamespace()) {
  String prefix = frag.getPrefix();
  String url = unmarshalRecord.resolveNamespacePrefix(prefix);
  frag.setNamespaceURI(url);
  qname = new QName(url, frag.getLocalName());
  unmarshalRecord.setTypeQName(qname);

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

public Element createUnownedElement(Node parent, XMLField xmlField) {
  XPathFragment lastFragment = xmlField.getXPathFragment();
  while (lastFragment.getNextFragment() != null) {
    lastFragment = lastFragment.getNextFragment();
  }
  String nodeName = lastFragment.getShortName();
  String namespace = resolveNamespacePrefix(lastFragment, getNamespaceResolverForField(xmlField));
  Element elem = parent.getOwnerDocument().createElementNS(namespace, nodeName);
  if (lastFragment.isGeneratedPrefix()) {
    elem.setAttributeNS(XMLConstants.XMLNS_URL, XMLConstants.XMLNS + XMLConstants.COLON + lastFragment.getPrefix(), lastFragment.getNamespaceURI());
  }
  return elem;
}

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

/**
 * INTERNAL:
 */
public void attribute(String namespaceURI, String localName, String qName, String value) {
  XPathFragment xPathFragment = new XPathFragment();
  xPathFragment.setNamespaceURI(namespaceURI);
  xPathFragment.setAttribute(true);
  xPathFragment.setLocalName(localName);
  openStartElement(xPathFragment, namespaceResolver);
  characters(null, value, null, false, true);
  endElement(xPathFragment, namespaceResolver);
}

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

private String resolveNamespacePrefix(XPathFragment fragment, NamespaceResolver namespaceResolver) {
  try {
    if (fragment.getNamespaceURI() != null) {
      return fragment.getNamespaceURI();
    }
    if(fragment.getPrefix() == null && fragment.isAttribute()) {
      return null;
    }
    return namespaceResolver.resolveNamespacePrefix(fragment.getPrefix());
  } catch (Exception e) {
    return null;
  }
}

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

protected String getNameForFragment(XPathFragment xPathFragment) {
  if(!this.hasCustomNamespaceMapper()) {
    return xPathFragment.getShortName();
  }
  if(xPathFragment.getNamespaceURI() != null && xPathFragment.getNamespaceURI().length() > 0) {
    String prefix = this.getPrefixForFragment(xPathFragment);
    if(prefix != null && prefix.length() > 0) {
      return prefix + Constants.COLON + xPathFragment.getLocalName();
    }
  }
  return xPathFragment.getLocalName();
}

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

protected void setOrAddAttributeValue(UnmarshalRecord unmarshalRecord, Object value, XPathFragment xPathFragment, Object collection){
  if (!xmlAnyCollectionMapping.usesXMLRoot() || xPathFragment.getLocalName() == null || (xmlAnyCollectionMapping.isMixedContent() && unmarshalRecord.getTextWrapperFragment() != null && unmarshalRecord.getTextWrapperFragment().equals(xPathFragment))) {
    unmarshalRecord.addAttributeValue(this, value);
  } else {
    Root xmlRoot = unmarshalRecord.createRoot();
    xmlRoot.setNamespaceURI(xPathFragment.getNamespaceURI());
    xmlRoot.setSchemaType(unmarshalRecord.getTypeQName());
    xmlRoot.setLocalName(xPathFragment.getLocalName());
    xmlRoot.setObject(value);
    unmarshalRecord.addAttributeValue(this, xmlRoot);
  }
}

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

private Node selectSingleElement(Node contextNode, XPathFragment xPathFragment, XMLNamespaceResolver xmlNamespaceResolver) {
  Node child = contextNode.getFirstChild();
  while (null != child) {
    String elementNamespaceURI = null;
    if(xmlNamespaceResolver != null) {
      elementNamespaceURI = xmlNamespaceResolver.resolveNamespacePrefix(xPathFragment.getPrefix());
    }
    if ((child.getNodeType() == Node.ELEMENT_NODE) && sameName(child, xPathFragment.getLocalName()) && sameNamespaceURI(child, elementNamespaceURI)) {
      return child;
    }
    child = child.getNextSibling();
  }
  return null;
}

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

/**
 * INTERNAL:
 */
public void element(XPathFragment frag) {
  Element element = document.createElementNS(frag.getNamespaceURI(), frag.getShortName());
  node.appendChild(element);
}

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

/**
 * INTERNAL:
 */
public void attribute(XPathFragment xPathFragment, NamespaceResolver namespaceResolver, String value) {
  attribute(null, xPathFragment.getLocalName(), xPathFragment.getShortName(), value);
}

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

public String resolveNamespacePrefix(XPathFragment frag, NamespaceResolver resolver) {
  String resolved = frag.getNamespaceURI();
  if (resolved == null) {
    return Constants.EMPTY_STRING;
  }
  return resolved;
}

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