当前位置: 首页>>代码示例>>Java>>正文


Java DOMUtil类代码示例

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


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


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