org.jdom.Namespace.getPrefix()方法的使用及代码示例

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

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

Namespace.getPrefix介绍

[英]This returns the prefix mapped to this Namespace.
[中]这将返回映射到此Namespace的前缀。

代码示例

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

public String getNamespacePrefix(Object obj)
{
  if (obj instanceof Namespace) {
    Namespace ns = (Namespace) obj;
    return ns.getPrefix();
  } else {
    XPathNamespace ns = (XPathNamespace) obj;
    return ns.getJDOMNamespace().getPrefix();
  }
}

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

public List operate(Object node) {
      if (node instanceof Element)
        return Collections.singletonList(((Element) node).getNamespace().getPrefix());
      else if (node instanceof Attribute)
        return Collections.singletonList(((Attribute) node).getNamespace().getPrefix());
      // With 2.1 semantics it  makes more sense to just return a null and let the core 
      // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
      return null;
//            throw new TemplateModelException("_nsprefix can not be applied on " + node.getClass());
    }
  }

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

public String toString()
  {
    return ( "[xmlns:" + jdomNamespace.getPrefix() + "=\"" +
         jdomNamespace.getURI() + "\", element=" +
         jdomElement.getName() + "]" );
  }
}

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

if ( !nsMap.containsKey(ns.getPrefix()) )
  nsMap.put( ns.getPrefix(), new XPathNamespace(elem, ns) );
if ( !nsMap.containsKey(ns.getPrefix()) )
  nsMap.put( ns.getPrefix(), new XPathNamespace(elem, ns) );
  if ( !nsMap.containsKey(attrNS.getPrefix()) )
    nsMap.put( attrNS.getPrefix(), new XPathNamespace(elem, attrNS) );

代码示例来源:origin: org.codehaus.xfire/xfire-core

private void declare(Namespace ns)
{
  prefix2decNs.put(ns.getPrefix(), ns);
  namespaces.add(ns);
}

代码示例来源:origin: apache/cxf

private void declare(Namespace ns) {
  prefix2decNs.put(ns.getPrefix(), ns);
  namespaces.add(ns);
}

代码示例来源:origin: org.freemarker/freemarker-gae

public List operate(Object node) {
      if (node instanceof Element)
        return Collections.singletonList(((Element) node).getNamespace().getPrefix());
      else if (node instanceof Attribute)
        return Collections.singletonList(((Attribute) node).getNamespace().getPrefix());
      // With 2.1 semantics it  makes more sense to just return a null and let the core 
      // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
      return null;
//            throw new TemplateModelException("_nsprefix can not be applied on " + node.getClass());
    }
  }

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private void printQualifiedName(Writer out, Element e) throws IOException {
  if (e.getNamespace().getPrefix().length() == 0) {
    out.write(e.getName());
  }
  else {
    out.write(e.getNamespace().getPrefix());
    out.write(':');
    out.write(e.getName());
  }
}

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

/**
 * This will add a new <code>{@link Namespace}</code>
 * to those currently available.
 * 
 * @param ns <code>Namespace</code> to add.
 */
public void push(Namespace ns) {
  prefixes.push(ns.getPrefix());
  uris.push(ns.getURI());
}

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

/**
 * This will add a new <code>{@link Namespace}</code> to those currently available.
 * 
 * @param ns <code>Namespace</code> to add.
 */
public void push(Namespace ns) {
  prefixes.push(ns.getPrefix());
  uris.push(ns.getURI());
}

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

private void writeObject(final ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  // We use writeObject() and not writeUTF() to minimize space
  // This allows for writing pointers to already written strings
  out.writeObject(namespace.getPrefix());
  out.writeObject(namespace.getURI());
}

代码示例来源:origin: apache/maven-archetype

/**
 * This will add a new <code>{@link Namespace}</code>
 * to those currently available.
 *
 * @param ns <code>Namespace</code> to add.
 */
public void push( Namespace ns )
{
  prefixes.push( ns.getPrefix() );
  uris.push( ns.getURI() );
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

public List operate(Object node) {
      if (node instanceof Element)
        return Collections.singletonList(((Element) node).getNamespace().getPrefix());
      else if (node instanceof Attribute)
        return Collections.singletonList(((Attribute) node).getNamespace().getPrefix());
      // With 2.1 semantics it  makes more sense to just return a null and let the core 
      // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
      return null;
//            throw new TemplateModelException("_nsprefix can not be applied on " + node.getClass());
    }
  }

代码示例来源:origin: org.kathrynhuxtable.maven.plugins/htmlfilter-site-maven-plugin

private void printQualifiedName(Writer out, Element e) throws IOException {
  if (e.getNamespace().getPrefix().length() == 0) {
    out.write(e.getName());
  } else {
    out.write(e.getNamespace().getPrefix());
    out.write(':');
    out.write(e.getName());
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

protected void printQualifiedName(Writer out, Attribute a) throws IOException {
  String prefix = a.getNamespace().getPrefix();
  if ((prefix != null) && (!prefix.equals(""))) {
    out.write(prefix);
    out.write(':');
  }
  printName(out, a);
}

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private void printQualifiedName(Writer out, Attribute a) throws IOException {
  String prefix=a.getNamespace().getPrefix();
  if ((prefix != null) && (!prefix.equals(""))) {
    out.write(prefix);
    out.write(':');
    out.write(a.getName());
  }
  else {
    out.write(a.getName());
  }
}

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

public List operate(Object node)
    {
      if (node instanceof Element)
        return Collections12.singletonList(((Element)node).getNamespace().getPrefix());
      else if (node instanceof Attribute)
        return Collections12.singletonList(((Attribute)node).getNamespace().getPrefix());
      // With 2.1 semantics it  makes more sense to just return a null and let the core 
      // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR)
      return null;
//            throw new TemplateModelException("_nsprefix can not be applied on " + node.getClass());
    }
  }

代码示例来源:origin: org.apache.cxf/cxf-rt-databinding-aegis

private boolean shouldDeclare(Namespace ns) {
  if (ns == Namespace.XML_NAMESPACE) {
    return false;
  }
  if (ns == Namespace.NO_NAMESPACE && getDeclaredURI("") == null) {
    return false;
  }
  String decUri = getDeclaredURI(ns.getPrefix());
  return !(decUri != null && decUri.equals(ns.getURI()));
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

private boolean shouldDeclare(Namespace ns)
{
  if (ns == Namespace.XML_NAMESPACE) return false;
  
  if (ns == Namespace.NO_NAMESPACE && getDeclaredURI("") == null)
    return false;
  
  String decUri = getDeclaredURI(ns.getPrefix());
  
  return !(decUri != null && decUri.equals(ns.getURI()));
}

代码示例来源:origin: apache/cxf

private boolean shouldDeclare(Namespace ns) {
  if (ns == Namespace.XML_NAMESPACE) {
    return false;
  }
  if (ns == Namespace.NO_NAMESPACE && getDeclaredURI("") == null) {
    return false;
  }
  String decUri = getDeclaredURI(ns.getPrefix());
  return !(decUri != null && decUri.equals(ns.getURI()));
}

相关文章