Java Code Examples for org.apache.solr.common.util.StrUtils#parseBool()
The following examples show how to use
org.apache.solr.common.util.StrUtils#parseBool() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataImportHandler.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public void inform(SolrCore core) { try { String name = getPluginInfo().name; if (name.startsWith("/")) { myName = name.substring(1); } // some users may have '/' in the handler name. replace with '_' myName = myName.replaceAll("/", "_"); debugEnabled = StrUtils.parseBool((String)initArgs.get(ENABLE_DEBUG), true); importer = new DataImporter(core, myName); } catch (Exception e) { log.error( DataImporter.MSG.LOAD_EXP, e); throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, DataImporter.MSG.LOAD_EXP, e); } }
Example 2
Source File: ShardParams.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Parse the {@value #SHARDS_TOLERANT} param from <code>params</code> as a boolean; * accepts {@value #REQUIRE_ZK_CONNECTED} as a valid value indicating <code>false</code>. * * By default, returns <code>false</code> when {@value #SHARDS_TOLERANT} is not set * in <code>params</code>. */ static boolean getShardsTolerantAsBool(SolrParams params) { String shardsTolerantValue = params.get(SHARDS_TOLERANT); if (null == shardsTolerantValue || shardsTolerantValue.equals(REQUIRE_ZK_CONNECTED)) { return false; } else { return StrUtils.parseBool(shardsTolerantValue); // throw an exception if non-boolean } }
Example 3
Source File: ComplexPhraseQParserPlugin.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public void init(@SuppressWarnings({"rawtypes"})NamedList args) { super.init(args); if (args != null) { Object val = args.get("inOrder"); if (val != null) { inOrder = StrUtils.parseBool(val.toString()); } } }
Example 4
Source File: ReplicationHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
private boolean isEnabled( @SuppressWarnings({"rawtypes"})NamedList params ){ if( params == null ) return false; Object enable = params.get( "enable" ); if( enable == null ) return true; if( enable instanceof String ) return StrUtils.parseBool( (String)enable ); return Boolean.TRUE.equals( enable ); }
Example 5
Source File: SolrParams.java From lucene-solr with Apache License 2.0 | 4 votes |
/** Returns the boolean value of the param, or def if not set */ public boolean getBool(String param, boolean def) { String val = get(param); return val==null ? def : StrUtils.parseBool(val); }
Example 6
Source File: RequestInfo.java From lucene-solr with Apache License 2.0 | 4 votes |
public RequestInfo(SolrQueryRequest request, Map<String,Object> requestParams, ContentStream stream) { this.request = request; this.contentStream = stream; if (requestParams.containsKey("command")) { command = (String) requestParams.get("command"); } else { command = null; } boolean debugMode = StrUtils.parseBool((String) requestParams.get("debug"), false); if (debugMode) { debug = true; debugInfo = new DebugInfo(requestParams); } else { debug = false; debugInfo = null; } if (requestParams.containsKey("clean")) { clean = StrUtils.parseBool( (String) requestParams.get("clean"), true); } else if (DataImporter.DELTA_IMPORT_CMD.equals(command) || DataImporter.IMPORT_CMD.equals(command)) { clean = false; } else { clean = debug ? false : true; } optimize = StrUtils.parseBool((String) requestParams.get("optimize"), false); if(optimize) { commit = true; } else { commit = StrUtils.parseBool( (String) requestParams.get("commit"), (debug ? false : true)); } if (requestParams.containsKey("rows")) { rows = Integer.parseInt((String) requestParams.get("rows")); } else { rows = debug ? 10 : Long.MAX_VALUE; } if (requestParams.containsKey("start")) { start = Integer.parseInt((String) requestParams.get("start")); } else { start = 0; } syncMode = StrUtils.parseBool((String) requestParams.get("synchronous"), false); Object o = requestParams.get("entity"); List<String> modifiableEntities = null; if(o != null) { if (o instanceof String) { modifiableEntities = new ArrayList<>(); modifiableEntities.add((String) o); } else if (o instanceof List<?>) { @SuppressWarnings("unchecked") List<String> modifiableEntities1 = new ArrayList<>((List<String>) o); modifiableEntities = modifiableEntities1; } entitiesToRun = Collections.unmodifiableList(modifiableEntities); } else { entitiesToRun = null; } String configFileParam = (String) requestParams.get("config"); configFile = configFileParam; String dataConfigParam = (String) requestParams.get("dataConfig"); if (dataConfigParam != null && dataConfigParam.trim().length() == 0) { // Empty data-config param is not valid, change it to null dataConfigParam = null; } dataConfig = dataConfigParam; this.rawParams = Collections.unmodifiableMap(new HashMap<>(requestParams)); }
Example 7
Source File: DebugInfo.java From lucene-solr with Apache License 2.0 | 4 votes |
public DebugInfo(Map<String,Object> requestParams) { verbose = StrUtils.parseBool((String) requestParams.get("verbose"), false); debugVerboseOutput = new NamedList<>(); }
Example 8
Source File: DOMUtil.java From lucene-solr with Apache License 2.0 | 4 votes |
/** * Examines a Node from the DOM representation of a NamedList and adds the * contents of that node to both the specified NamedList and List passed * as arguments. * * @param nd The Node whose type will be used to determine how to parse the * text content. If there is a 'name' attribute it will be used * when adding to the NamedList * @param nlst A NamedList to add the item to with name if application. * If this param is null it will be ignored. * @param arr A List to add the item to. * If this param is null it will be ignored. */ @SuppressWarnings("unchecked") public static void addToNamedList(Node nd, @SuppressWarnings({"rawtypes"})NamedList nlst, @SuppressWarnings({"rawtypes"})List arr) { // Nodes often include whitespace, etc... so just return if this // is not an Element. if (nd.getNodeType() != Node.ELEMENT_NODE) return; final String type = nd.getNodeName(); final String name = getAttr(nd, NAME); Object val=null; if ("lst".equals(type)) { val = childNodesToNamedList(nd); } else if ("arr".equals(type)) { val = childNodesToList(nd); } else { final String textValue = getText(nd); try { if ("str".equals(type)) { val = textValue; } else if ("int".equals(type)) { val = Integer.valueOf(textValue); } else if ("long".equals(type)) { val = Long.valueOf(textValue); } else if ("float".equals(type)) { val = Float.valueOf(textValue); } else if ("double".equals(type)) { val = Double.valueOf(textValue); } else if ("bool".equals(type)) { val = StrUtils.parseBool(textValue); } // :NOTE: Unexpected Node names are ignored // :TODO: should we generate an error here? } catch (NumberFormatException nfe) { throw new SolrException (SolrException.ErrorCode.SERVER_ERROR, "Value " + (null != name ? ("of '" +name+ "' ") : "") + "can not be parsed as '" +type+ "': \"" + textValue + "\"", nfe); } } if (nlst != null) nlst.add(name,val); if (arr != null) arr.add(val); }
Example 9
Source File: SolrParams.java From lucene-solr with Apache License 2.0 | 2 votes |
/** * Returns the Boolean value of the param, or null if not set. * Use this method only when you want to be explicit * about absence of a value (<code>null</code>) vs the default value <code>false</code>. * @see #getBool(String, boolean) * @see #getPrimitiveBool(String) * **/ public Boolean getBool(String param) { String val = get(param); return val==null ? null : StrUtils.parseBool(val); }
Example 10
Source File: SolrParams.java From lucene-solr with Apache License 2.0 | 2 votes |
/** * Returns the Boolean value of the field param, * or the value for param, or null if neither is set. * Use this method only when you want to be explicit * about absence of a value (<code>null</code>) vs the default value <code>false</code>. * @see #getFieldBool(String, String, boolean) * @see #getPrimitiveFieldBool(String, String) **/ public Boolean getFieldBool(String field, String param) { String val = getFieldParam(field, param); return val==null ? null : StrUtils.parseBool(val); }
Example 11
Source File: SolrParams.java From lucene-solr with Apache License 2.0 | 2 votes |
/** * Returns the boolean value of the field param, * or the value for param, or def if neither is set. * * */ public boolean getFieldBool(String field, String param, boolean def) { String val = getFieldParam(field, param); return val==null ? def : StrUtils.parseBool(val); }