gpt4 book ai didi

com.google.gdata.util.common.xml.XmlNamespace类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 18:24:40 25 4
gpt4 key购买 nike

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

XmlNamespace介绍

[英]Represents an XML namespace, including the associated namespace URI and an optional alias prefix to use in XML output.
[中]表示XML名称空间,包括关联的名称空间URI和在XML输出中使用的可选别名前缀。

代码示例

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/** SAX callback. */
@Override
public void startPrefixMapping(String alias, String uri) {
 Stack<NamespaceDecl> mapping = namespaceMap.get(alias);
 if (mapping == null) {
  mapping = new Stack<NamespaceDecl>();
  namespaceMap.put(alias, mapping);
 }
 XmlNamespace ns = new XmlNamespace(alias, uri);
 NamespaceDecl nsDecl = new NamespaceDecl(ns);
 mapping.push(nsDecl);
 elementNamespaces.add(ns);
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/**
 * Returns {@code true} if this qname has a namespace value that will match
 * any namespace.
 *
 * @see ANY_NAMESPACE
 */
public boolean matchesAnyNamespace() {
 return ANY_NAMESPACE.equals(namespace);
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/**
 * Returns the namespace URI associated with a given namespace alias.
 *
 * @param     nsAlias namespace alias, or {@code null} for default namespace.
 * @return    namespace URI, or {@code null} if not found.
 */
protected String getNamespaceUri(String nsAlias) {
 if (nsAlias == null) {
  return defaultNamespace;
 }
 // Walk the stack from the top to find an element with this ns alias.
 for (int i = elementStack.size() - 1; i >= 0; --i) {
  Element element = elementStack.get(i);
  for (XmlNamespace ns : element.nsDecls) {
   if (ns.getAlias().equals(nsAlias)) {
    return ns.getUri();
   }
  }
 }
 return null;
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/** Ensures that the namespace from the QName is stored with the blob. */
private void ensureBlobNamespace(ElementHandler handler, String qName) {
 // Get the namespace.
 NamespaceDecl nsDecl = null;
 String alias = qName.substring(0, Math.max(0, qName.indexOf(":")));
 if (alias.equals("xml")) {
  // "xml:" doesn't need a declaration.
  return;
 }
 Stack<NamespaceDecl> mapping = namespaceMap.get(alias);
 if (mapping != null) {
  nsDecl = mapping.peek();
 }
 // The namespace might be null for a namespace-less element.
 assert alias.length() == 0 || nsDecl != null :
  "Namespace alias '" + alias + "' should be mapped in 'namespaceMap'.";
 // Make sure the namespace is described within the blob if it was
 // originally declared externally to it
 if (nsDecl != null && !nsDecl.inBlob && nsDecl.ns != null &&
   !handler.blobNamespaces.contains(alias)) {
  handler.blobNamespaces.add(alias);
  handler.xmlBlob.getNamespaces().add(
    new XmlNamespace(alias, nsDecl.ns.getUri()));
 }
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

namespaces.add(new XmlNamespace(blobNs.getAlias(),
                blobNs.getUri()));

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
 * Defines a natural ordering for ExtensionDescription based upon
 * the qualified name of the mapped XML element.  Elements with no
 * namespace are considered to precede all others.
 */
public int compareTo(ExtensionDescription desc) {
 String ns1 = namespace.getUri();
 if (ns1 == null) {
  ns1 = "";
 }
 String ns2 = desc.namespace.getUri();
 if (ns2 == null) {
  ns2 = "";
 }
 int nscomp = ns1.compareTo(ns2);
 if (nscomp != 0) {
  return nscomp;
 }
 return localName.compareTo(desc.localName);
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

public int compareTo(QName o) {

  if (getNs() == null) {
   if (o.getNs() != null) {
    return -1;
   }
  } else {
   if (o.getNs() == null) {
    return 1;
   }
   int result = getNs().getUri().compareTo(o.getNs().getUri());
   if (result != 0) {
    if (ANY_NAMESPACE.equals(o.getNs())) {
     return -1;
    }
    return result;
   }
  }
  String localName = getLocalName();
  int compare = localName.compareTo(o.getLocalName());
  if (compare != 0 && ANY_LOCALNAME.equals(localName)) {
   return -1;
  }
  return compare;
 }
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

@Override
public String toString() {
 if (getNs() == null || "".equals(getNs().getAlias())) {
  return getLocalName();
 }
 return getNs().getAlias() + ":" + getLocalName();
}

代码示例来源:origin: com.google.gdata/gdata-java-client

namespaces.add(new XmlNamespace(blobNs.getAlias(),
                blobNs.getUri()));

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/**
 * Defines a natural ordering for ExtensionDescription based upon
 * the qualified name of the mapped XML element.  Elements with no
 * namespace are considered to precede all others.
 */
public int compareTo(ExtensionDescription desc) {
 String ns1 = namespace.getUri();
 if (ns1 == null) {
  ns1 = "";
 }
 String ns2 = desc.namespace.getUri();
 if (ns2 == null) {
  ns2 = "";
 }
 int nscomp = ns1.compareTo(ns2);
 if (nscomp != 0) {
  return nscomp;
 }
 return localName.compareTo(desc.localName);
}

代码示例来源:origin: com.google.gdata/gdata-java-client

public int compareTo(QName o) {

  if (getNs() == null) {
   if (o.getNs() != null) {
    return -1;
   }
  } else {
   if (o.getNs() == null) {
    return 1;
   }
   int result = getNs().getUri().compareTo(o.getNs().getUri());
   if (result != 0) {
    if (ANY_NAMESPACE.equals(o.getNs())) {
     return -1;
    }
    return result;
   }
  }
  String localName = getLocalName();
  int compare = localName.compareTo(o.getLocalName());
  if (compare != 0 && ANY_LOCALNAME.equals(localName)) {
   return -1;
  }
  return compare;
 }
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

@Override
public String toString() {
 if (getNs() == null || "".equals(getNs().getAlias())) {
  return getLocalName();
 }
 return getNs().getAlias() + ":" + getLocalName();
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/** SAX callback. */
@Override
public void startPrefixMapping(String alias, String uri) {
 Stack<NamespaceDecl> mapping = namespaceMap.get(alias);
 if (mapping == null) {
  mapping = new Stack<NamespaceDecl>();
  namespaceMap.put(alias, mapping);
 }
 XmlNamespace ns = new XmlNamespace(alias, uri);
 NamespaceDecl nsDecl = new NamespaceDecl(ns);
 mapping.push(nsDecl);
 elementNamespaces.add(ns);
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

namespaces.add(new XmlNamespace(blobNs.getAlias(),
                blobNs.getUri()));

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/**
 * Returns the namespace URI associated with a given namespace alias.
 *
 * @param     nsAlias namespace alias, or {@code null} for default namespace.
 * @return    namespace URI, or {@code null} if not found.
 */
protected String getNamespaceUri(String nsAlias) {
 if (nsAlias == null) {
  return defaultNamespace;
 }
 // Walk the stack from the top to find an element with this ns alias.
 for (int i = elementStack.size() - 1; i >= 0; --i) {
  Element element = elementStack.get(i);
  for (XmlNamespace ns : element.nsDecls) {
   if (ns.getAlias().equals(nsAlias)) {
    return ns.getUri();
   }
  }
 }
 return null;
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/**
 * Defines a natural ordering for ExtensionDescription based upon
 * the qualified name of the mapped XML element.  Elements with no
 * namespace are considered to precede all others.
 */
public int compareTo(ExtensionDescription desc) {
 String ns1 = namespace.getUri();
 if (ns1 == null) {
  ns1 = "";
 }
 String ns2 = desc.namespace.getUri();
 if (ns2 == null) {
  ns2 = "";
 }
 int nscomp = ns1.compareTo(ns2);
 if (nscomp != 0) {
  return nscomp;
 }
 return localName.compareTo(desc.localName);
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

public int compareTo(QName o) {

  if (getNs() == null) {
   if (o.getNs() != null) {
    return -1;
   }
  } else {
   if (o.getNs() == null) {
    return 1;
   }
   int result = getNs().getUri().compareTo(o.getNs().getUri());
   if (result != 0) {
    if (ANY_NAMESPACE.equals(o.getNs())) {
     return -1;
    }
    return result;
   }
  }
  String localName = getLocalName();
  int compare = localName.compareTo(o.getLocalName());
  if (compare != 0 && ANY_LOCALNAME.equals(localName)) {
   return -1;
  }
  return compare;
 }
}

代码示例来源:origin: com.google.gdata/gdata-java-client

@Override
public String toString() {
 if (getNs() == null || "".equals(getNs().getAlias())) {
  return getLocalName();
 }
 return getNs().getAlias() + ":" + getLocalName();
}

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
 * Returns {@code true} if this qname has a namespace value that will match
 * any namespace.
 *
 * @see ANY_NAMESPACE
 */
public boolean matchesAnyNamespace() {
 return ANY_NAMESPACE.equals(namespace);
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/** SAX callback. */
@Override
public void startPrefixMapping(String alias, String uri) {
 Stack<NamespaceDecl> mapping = namespaceMap.get(alias);
 if (mapping == null) {
  mapping = new Stack<NamespaceDecl>();
  namespaceMap.put(alias, mapping);
 }
 XmlNamespace ns = new XmlNamespace(alias, uri);
 NamespaceDecl nsDecl = new NamespaceDecl(ns);
 mapping.push(nsDecl);
 elementNamespaces.add(ns);
}

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