org.apache.avalon.framework.configuration.Configuration.getNamespace()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(129)

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

Configuration.getNamespace介绍

[英]Returns a string indicating which namespace this Configuration node belongs to.

What this returns is dependent on the configuration file and the Configuration builder. If the Configuration builder does not support namespaces, this method will return a blank string.

In the case of DefaultConfigurationBuilder, the namespace will be the URI associated with the XML element. Eg.,:

<foo xmlns:x="http://blah.com"> 
<x:bar/> 
</foo>

The namespace of foo will be "", and the namespace of bar will be "http://blah.com".
[中]返回一个字符串,该字符串指示此配置节点所属的命名空间。
返回的内容取决于配置文件和配置生成器。如果Configuration builder不支持名称空间,则此方法将返回空白字符串。
对于DefaultConfigurationBuilder,名称空间将是与XML元素关联的URI。如。,:

<foo xmlns:x="http://blah.com"> 
<x:bar/> 
</foo>

foo的命名空间将为“”,而bar的命名空间将为“http://blah.com".

代码示例

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
   * Check if the namespace URI of the given configuraition is the same as the
   * one given by the builder.
   */
  protected void checkNamespace(Configuration config) throws ConfigurationException {
    if (!this.treeBuilder.getNamespace().equals(config.getNamespace())) {
      String msg = "Invalid namespace '" + config.getNamespace() + "' at " + config.getLocation();
      throw new ConfigurationException(msg);
    }
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

public Location getLocation(Object obj, String description) {
    if (obj instanceof Configuration) {
      Configuration config = (Configuration)obj;
      String locString = config.getLocation();
      Location result = LocationUtils.parse(locString);
      if (LocationUtils.isKnown(result)) {
        // Add description
        StringBuffer desc = new StringBuffer().append('<');
        // Unfortunately Configuration.getPrefix() is not public
        try {
          if (config.getNamespace().startsWith("http://apache.org/cocoon/sitemap/")) {
            desc.append("map:");
          }
        } catch (ConfigurationException e) {
          // no namespace: ignore
        }
        desc.append(config.getName()).append('>');
        return new LocationImpl(desc.toString(), result);
      } else {
        return result;
      }
    }
    // Try next finders.
    return null;
  }
};

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

namespace = config.getNamespace();
} catch (ConfigurationException e) {

代码示例来源:origin: org.apache.avalon.framework/avalon-framework-impl

final String nsURI = element.getNamespace();
String nsPrefix = "";

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

for (int i = 0; i < properties.length; ++i) {
  Configuration configuration = properties[i];
  namespace = configuration.getNamespace();
  if (namespace == null) {
    namespace = "";

代码示例来源:origin: org.apache.avalon.framework/avalon-framework-impl

/**
 * Copy constructor, to create a clone of another configuration.
 * To modify children, use <code>getChild()</code>, 
 * <code>removeChild()</code> and <code>addChild()</code>.
 * 
 * @param config the <code>Configuration</code> to copy
 * @param deepCopy true will cause clones of the children to be added,
 *                 false will add the original instances and is thus
 *                 faster.
 *
 * @throws ConfigurationException if an error occurs when copying
 */
public DefaultConfiguration( Configuration config, boolean deepCopy )
  throws ConfigurationException
{
  this( config.getName(), config.getLocation(), config.getNamespace(), 
    ( (config instanceof AbstractConfiguration) ? ((AbstractConfiguration)config).getPrefix() : "") );
  
  addAll( config, deepCopy );
}

代码示例来源:origin: com.cloudhopper.proxool/proxool

for (int i = 0; i < properties.length; ++i) {
  Configuration configuration = properties[i];
  namespace = configuration.getNamespace();
  if (namespace == null) {
    namespace = "";

代码示例来源:origin: org.apache.cocoon/cocoon-util

final Configuration configuration )
throws ConfigurationException {
  final Element element = document.createElementNS( configuration.getNamespace(), configuration.getName() );
  element.setPrefix( configuration.getLocation() );
  final String content = configuration.getValue( null );

代码示例来源:origin: org.apache.avalon.framework/avalon-framework-impl

m_namespace = config.getNamespace();
m_prefix = (config instanceof AbstractConfiguration) ? ((AbstractConfiguration)config).getPrefix() : "";

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * Get the tree builder role from the sitemap program (as a configuration object).
 * This method should report very any problem very clearly, as it is the entry point of any
 * Cocoon application.
 *
 * @param sitemapProgram the sitemap
 * @return the treebuilder role
 * @throws ConfigurationException if a suitable role could not be found
 */
private TreeBuilder getTreeBuilder(Configuration sitemapProgram) throws ConfigurationException {
  String ns = sitemapProgram.getNamespace();
  RE re = new RE("http://apache.org/cocoon/sitemap/(\\d\\.\\d)");
  if (!re.match(ns)) {
    throw new ConfigurationException("Unknown sitemap namespace (" + ns + ") at " +
        this.source.getURI());
  }
  String version = re.getParen(1);
  String result = TreeBuilder.ROLE + "/sitemap-" + version;
  try {
    return (TreeBuilder) this.manager.lookup(result);
  } catch (Exception e) {
    throw new ConfigurationException("This version of Cocoon does not handle sitemap version " +
                     version + " at " + this.source.getURI(), e);
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

this.itsNamespace = tree.getNamespace();

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

componentConfig = new DefaultConfiguration("components",
                      config.getLocation(),
                      config.getNamespace(),
                      "");
                            componentConfig.getNamespace(),
                            "");
c.addAll(componentConfig);

相关文章