org.jdom2.Namespace.getURI()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(128)

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

Namespace.getURI介绍

[英]This returns the namespace URI for this Namespace.
[中]这将返回此Namespace的命名空间URI。

代码示例

代码示例来源:origin: gocd/gocd

private static boolean compareAttributeAwareConfigTag(Element e, AttributeAwareConfigTag attributeAwareConfigTag) {
  return attributeAwareConfigTag.value().equals(e.getName()) &&
      attributeAwareConfigTag.attributeValue().equals(e.getAttributeValue(attributeAwareConfigTag.attribute())) &&
      e.getNamespace().getURI().equals(attributeAwareConfigTag.namespaceURI());
}

代码示例来源:origin: gocd/gocd

public static boolean compare(Element e, Class<?> implementation, ConfigCache configCache) {
  final AttributeAwareConfigTag attributeAwareConfigTag = annotationFor(implementation, AttributeAwareConfigTag.class);
  if (attributeAwareConfigTag != null) {
    return compareAttributeAwareConfigTag(e, attributeAwareConfigTag);
  }
  ConfigTag configTag = configTag(implementation, configCache);
  return configTag.value().equals(e.getName()) && e.getNamespace().getURI().equals(configTag.namespaceURI());
}

代码示例来源:origin: org.jdom/jdom

/**
 * This returns the URI mapped to this <code>Attribute</code>'s
 * prefix. If no mapping is found, an empty <code>String</code> is
 * returned.
 *
 * @return <code>String</code> - namespace URI for this <code>Attribute</code>.
 */
public String getNamespaceURI() {
  return namespace.getURI();
}

代码示例来源:origin: org.jdom/jdom

/**
 * Returns the namespace URI mapped to this element's prefix (or the
 * in-scope default namespace URI if no prefix). If no mapping is found, an
 * empty string is returned.
 *
 * @return                     the namespace URI for this element
 */
public String getNamespaceURI() {
  return namespace.getURI();
}

代码示例来源:origin: org.jdom/jdom

@Override
public final Object getVariable(final String name, Namespace uri) {
  final Map<String, Object> vmap =
      xvariables.get(uri == null ? "" : uri.getURI());
  if (vmap == null) {
    throw new IllegalArgumentException("Variable with name '" + name
        + "' in namespace '" + uri.getURI() + "' has not been declared.");
  }
  final Object ret = vmap.get(name);
  if (ret == null) {
    if (!vmap.containsKey(name)) {
      throw new IllegalArgumentException("Variable with name '"
          + name + "' in namespace '" + uri.getURI()
          + "' has not been declared.");
    }
    // leave translating null variable values to the implementation.
    return null;
  }
  return ret;
}

代码示例来源:origin: org.jdom/jdom

@Override
public Object setVariable(String name, Namespace uri, Object value) {
  final Object ret = getVariable(name, uri);
  // if that succeeded then we have it easy....
  xvariables.get(uri.getURI()).put(name, value);
  return ret;
}

代码示例来源:origin: org.jdom/jdom

@Override
  public String toString() {
    return ns.getPrefix() + "=" + ns.getURI();
  }
}

代码示例来源:origin: org.jdom/jdom

@Override
public String translateNamespacePrefixToUri(String prefix) {
  return getNamespace(prefix).getURI();
}

代码示例来源:origin: org.jdom/jdom

@Override
public final String getNamespaceStringValue(Object namespace) {
  return ((NamespaceContainer)namespace).getNamespace().getURI();
}

代码示例来源:origin: org.jdom/jdom

void includeNamespace(Namespace namespace) {
  nsFromUser.put(namespace.getPrefix(), namespace.getURI());
}

代码示例来源:origin: org.jdom/jdom

/**
 * This will handle printing of any needed <code>{@link Namespace}</code>
 * declarations.
 * 
 * @param out
 *        <code>XMLStreamWriter</code> to use.
 * @param fstack
 *        The current FormatStack
 * @param ns
 *        <code>Namespace</code> to print definition of
 * @throws XMLStreamException
 *         if the output fails
 */
protected void printNamespace(final XMLStreamWriter out, final FormatStack fstack, 
    final Namespace ns)  throws XMLStreamException {
  final String prefix = ns.getPrefix();
  final String uri = ns.getURI();
  
  out.writeNamespace(prefix, uri);
}

代码示例来源:origin: org.jdom/jdom

/**
 * Check if two namespaces collide.
 *
 * @param namespace <code>Namespace</code> to check.
 * @param other <code>Namespace</code> to check against.
 * @return <code>String</code> reason for collision, or
 *         <code>null</code> if no collision.
 */
public static String checkNamespaceCollision(final Namespace namespace,
    final Namespace other) {
  String p1,p2,u1,u2,reason;
  reason = null;
  p1 = namespace.getPrefix();
  u1 = namespace.getURI();
  p2 = other.getPrefix();
  u2 = other.getURI();
  if (p1.equals(p2) && !u1.equals(u2)) {
    reason = "The namespace prefix \"" + p1 + "\" collides";
  }
  return reason;
}

代码示例来源:origin: org.jdom/jdom

@Override
public javax.xml.stream.events.Namespace next() {
  Namespace ns = source.next();
  return fac.createNamespace(ns.getPrefix(), ns.getURI());
}

代码示例来源:origin: org.jdom/jdom

/**
 * This will create an <code>Exception</code> indicating
 * that the addition of the <code>{@link Namespace}</code>
 * to the <code>{@link Element}</code> is illegal.
 *
 * @param base <code>Element</code> that the <code>Namespace</code>
 *             couldn't be added to
 * @param added <code>Namespace</code> that could not be added
 * @param reason cause of the problem
 */
IllegalAddException(Element base, Namespace added, String reason) {
  super(new StringBuilder()
  .append("The namespace xmlns")
  .append(added.getPrefix().equals("") ? "=" 
      : ":" + added.getPrefix() + "=")
      .append("\"")
      .append(added.getURI())
      .append("\" could not be added as a namespace to \"")
      .append(base.getQualifiedName())
      .append("\": ")
      .append(reason)
      .toString());
}

代码示例来源:origin: org.jdom/jdom

void setContext(Object node) {
  nsFromContext.clear();
  List<Namespace> nsl = null;
  if (node instanceof NamespaceAware) {
    nsl = ((NamespaceAware)node).getNamespacesInScope();
  } else if (node instanceof NamespaceContainer) {
    nsl = ((NamespaceContainer)node).getParentElement().getNamespacesInScope();
  }
  if (nsl != null) {
    for (Namespace ns : nsl) {
      nsFromContext.put(ns.getPrefix(), ns.getURI());
    }
  }
}

代码示例来源:origin: org.jdom/jdom

/**
 * Return index of the <code>Attribute</code> with the given <i>name</i> and
 * the same Namespace URI as <i>namespace</i>.
 * 
 * @param name
 *        name of <code>Attribute</code> to retrieve
 * @param namespace
 *        indicate what <code>Namespace</code> URI to consider
 * @return the index of the attribute that matches the conditions, or
 *         <code>-1</code> if there is none.
 */
int indexOf(final String name, final Namespace namespace) {
  if (attributeData != null) {
    if (namespace == null) {
      return indexOf(name, Namespace.NO_NAMESPACE);
    }
    final String uri = namespace.getURI();
    for (int i = 0; i < size; i++) {
      final Attribute att = attributeData[i];
      if (uri.equals(att.getNamespaceURI()) &&
          name.equals(att.getName())) {
        return i;
      }
    }
  }
  return -1;
}

代码示例来源:origin: org.jdom/jdom

@Override
public Object getVariableValue(String namespaceURI, String prefix,
    String localName) throws UnresolvableException {
  if (namespaceURI == null) {
    namespaceURI = "";
  }
  if (prefix == null) {
    prefix = "";
  }
  try {
    if ("".equals(namespaceURI)) {
      namespaceURI = getNamespace(prefix).getURI();
    }
    return getVariable(localName, Namespace.getNamespace(namespaceURI));
  } catch (IllegalArgumentException e) {
    throw new UnresolvableException("Unable to resolve variable " + 
        localName + " in namespace '" + namespaceURI + 
        "' to a vaulue.");
  }
}

代码示例来源:origin: org.jdom/jdom

@Override
public javax.xml.stream.events.Attribute next() {
  final Attribute att = source.next();
  final Namespace ns = att.getNamespace();
  if (ns == Namespace.NO_NAMESPACE) {
    return fac.createAttribute(att.getName(), att.getValue());
  }
  return fac.createAttribute(ns.getPrefix(), ns.getURI(), 
      att.getName(), att.getValue());
}

代码示例来源:origin: org.jdom/jdom

/**
 * This will handle printing of an <code>{@link Attribute}</code>.
 * 
 * @param out
 *        <code>XMLStreamWriter</code> to use.
 * @param fstack
 *        The current FormatStack
 * @param attribute
 *        <code>Attribute</code> to output
 * @throws XMLStreamException
 *         if the output fails
 */
protected void printAttribute(final XMLStreamWriter out, final FormatStack fstack,
    final Attribute attribute) throws XMLStreamException {
  if (!attribute.isSpecified() && fstack.isSpecifiedAttributesOnly()) {
    return;
  }
  
  final Namespace ns = attribute.getNamespace();
  if (ns == Namespace.NO_NAMESPACE) {
    out.writeAttribute(attribute.getName(), attribute.getValue());
  } else {
    out.writeAttribute(ns.getPrefix(), ns.getURI(), 
        attribute.getName(), attribute.getValue());
  }
}

代码示例来源:origin: org.jdom/jdom

/**
 * This will handle printing of any needed <code>{@link Namespace}</code>
 * declarations.
 * 
 * @param out
 *        <code>Writer</code> to use.
 * @param fstack
 *        The current FormatStack
 * @param ns
 *        <code>Namespace</code> to print definition of
 * @throws IOException
 *         if the output fails
 */
protected void printNamespace(final Writer out, final FormatStack fstack, 
    final Namespace ns)  throws IOException {
  final String prefix = ns.getPrefix();
  final String uri = ns.getURI();
  write(out, " xmlns");
  if (!prefix.equals("")) {
    write(out, ":");
    write(out, prefix);
  }
  write(out, "=\"");
  attributeEscapedEntitiesFilter(out, fstack, uri);
  write(out, "\"");
}

相关文章