• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DOMUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.solr.util.DOMUtil的典型用法代码示例。如果您正苦于以下问题:Java DOMUtil类的具体用法?Java DOMUtil怎么用?Java DOMUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DOMUtil类属于org.apache.solr.util包,在下文中一共展示了DOMUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getConfig

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
public static CacheConfig getConfig(SolrConfig solrConfig, Node node) {
  if (node==null) return null;
  CacheConfig config = new CacheConfig();
  config.nodeName = node.getNodeName();
  config.args = DOMUtil.toMap(node.getAttributes());
  String nameAttr = config.args.get("name");  // OPTIONAL
  if (nameAttr==null) {
    config.args.put("name",config.nodeName);
  }

  SolrResourceLoader loader = solrConfig.getResourceLoader();
  config.cacheImpl = config.args.get("class");
  config.regenImpl = config.args.get("regenerator");
  config.clazz = loader.findClass(config.cacheImpl, SolrCache.class);
  if (config.regenImpl != null) {
    config.regenerator = loader.newInstance(config.regenImpl, CacheRegenerator.class);
  }
  
  return config;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:CacheConfig.java


示例2: readSimilarity

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
static SimilarityFactory readSimilarity(SolrResourceLoader loader, Node node) {
  if (node==null) {
    return null;
  } else {
    SimilarityFactory similarityFactory;
    final String classArg = ((Element) node).getAttribute(SimilarityFactory.CLASS_NAME);
    final Object obj = loader.newInstance(classArg, Object.class, "search.similarities.");
    if (obj instanceof SimilarityFactory) {
      // configure a factory, get a similarity back
      final NamedList<Object> namedList = DOMUtil.childNodesToNamedList(node);
      namedList.add(SimilarityFactory.CLASS_NAME, classArg);
      SolrParams params = SolrParams.toSolrParams(namedList);
      similarityFactory = (SimilarityFactory)obj;
      similarityFactory.init(params);
    } else {
      // just like always, assume it's a Similarity and get a ClassCastException - reasonable error handling
      similarityFactory = new SimilarityFactory() {
        @Override
        public Similarity getSimilarity() {
          return (Similarity) obj;
        }
      };
    }
    return similarityFactory;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:IndexSchema.java


示例3: getProperty

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
public String getProperty(String coreName, String property, String defaultVal) {
  
  synchronized (coreNodes) {
    for (int idx = 0; idx < coreNodes.getLength(); ++idx) {
      Node node = coreNodes.item(idx);
      if (coreName.equals(DOMUtil.getAttr(node, CoreDescriptor.CORE_NAME,
          null))) {
        String propVal = DOMUtil.getAttr(node, property);
        if (propVal == null)
          propVal = defaultVal;
        return propVal;
      }
    }
  }
  return defaultVal;
  
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:ConfigSolrXmlOld.java


示例4: getVal

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
public String getVal(String path, boolean errIfMissing) {
  Node nd = getNode(path,errIfMissing);
  if (nd==null) return null;

  String txt = DOMUtil.getText(nd);

  log.debug(name + ' '+path+'='+txt);
  return txt;

  /******
  short typ = nd.getNodeType();
  if (typ==Node.ATTRIBUTE_NODE || typ==Node.TEXT_NODE) {
    return nd.getNodeValue();
  }
  return nd.getTextContent();
  ******/
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:Config.java


示例5: bootstrapConf

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
/**
 * If in SolrCloud mode, upload config sets for each SolrCore in solr.xml.
 */
public static void bootstrapConf(SolrZkClient zkClient, Config cfg, String solrHome) throws IOException,
    KeeperException, InterruptedException {
  log.info("bootstraping config into ZooKeeper using solr.xml");
  NodeList nodes = (NodeList)cfg.evaluate("solr/cores/core", XPathConstants.NODESET);

  for (int i=0; i<nodes.getLength(); i++) {
    Node node = nodes.item(i);
    String rawName = DOMUtil.substituteProperty(DOMUtil.getAttr(node, "name", null), new Properties());
    String instanceDir = DOMUtil.getAttr(node, "instanceDir", null);
    File idir = new File(instanceDir);
    if (!idir.isAbsolute()) {
      idir = new File(solrHome, instanceDir);
    }
    String confName = DOMUtil.substituteProperty(DOMUtil.getAttr(node, "collection", null), new Properties());
    if (confName == null) {
      confName = rawName;
    }
    File udir = new File(idir, "conf");
    log.info("Uploading directory " + udir + " with name " + confName + " for SolrCore " + rawName);
    ZkController.uploadConfigDir(zkClient, udir, confName);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:26,代码来源:ZkController.java


示例6: readSimilarity

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
static SimilarityFactory readSimilarity(SolrResourceLoader loader, Node node) {
  if (node==null) {
    return null;
  } else {
    SimilarityFactory similarityFactory;
    final Object obj = loader.newInstance(((Element) node).getAttribute("class"), Object.class, "search.similarities.");
    if (obj instanceof SimilarityFactory) {
      // configure a factory, get a similarity back
      SolrParams params = SolrParams.toSolrParams(DOMUtil.childNodesToNamedList(node));
      similarityFactory = (SimilarityFactory)obj;
      similarityFactory.init(params);
    } else {
      // just like always, assume it's a Similarity and get a ClassCastException - reasonable error handling
      similarityFactory = new SimilarityFactory() {
        @Override
        public Similarity getSimilarity() {
          return (Similarity) obj;
        }
      };
    }
    return similarityFactory;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:24,代码来源:IndexSchema.java


示例7: addCoresAttrib

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
private void addCoresAttrib(Map<String,String> coresAttribs, String attribName, String attribValue, String defaultValue) {
  if (cfg == null) {
    coresAttribs.put(attribName, attribValue);
    return;
  }
  
  if (attribValue != null) {
    String rawValue = cfg.get("solr/cores/@" + attribName, null);
    if (rawValue == null && defaultValue != null && attribValue.equals(defaultValue)) return;
    if (attribValue.equals(DOMUtil.substituteProperty(rawValue, loader.getCoreProperties()))) {
      coresAttribs.put(attribName, rawValue);
    } else {
      coresAttribs.put(attribName, attribValue);
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:CoreContainer.java


示例8: addCoreProperty

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
private void addCoreProperty(Map<String,String> coreAttribs, Node node, String name,
    String value, String defaultValue) {
  if (node == null) {
    coreAttribs.put(name, value);
    return;
  }
  
  if (node != null) {
    String rawAttribValue = DOMUtil.getAttr(node, name, null);
    if (value == null) {
      coreAttribs.put(name, rawAttribValue);
      return;
    }
    if (rawAttribValue == null && defaultValue != null && value.equals(defaultValue)) {
      return;
    }
    if (rawAttribValue != null && value.equals(DOMUtil.substituteProperty(rawAttribValue, loader.getCoreProperties()))){
      coreAttribs.put(name, rawAttribValue);
    } else {
      coreAttribs.put(name, value);
    }
  }

}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:25,代码来源:CoreContainer.java


示例9: addCoresAttrib

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
private void addCoresAttrib(Map<String, String> coresAttribs, String attribName, String attribValue, String defaultValue) {
	if(cfg == null) {
		coresAttribs.put(attribName, attribValue);
		return;
	}

	if(attribValue != null) {
		String rawValue = cfg.get("solr/cores/@" + attribName, null);
		if(rawValue == null && defaultValue != null && attribValue.equals(defaultValue))
			return;
		if(attribValue.equals(DOMUtil.substituteProperty(rawValue, loader.getCoreProperties()))) {
			coresAttribs.put(attribName, rawValue);
		} else {
			coresAttribs.put(attribName, attribValue);
		}
	}
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:18,代码来源:CoreContainer.java


示例10: addCoreProperty

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
private void addCoreProperty(Map<String, String> coreAttribs, Node node, String name, String value, String defaultValue) {
	if(node == null) {
		coreAttribs.put(name, value);
		return;
	}

	if(node != null) {
		String rawAttribValue = DOMUtil.getAttr(node, name, null);
		if(value == null) {
			coreAttribs.put(name, rawAttribValue);
			return;
		}
		if(rawAttribValue == null && defaultValue != null && value.equals(defaultValue)) {
			return;
		}
		if(rawAttribValue != null && value.equals(DOMUtil.substituteProperty(rawAttribValue, loader.getCoreProperties()))) {
			coreAttribs.put(name, rawAttribValue);
		} else {
			coreAttribs.put(name, value);
		}
	}

}
 
开发者ID:netboynb,项目名称:search-core,代码行数:24,代码来源:CoreContainer.java


示例11: getProperty

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
public String getProperty(String coreName, String property, String defaultVal) {
  
  synchronized (coreNodes) {
    for (int idx = 0; idx < coreNodes.getLength(); ++idx) {
      Node node = coreNodes.item(idx);
      if (coreName.equals(DOMUtil.getAttr(node, CoreDescriptor.CORE_NAME,
          null))) {
        String propVal = DOMUtil.getAttr(node, property);
        if (propVal == null)
          propVal = defaultVal;
        return PropertiesUtil.substituteProperty(propVal, null);
      }
    }
  }
  return defaultVal;
  
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:18,代码来源:ConfigSolrXmlOld.java


示例12: initLibs

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
private void initLibs() {
  NodeList nodes = (NodeList) evaluate("lib", XPathConstants.NODESET);
  if (nodes == null || nodes.getLength() == 0) return;
  
  log.info("Adding specified lib dirs to ClassLoader");
  SolrResourceLoader loader = getResourceLoader();
  
  try {
    for (int i = 0; i < nodes.getLength(); i++) {
      Node node = nodes.item(i);
      
      String baseDir = DOMUtil.getAttr(node, "dir");
      String path = DOMUtil.getAttr(node, "path");
      if (null != baseDir) {
        // :TODO: add support for a simpler 'glob' mutually exclusive of regex
        String regex = DOMUtil.getAttr(node, "regex");
        FileFilter filter = (null == regex) ? null : new RegexFileFilter(regex);
        loader.addToClassLoader(baseDir, filter, false);
      } else if (null != path) {
        final File file = FileUtils.resolvePath(new File(loader.getInstanceDir()), path);
        loader.addToClassLoader(file.getParent(), new FileFilter() {
          @Override
          public boolean accept(File pathname) {
            return pathname.equals(file);
          }
        }, false);
      } else {
        throw new RuntimeException(
            "lib: missing mandatory attributes: 'dir' or 'path'");
      }
    }
  } finally {
    loader.reloadLuceneSPI();
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:36,代码来源:SolrConfig.java


示例13: getAllCoreNames

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
public List<String> getAllCoreNames() {
  List<String> ret = new ArrayList<>();
  
  synchronized (coreNodes) {
    for (int idx = 0; idx < coreNodes.getLength(); ++idx) {
      Node node = coreNodes.item(idx);
      ret.add(DOMUtil.getAttr(node, CoreDescriptor.CORE_NAME, null));
    }
  }
  
  return ret;
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:ConfigSolrXmlOld.java


示例14: getCoreProperties

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
public Properties getCoreProperties(String coreName) {
  synchronized (coreNodes) {
    for (int idx = 0; idx < coreNodes.getLength(); idx++) {
      Node node = coreNodes.item(idx);
      if (coreName.equals(DOMUtil.getAttr(node, CoreDescriptor.CORE_NAME, null))) {
        try {
          return readProperties(node);
        } catch (XPathExpressionException e) {
          SolrException.log(log, e);
        }
      }
    }
  }
  return new Properties();
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:ConfigSolrXmlOld.java


示例15: readProperties

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
protected Properties readProperties(Node node) throws XPathExpressionException {
  XPath xpath = config.getXPath();
  NodeList props = (NodeList) xpath.evaluate("property", node, XPathConstants.NODESET);
  Properties properties = new Properties();
  for (int i = 0; i < props.getLength(); i++) {
    Node prop = props.item(i);
    properties.setProperty(DOMUtil.getAttr(prop, "name"),
        PropertiesUtil.substituteProperty(DOMUtil.getAttr(prop, "value"), null));
  }
  return properties;
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:ConfigSolr.java


示例16: readNodeListAsNamedList

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
private NamedList<Object> readNodeListAsNamedList(String path) {
  NodeList nodes = config.getNodeList(path, false);
  if (nodes != null) {
    NamedList<Object> namedList = DOMUtil.nodesToNamedList(nodes);
    return namedList;
  }
  return new NamedList<>();
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:ConfigSolrXml.java


示例17: PluginInfo

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
public PluginInfo(Node node, String err, boolean requireName, boolean requireClass) {
  type = node.getNodeName();
  name = DOMUtil.getAttr(node, "name", requireName ? err : null);
  className = DOMUtil.getAttr(node, "class", requireClass ? err : null);
  initArgs = DOMUtil.childNodesToNamedList(node);
  attributes = unmodifiableMap(DOMUtil.toMap(node.getAttributes()));
  children = loadSubPlugins(node);
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:PluginInfo.java


示例18: init

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
@Override
protected void init(FieldType plugin, Node node) throws Exception {

  Map<String,String> params = DOMUtil.toMapExcept( node.getAttributes(), 
                                                   "name","class" );
  plugin.setArgs(schema, params );
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:8,代码来源:FieldTypePluginLoader.java


示例19: readProperties

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
private Properties readProperties(Config cfg, Node node) throws XPathExpressionException {
  XPath xpath = cfg.getXPath();
  NodeList props = (NodeList) xpath.evaluate("property", node, XPathConstants.NODESET);
  Properties properties = new Properties();
  for (int i=0; i<props.getLength(); i++) {
    Node prop = props.item(i);
    properties.setProperty(DOMUtil.getAttr(prop, "name"), DOMUtil.getAttr(prop, "value"));
  }
  return properties;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:11,代码来源:CoreContainer.java


示例20: initLibs

import org.apache.solr.util.DOMUtil; //导入依赖的package包/类
private void initLibs() {
  NodeList nodes = (NodeList) evaluate("lib", XPathConstants.NODESET);
  if (nodes == null || nodes.getLength() == 0) return;
  
  log.info("Adding specified lib dirs to ClassLoader");
  
  try {
    for (int i = 0; i < nodes.getLength(); i++) {
      Node node = nodes.item(i);
      
      String baseDir = DOMUtil.getAttr(node, "dir");
      String path = DOMUtil.getAttr(node, "path");
      if (null != baseDir) {
        // :TODO: add support for a simpler 'glob' mutually eclusive of regex
        String regex = DOMUtil.getAttr(node, "regex");
        FileFilter filter = (null == regex) ? null : new RegexFileFilter(regex);
        getResourceLoader().addToClassLoader(baseDir, filter);
      } else if (null != path) {
        getResourceLoader().addToClassLoader(path);
      } else {
        throw new RuntimeException(
            "lib: missing mandatory attributes: 'dir' or 'path'");
      }
    }
  } finally {
    getResourceLoader().reloadLuceneSPI();
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:29,代码来源:SolrConfig.java



注:本文中的org.apache.solr.util.DOMUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SecurityModel类代码示例发布时间:2022-05-22
下一篇:
Java VarcharType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap