List of usage examples for org.apache.commons.lang3 StringUtils lowerCase
public static String lowerCase(final String str)
Converts a String to lower case as per String#toLowerCase() .
A null input String returns null .
StringUtils.lowerCase(null) = null StringUtils.lowerCase("") = "" StringUtils.lowerCase("aBc") = "abc"
Note: As described in the documentation for String#toLowerCase() , the result of this method is affected by the current locale.
From source file:org.apache.openmeetings.db.util.DaoHelper.java
public static String getStringParam(String param) { return param == null ? "%" : "%" + StringUtils.lowerCase(param) + "%"; }
From source file:org.apache.openmeetings.util.DaoHelper.java
public static void getWhereClause(StringBuilder sb, String search, String alias, String... fields) { if (search != null) { boolean notEmpty = false; String[] searchItems = search.replace("\'", "").replace("\"", "").split(" "); for (int i = 0; i < searchItems.length; ++i) { if (searchItems[i].isEmpty()) { continue; }//www . j a v a 2s.com if (i == 0) { notEmpty = true; sb.append(" ("); } else { sb.append(" OR "); } StringBuilder placeholder = new StringBuilder(); placeholder.append("%").append(StringUtils.lowerCase(searchItems[i])).append("%"); sb.append("("); for (int j = 0; j < fields.length; ++j) { if (j != 0) { sb.append(" OR "); } sb.append("lower(").append(alias).append(".").append(fields[j]).append(") LIKE '") .append(placeholder).append("' "); } sb.append(")"); } if (notEmpty) { sb.append(") "); } } }
From source file:org.ballerinalang.composer.service.ballerina.parser.service.BallerinaParserService.java
public static JsonElement generateJSON(Node node, Map<String, Node> anonStructs) throws InvocationTargetException, IllegalAccessException { if (node == null) { return JsonNull.INSTANCE; }/*w ww .j a v a 2s . c o m*/ Set<Method> methods = ClassUtils.getAllInterfaces(node.getClass()).stream() .flatMap(aClass -> Arrays.stream(aClass.getMethods())).collect(Collectors.toSet()); JsonObject nodeJson = new JsonObject(); JsonArray wsJsonArray = new JsonArray(); Set<Whitespace> ws = node.getWS(); if (ws != null && !ws.isEmpty()) { for (Whitespace whitespace : ws) { JsonObject wsJson = new JsonObject(); wsJson.addProperty("ws", whitespace.getWs()); wsJson.addProperty("i", whitespace.getIndex()); wsJson.addProperty("text", whitespace.getPrevious()); wsJson.addProperty("static", whitespace.isStatic()); wsJsonArray.add(wsJson); } nodeJson.add("ws", wsJsonArray); } Diagnostic.DiagnosticPosition position = node.getPosition(); if (position != null) { JsonObject positionJson = new JsonObject(); positionJson.addProperty("startColumn", position.getStartColumn()); positionJson.addProperty("startLine", position.getStartLine()); positionJson.addProperty("endColumn", position.getEndColumn()); positionJson.addProperty("endLine", position.getEndLine()); nodeJson.add("position", positionJson); } /* Virtual props */ JsonArray type = getType(node); if (type != null) { nodeJson.add(SYMBOL_TYPE, type); } if (node.getKind() == NodeKind.INVOCATION) { assert node instanceof BLangInvocation : node.getClass(); BLangInvocation invocation = (BLangInvocation) node; if (invocation.symbol != null && invocation.symbol.kind != null) { nodeJson.addProperty(INVOCATION_TYPE, invocation.symbol.kind.toString()); } } for (Method m : methods) { String name = m.getName(); if (name.equals("getWS") || name.equals("getPosition")) { continue; } String jsonName; if (name.startsWith("get")) { jsonName = toJsonName(name, 3); } else if (name.startsWith("is")) { jsonName = toJsonName(name, 2); } else { continue; } Object prop = m.invoke(node); /* Literal class - This class is escaped in backend to address cases like "ss\"" and 8.0 and null */ if (node.getKind() == NodeKind.LITERAL && "value".equals(jsonName)) { if (prop instanceof String) { nodeJson.addProperty(jsonName, '"' + StringEscapeUtils.escapeJava((String) prop) + '"'); nodeJson.addProperty(UNESCAPED_VALUE, String.valueOf(prop)); } else { nodeJson.addProperty(jsonName, String.valueOf(prop)); } continue; } if (node.getKind() == NodeKind.ANNOTATION && node instanceof BLangAnnotation) { JsonArray attachmentPoints = new JsonArray(); ((BLangAnnotation) node).getAttachPoints().stream().map(AttachPoint::getValue) .map(JsonPrimitive::new).forEach(attachmentPoints::add); nodeJson.add("attachmentPoints", attachmentPoints); } // TODO: revisit logic for user defined types // if (node.getKind() == NodeKind.USER_DEFINED_TYPE && jsonName.equals("typeName")) { // IdentifierNode typeNode = (IdentifierNode) prop; // Node structNode; // if (typeNode.getValue().startsWith("$anonStruct$") && // (structNode = anonStructs.remove(typeNode.getValue())) != null) { // JsonObject anonStruct = generateJSON(structNode, anonStructs).getAsJsonObject(); // anonStruct.addProperty("anonStruct", true); // nodeJson.add("anonStruct", anonStruct); // continue; // } // } if (prop instanceof List && jsonName.equals("types")) { // Currently we don't need any Symbols for the UI. So skipping for now. continue; } /* Node classes */ if (prop instanceof Node) { nodeJson.add(jsonName, generateJSON((Node) prop, anonStructs)); } else if (prop instanceof List) { List listProp = (List) prop; JsonArray listPropJson = new JsonArray(); nodeJson.add(jsonName, listPropJson); for (Object listPropItem : listProp) { if (listPropItem instanceof Node) { /* Remove top level anon func and struct */ if (node.getKind() == NodeKind.COMPILATION_UNIT) { if (listPropItem instanceof BLangFunction && (((BLangFunction) listPropItem)).name.value.startsWith("$lambda$")) { continue; } } listPropJson.add(generateJSON((Node) listPropItem, anonStructs)); } else { logger.debug("Can't serialize " + jsonName + ", has a an array of " + listPropItem); } } /* Runtime model classes */ } else if (prop instanceof Set && jsonName.equals("flags")) { Set flags = (Set) prop; for (Flag flag : Flag.values()) { nodeJson.addProperty(StringUtils.lowerCase(flag.toString()), flags.contains(flag)); } } else if (prop instanceof Set) { // TODO : limit this else if to getInputs getOutputs of transform. Set vars = (Set) prop; JsonArray listVarJson = new JsonArray(); nodeJson.add(jsonName, listVarJson); for (Object obj : vars) { listVarJson.add(obj.toString()); } } else if (prop instanceof NodeKind) { String kindName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, prop.toString()); nodeJson.addProperty(jsonName, kindName); } else if (prop instanceof OperatorKind) { nodeJson.addProperty(jsonName, prop.toString()); /* Generic classes */ } else if (prop instanceof String) { nodeJson.addProperty(jsonName, (String) prop); } else if (prop instanceof Number) { nodeJson.addProperty(jsonName, (Number) prop); } else if (prop instanceof Boolean) { nodeJson.addProperty(jsonName, (Boolean) prop); } else if (prop instanceof Enum) { nodeJson.addProperty(jsonName, StringUtils.lowerCase(((Enum) prop).name())); } else if (prop instanceof int[]) { int[] intArray = ((int[]) prop); JsonArray intArrayPropJson = new JsonArray(); nodeJson.add(jsonName, intArrayPropJson); for (int intProp : intArray) { intArrayPropJson.add(intProp); } } else if (prop != null) { nodeJson.addProperty(jsonName, prop.toString()); String message = "Node " + node.getClass().getSimpleName() + " contains unknown type prop: " + jsonName + " of type " + prop.getClass(); logger.error(message); } } return nodeJson; }
From source file:org.ballerinalang.langserver.compiler.format.TextDocumentFormatUtil.java
/** * Generate json representation for the given node. * * @param node Node to get the json representation * @param anonStructs Map of anonymous structs * @param symbolMetaInfoMap symbol meta information map * @return {@link JsonElement} Json Representation of the node * @throws JSONGenerationException when Json error occurs *///from ww w .j a v a 2s . c o m public static JsonElement generateJSON(Node node, Map<String, Node> anonStructs, Map<BLangNode, List<SymbolMetaInfo>> symbolMetaInfoMap) throws JSONGenerationException { if (node == null) { return JsonNull.INSTANCE; } Set<Method> methods = ClassUtils.getAllInterfaces(node.getClass()).stream() .flatMap(aClass -> Arrays.stream(aClass.getMethods())).collect(Collectors.toSet()); JsonObject nodeJson = new JsonObject(); JsonArray wsJsonArray = new JsonArray(); Set<Whitespace> ws = node.getWS(); if (ws != null && !ws.isEmpty()) { for (Whitespace whitespace : ws) { JsonObject wsJson = new JsonObject(); wsJson.addProperty("ws", whitespace.getWs()); wsJson.addProperty("i", whitespace.getIndex()); wsJson.addProperty("text", whitespace.getPrevious()); wsJson.addProperty("static", whitespace.isStatic()); wsJsonArray.add(wsJson); } nodeJson.add("ws", wsJsonArray); } Diagnostic.DiagnosticPosition position = node.getPosition(); if (position != null) { JsonObject positionJson = new JsonObject(); positionJson.addProperty("startColumn", position.getStartColumn()); positionJson.addProperty("startLine", position.getStartLine()); positionJson.addProperty("endColumn", position.getEndColumn()); positionJson.addProperty("endLine", position.getEndLine()); nodeJson.add("position", positionJson); } /* Virtual props */ // Add UUID for each node. nodeJson.addProperty("id", UUID.randomUUID().toString()); // Add the visible endpoints for a given node if (symbolMetaInfoMap.containsKey(node)) { List<SymbolMetaInfo> endpointMetaList = symbolMetaInfoMap.get(node); JsonArray endpoints = new JsonArray(); endpointMetaList.forEach(symbolMetaInfo -> endpoints.add(symbolMetaInfo.getJson())); nodeJson.add("VisibleEndpoints", endpoints); } JsonArray type = getType(node); if (type != null) { nodeJson.add(SYMBOL_TYPE, type); } if (node.getKind() == NodeKind.INVOCATION) { assert node instanceof BLangInvocation : node.getClass(); BLangInvocation invocation = (BLangInvocation) node; if (invocation.symbol != null && invocation.symbol.kind != null) { nodeJson.addProperty(INVOCATION_TYPE, invocation.symbol.kind.toString()); } } for (Method m : methods) { String name = m.getName(); if (name.equals("getWS") || name.equals("getPosition")) { continue; } String jsonName; if (name.startsWith("get")) { jsonName = toJsonName(name, 3); } else if (name.startsWith("is")) { jsonName = toJsonName(name, 2); } else { continue; } Object prop = null; try { prop = m.invoke(node); } catch (IllegalAccessException | InvocationTargetException e) { throw new JSONGenerationException("Error occurred while generating JSON", e); } /* Literal class - This class is escaped in backend to address cases like "ss\"" and 8.0 and null */ if ((node.getKind() == NodeKind.LITERAL || node.getKind() == NodeKind.NUMERIC_LITERAL) && "value".equals(jsonName)) { if (prop instanceof String) { nodeJson.addProperty(jsonName, '"' + StringEscapeUtils.escapeJava((String) prop) + '"'); nodeJson.addProperty(UNESCAPED_VALUE, String.valueOf(prop)); } else { nodeJson.addProperty(jsonName, String.valueOf(prop)); } continue; } if (node.getKind() == NodeKind.ANNOTATION && node instanceof BLangAnnotation) { JsonArray attachmentPoints = new JsonArray(); ((BLangAnnotation) node).getAttachPoints().stream().map(AttachPoint::getValue) .map(JsonPrimitive::new).forEach(attachmentPoints::add); nodeJson.add("attachmentPoints", attachmentPoints); } if (prop instanceof List && jsonName.equals("types")) { // Currently we don't need any Symbols for the UI. So skipping for now. continue; } /* Node classes */ if (prop instanceof Node) { nodeJson.add(jsonName, generateJSON((Node) prop, anonStructs, symbolMetaInfoMap)); } else if (prop instanceof List) { List listProp = (List) prop; JsonArray listPropJson = new JsonArray(); nodeJson.add(jsonName, listPropJson); for (Object listPropItem : listProp) { if (listPropItem instanceof Node) { /* Remove top level anon func and struct */ if (node.getKind() == NodeKind.COMPILATION_UNIT) { if (listPropItem instanceof BLangFunction && (((BLangFunction) listPropItem)).name.value.startsWith("$lambda$")) { continue; } } listPropJson.add(generateJSON((Node) listPropItem, anonStructs, symbolMetaInfoMap)); } else if (listPropItem instanceof BLangRecordVarRef.BLangRecordVarRefKeyValue) { listPropJson.add(generateJSON( ((BLangRecordVarRef.BLangRecordVarRefKeyValue) listPropItem).getVariableName(), anonStructs, symbolMetaInfoMap)); listPropJson.add(generateJSON( ((BLangRecordVarRef.BLangRecordVarRefKeyValue) listPropItem).getBindingPattern(), anonStructs, symbolMetaInfoMap)); } else if (listPropItem instanceof BLangRecordVariable.BLangRecordVariableKeyValue) { listPropJson.add(generateJSON( ((BLangRecordVariable.BLangRecordVariableKeyValue) listPropItem).getKey(), anonStructs, symbolMetaInfoMap)); listPropJson.add(generateJSON( ((BLangRecordVariable.BLangRecordVariableKeyValue) listPropItem).getValue(), anonStructs, symbolMetaInfoMap)); } else if (listPropItem instanceof String) { listPropJson.add((String) listPropItem); } else { logger.debug("Can't serialize " + jsonName + ", has a an array of " + listPropItem); } } /* Runtime model classes */ } else if (prop instanceof Set && jsonName.equals("flags")) { Set flags = (Set) prop; for (Flag flag : Flag.values()) { nodeJson.addProperty(StringUtils.lowerCase(flag.toString()), flags.contains(flag)); } } else if (prop instanceof Set) { // TODO : limit this else if to getInputs getOutputs of transform. Set vars = (Set) prop; JsonArray listVarJson = new JsonArray(); nodeJson.add(jsonName, listVarJson); for (Object obj : vars) { listVarJson.add(obj.toString()); } } else if (prop instanceof NodeKind) { String kindName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, prop.toString()); nodeJson.addProperty(jsonName, kindName); } else if (prop instanceof OperatorKind) { nodeJson.addProperty(jsonName, prop.toString()); /* Generic classes */ } else if (prop instanceof String) { nodeJson.addProperty(jsonName, (String) prop); } else if (prop instanceof Number) { nodeJson.addProperty(jsonName, (Number) prop); } else if (prop instanceof Boolean) { nodeJson.addProperty(jsonName, (Boolean) prop); } else if (prop instanceof Enum) { nodeJson.addProperty(jsonName, StringUtils.lowerCase(((Enum) prop).name())); } else if (prop instanceof int[]) { int[] intArray = ((int[]) prop); JsonArray intArrayPropJson = new JsonArray(); nodeJson.add(jsonName, intArrayPropJson); for (int intProp : intArray) { intArrayPropJson.add(intProp); } } else if (prop != null) { nodeJson.addProperty(jsonName, prop.toString()); } } return nodeJson; }
From source file:org.brunocvcunha.instagram4j.requests.payload.InstagramUserGenderEnum.java
/** * @param value - instagram gender code or enum value * @return enum/*w w w. jav a 2 s.c o m*/ */ @JsonCreator public static InstagramUserGenderEnum forValue(String value) { InstagramUserGenderEnum resultEnum = gendersMap.get(StringUtils.lowerCase(value)); if (resultEnum == null) { resultEnum = InstagramUserGenderEnum.valueOf(value); } return resultEnum; }
From source file:org.codice.git.hook.Artifact.java
/** * Prompts for the blacklist artifact info. * * @param in the reader to read user input from * @param out the output stream where to print messages to the user * @throws IOException if an error occurs *//*w ww .ja va 2 s .co m*/ public void promptInfo(BufferedReader in, PrintStream out) throws IOException { this.mvnInfo = null; this.mvnName = null; LOGGER.log(Level.WARNING, "The {0} file was not found.", name); out.printf("%sThe %s file was not found%n", iprefix, name); out.printf("%sDo you wish to download it automatically (y/n) [Y]? ", iprefix); out.flush(); final String yn = StringUtils.lowerCase(StringUtils.trim(in.readLine())); if (!yn.isEmpty() && (yn.charAt(0) == 'n')) { out.printf("%s You can always manually copy the file to: %n", iprefix); out.printf("%s %n", iprefix, file); if (!infofile.exists()) { // make sure we no longer cache the info infofile.delete(); } return; } out.println(iprefix); out.printf("%sPlease provide the maven artifact's coordinates for the %s file:%n", iprefix, name); final String email = handler.getConfigString("user", null, "email"); String dgroup = null; if (StringUtils.isNotEmpty(email)) { final int i = email.indexOf('@'); if (i != -1) { final String domain = email.substring(i + 1); final int j = domain.indexOf('.'); if (j != -1) { dgroup = domain.substring(j + 1) + '.' + domain.substring(0, j); } } } String group; final String id; final String version; final String type; final String classifier; do { if (dgroup == null) { do { out.printf("%s group id: ", iprefix); out.flush(); group = StringUtils.trim(in.readLine()); } while (StringUtils.isEmpty(group)); } else { out.printf("%s group id [%s]: ", iprefix, dgroup); out.flush(); group = StringUtils.defaultIfBlank(StringUtils.trim(in.readLine()), dgroup); } } while (StringUtils.isEmpty(group)); out.printf("%s artifact id [blacklist-words]: ", iprefix); out.flush(); id = StringUtils.defaultIfBlank(StringUtils.trim(in.readLine()), "blacklist-words"); out.printf("%s version [RELEASE]: ", iprefix); out.flush(); version = StringUtils.defaultIfBlank(StringUtils.trim(in.readLine()), "RELEASE"); out.printf("%s type [txt]: ", iprefix); out.flush(); type = StringUtils.defaultIfBlank(StringUtils.trim(in.readLine()), "txt"); out.printf("%s classifier []: ", iprefix); out.flush(); classifier = StringUtils.trim(in.readLine()); this.mvnInfo = group + ':' + id + ':' + version + ':' + type; if (StringUtils.isNotEmpty(classifier)) { this.mvnInfo += ':' + classifier; } this.mvnName = id + '.' + type; }
From source file:org.craftercms.engine.targeting.impl.LocaleTargetIdManager.java
@Override public String getCurrentTargetId() throws IllegalStateException { Locale currentLocale = LocaleContextHolder.getLocale(); if (currentLocale != null) { return StringUtils.lowerCase(currentLocale.toString()); } else {// w w w .jav a 2 s. com return null; } }
From source file:org.craftercms.engine.targeting.impl.LocaleTargetIdManager.java
@Override public List<String> getAvailableTargetIds() { String[] availableTargetIds = SiteProperties.getAvailableTargetIds(); if (ArrayUtils.isEmpty(availableTargetIds)) { List<Locale> availableLocales = LocaleUtils.availableLocaleList(); List<String> availableLocaleStrs = new ArrayList<>(availableLocales.size()); for (Locale locale : availableLocales) { String localeStr = locale.toString(); // Ignore empty ROOT locale if (StringUtils.isNotEmpty(localeStr)) { availableLocaleStrs.add(StringUtils.lowerCase(localeStr)); }//from ww w . j a va2 s . c o m } return availableLocaleStrs; } else { return Arrays.asList(availableTargetIds); } }
From source file:org.dspace.browse.BrowseEngine.java
/** * Browse the archive by single values (such as the name of an author). This * produces a BrowseInfo object that contains Strings as the results of * the browse//from w ww . j a v a 2 s. com * * @param bs the scope of the browse * @return the results of the browse * @throws BrowseException if browse error */ private BrowseInfo browseByValue(BrowserScope bs) throws BrowseException { log.info(LogManager.getHeader(context, "browse_by_value", "focus=" + bs.getJumpToValue())); try { // get the table name that we are going to be getting our data from // this is the distinct table constrained to either community or collection dao.setTable(browseIndex.getDistinctTableName()); dao.setStartsWith(StringUtils.lowerCase(scope.getStartsWith())); // remind the DAO that this is a distinct value browse, so it knows what sort // of query to build dao.setDistinct(true); // tell the browse query whether we are ascending or descending on the value dao.setAscending(scope.isAscending()); // inform dao about the display frequencies flag dao.setEnableBrowseFrequencies(browseIndex.isDisplayFrequencies()); // if we want to display frequencies, we need to pass the map table if (browseIndex.isDisplayFrequencies()) { dao.setFilterMappingTables(null, browseIndex.getMapTableName()); } // set our constraints on community or collection if (scope.inCollection() || scope.inCommunity()) { // Scoped browsing of distinct metadata requires the mapping // table to be specified. if (!browseIndex.isDisplayFrequencies()) { dao.setFilterMappingTables(null, browseIndex.getMapTableName()); } if (scope.inCollection()) { Collection col = (Collection) scope.getBrowseContainer(); dao.setContainerTable("collection2item"); dao.setContainerIDField("collection_id"); dao.setContainerID(col.getID()); } else if (scope.inCommunity()) { Community com = (Community) scope.getBrowseContainer(); dao.setContainerTable("communities2item"); dao.setContainerIDField("community_id"); dao.setContainerID(com.getID()); } } // this is the total number of results in answer to the query int total = getTotalResults(true); // set the ordering field (there is only one option) dao.setOrderField("sort_value"); // assemble the focus clause if we are to have one // it will look like one of the following // - sort_value < myvalue // = sort_1 > myvalue dao.setJumpToField("sort_value"); int offset = scope.getOffset(); String rawFocusValue = null; if (offset < 1 && scope.hasJumpToValue() || scope.hasStartsWith()) { rawFocusValue = getJumpToValue(); } // assemble the offset and limit dao.setOffset(offset); dao.setLimit(scope.getResultsPerPage()); // Holder for the results List<String[]> results = null; // Does this browse have any contents? if (total > 0) { // now run the query results = dao.doValueQuery(); // now, if we don't have any results, we are at the end of the browse. This will // be because a starts_with value has been supplied for which we don't have // any items. if (results.size() == 0) { // In this case, we will calculate a new offset for the last page of results offset = total - scope.getResultsPerPage(); if (offset < 0) { offset = 0; } // And rerun the query dao.setOffset(offset); results = dao.doValueQuery(); } } else { // No records, so make an empty list results = new ArrayList<String[]>(); } // construct the BrowseInfo object to pass back BrowseInfo browseInfo = new BrowseInfo(results, offset, total, offset); if (offset + scope.getResultsPerPage() < total) { browseInfo.setNextOffset(offset + scope.getResultsPerPage()); } if (offset - scope.getResultsPerPage() > -1) { browseInfo.setPrevOffset(offset - scope.getResultsPerPage()); } // add the browse index to the Browse Info browseInfo.setBrowseIndex(browseIndex); // set the sort option for the Browse Info browseInfo.setSortOption(scope.getSortOption()); // tell the Browse Info which way we are sorting browseInfo.setAscending(scope.isAscending()); // tell the Browse Info which level of browse we are at browseInfo.setBrowseLevel(scope.getBrowseLevel()); // set the browse value if there is one browseInfo.setFocus(rawFocusValue); // tell the browse info if it is working from a starts with parameter browseInfo.setStartsWith(scope.hasStartsWith()); // tell the browse info what the container for the browse was if (scope.inCollection() || scope.inCommunity()) { browseInfo.setBrowseContainer(scope.getBrowseContainer()); } browseInfo.setResultsPerPage(scope.getResultsPerPage()); return browseInfo; } catch (SQLException e) { log.error("caught exception: ", e); throw new BrowseException(e); } }
From source file:org.elasticsearch.index.mapper.core.TypeParsers.java
private static void parseAnalyzersAndTermVectors(FieldMapper.Builder builder, String name, Map<String, Object> fieldNode, Mapper.TypeParser.ParserContext parserContext) { NamedAnalyzer indexAnalyzer = builder.fieldType().indexAnalyzer(); NamedAnalyzer searchAnalyzer = builder.fieldType().searchAnalyzer(); for (Iterator<Map.Entry<String, Object>> iterator = fieldNode.entrySet().iterator(); iterator.hasNext();) { Map.Entry<String, Object> entry = iterator.next(); final String propName = Strings.toUnderscoreCase(entry.getKey()); final Object propNode = entry.getValue(); if (propName.equals("term_vector")) { parseTermVector(name, propNode.toString(), builder); iterator.remove();/*from www. j a v a 2 s. co m*/ } else if (propName.equals("store_term_vectors")) { builder.storeTermVectors(nodeBooleanValue(propNode)); iterator.remove(); } else if (propName.equals("store_term_vector_offsets")) { builder.storeTermVectorOffsets(nodeBooleanValue(propNode)); iterator.remove(); } else if (propName.equals("store_term_vector_positions")) { builder.storeTermVectorPositions(nodeBooleanValue(propNode)); iterator.remove(); } else if (propName.equals("store_term_vector_payloads")) { builder.storeTermVectorPayloads(nodeBooleanValue(propNode)); iterator.remove(); } else if (propName.equals(CQL_COLLECTION)) { switch (StringUtils.lowerCase(propNode.toString())) { case "list": builder.cqlCollection(CqlCollection.LIST); break; case "set": builder.cqlCollection(CqlCollection.SET); break; case "singleton": builder.cqlCollection(CqlCollection.SINGLETON); break; } iterator.remove(); } else if (propName.equals(CQL_STRUCT)) { switch (StringUtils.lowerCase(propNode.toString())) { case "map": builder.cqlStruct(CqlStruct.MAP); break; case "udt": builder.cqlStruct(CqlStruct.UDT); break; case "tuple": builder.cqlStruct(CqlStruct.TUPLE); break; } iterator.remove(); } else if (propName.equals(CQL_MANDATORY)) { builder.cqlPartialUpdate(nodeBooleanValue(propNode)); iterator.remove(); } else if (propName.equals(CQL_PARTITION_KEY)) { builder.cqlPartitionKey(nodeBooleanValue(propNode)); iterator.remove(); } else if (propName.equals(CQL_STATIC_COLUMN)) { builder.cqlStaticColumn(nodeBooleanValue(propNode)); iterator.remove(); } else if (propName.equals(CQL_PRIMARY_KEY_ORDER)) { builder.cqlPrimaryKeyOrder(nodeIntegerValue(propNode)); iterator.remove(); } else if (propName.equals("analyzer") || // for backcompat, reading old indexes, remove for v3.0 propName.equals("index_analyzer") && parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) { NamedAnalyzer analyzer = parserContext.analysisService().analyzer(propNode.toString()); if (analyzer == null) { throw new MapperParsingException( "analyzer [" + propNode.toString() + "] not found for field [" + name + "]"); } indexAnalyzer = analyzer; iterator.remove(); } else if (propName.equals("search_analyzer")) { NamedAnalyzer analyzer = parserContext.analysisService().analyzer(propNode.toString()); if (analyzer == null) { throw new MapperParsingException( "analyzer [" + propNode.toString() + "] not found for field [" + name + "]"); } searchAnalyzer = analyzer; iterator.remove(); } } if (indexAnalyzer == null) { if (searchAnalyzer != null) { // If the index was created before 2.0 then we are trying to upgrade the mappings so use the default indexAnalyzer // instead of throwing an exception so the user is able to upgrade if (parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) { indexAnalyzer = parserContext.analysisService().defaultIndexAnalyzer(); } else { throw new MapperParsingException( "analyzer on field [" + name + "] must be set when search_analyzer is set"); } } } else if (searchAnalyzer == null) { searchAnalyzer = indexAnalyzer; } builder.indexAnalyzer(indexAnalyzer); builder.searchAnalyzer(searchAnalyzer); }