List of usage examples for org.apache.commons.lang3 StringUtils equalsIgnoreCase
public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2)
Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.
null s are handled without exceptions.
From source file:de.micromata.genome.gwiki.page.search.expr.SearchExpressionParser.java
protected SearchResultComparatorBase createComparator(TokenResultList tks, SearchResultComparatorBase last) { // order by modby, modat, title, page SearchResultComparatorBase src = consumeThisComparator(tks); tks.skipping(TK_SPACE);/*from ww w .j a v a 2s . co m*/ if (tks.eof() == true) { return src; } if (tks.eof() || tks.curToken().getTokenType() == TK_COMMA) { return src; } if (StringUtils.equalsIgnoreCase(tks.curToken().getConsumed(), "DESC") == true) { src.setDesc(true); tks.nextTokenSkipping(TK_SPACE); } else if (StringUtils.equalsIgnoreCase(tks.curToken().getConsumed(), "ASC") == true) { tks.nextTokenSkipping(TK_SPACE); } else { throw new InvalidMatcherGrammar("expect ',' for the next order expression"); } return src; // if (tks.eof() == true) // return src; // if (tks.curToken().getTokenType() == TK_COMMA) { // tks.nextToken(); // return src; // } // throw new InvalidMatcherGrammar("expect ',' or end of expression for the next order expression"); }
From source file:com.glaf.core.util.DBUtils.java
public static void createIndex(Connection connection, String tableName, String columnName, String indexName) { DatabaseMetaData dbmd = null; Statement stmt = null;/*from www . java2 s .com*/ ResultSet rs = null; boolean hasIndex = false; boolean autoCommit = false; try { autoCommit = connection.getAutoCommit(); dbmd = connection.getMetaData(); rs = dbmd.getIndexInfo(null, null, tableName, false, false); while (rs.next()) { String col = rs.getString("COLUMN_NAME"); if (StringUtils.equalsIgnoreCase(columnName, col)) { hasIndex = true; break; } } JdbcUtils.close(rs); if (!hasIndex) { String sql = " create index " + indexName.toUpperCase() + " on " + tableName + " (" + columnName + ") "; connection.setAutoCommit(false); stmt = connection.createStatement(); stmt.executeUpdate(sql); JdbcUtils.close(stmt); connection.commit(); connection.setAutoCommit(autoCommit); } } catch (Exception ex) { throw new RuntimeException(ex); } finally { JdbcUtils.close(rs); JdbcUtils.close(stmt); } }
From source file:com.nesscomputing.httpclient.factory.httpclient4.ApacheHttpClient4Factory.java
private <T> HttpClientRequest<T> contributeAcceptEncoding(HttpClientRequest<T> request) { if (defaultAcceptEncoding == null) { return request; }/*from w w w .j ava 2 s. c o m*/ for (HttpClientHeader h : request.getHeaders()) { if (StringUtils.equalsIgnoreCase(HttpHeaders.ACCEPT_ENCODING, h.getName())) { return request; } } return HttpClientRequest.Builder.fromRequest(request) .addHeader(HttpHeaders.ACCEPT_ENCODING, defaultAcceptEncoding).request(); }
From source file:com.github.binlee1990.spider.movie.spider.MovieCrawler.java
private void setFilmRelated(Document doc, Film film) { Elements keyElements = doc.select(".fm-minfo dt"); Elements valueElements = doc.select(".fm-minfo dd"); if (CollectionUtils.isNotEmpty(keyElements) && CollectionUtils.isNotEmpty(valueElements)) { int keyI = 0; for (; keyI < keyElements.size(); keyI++) { Element keyElement = keyElements.get(keyI); Element valueElement = valueElements.get(keyI); if (null != keyElement && null != valueElement) { String key = StringUtils.trimToEmpty(keyElement.text().toString()); if (StringUtils.isNotBlank(key)) { String value = StringUtils.trimToEmpty(valueElement.text().toString()); if (StringUtils.equalsIgnoreCase(key, "")) { Director director = createOrQueryDirector(value); if (null != director) { film.setDirectorId(director.getId()); }// w w w . j a v a 2 s. c o m film.setDirector(value); } if (StringUtils.equalsIgnoreCase(key, "")) { } if (StringUtils.equalsIgnoreCase(key, "")) { } if (StringUtils.equalsIgnoreCase(key, "")) { String urlYear = getFilmUrlYear(doc, value); if (StringUtils.isNotBlank(urlYear)) { EnumYear enumYear = queryEnumYear(urlYear); if (null != enumYear) { film.setYearId(enumYear.getId()); } } Date releaseDate = getFilmReleaseDate(value); if (null != releaseDate) { film.setReleaseDate(releaseDate); } } if (StringUtils.equalsIgnoreCase(key, "")) { int length = getFilmLength(value); film.setLength(length); } if (StringUtils.equalsIgnoreCase(key, "??")) { if (StringUtils.isNotBlank(value)) { film.setAlias(value); } } } } } } }
From source file:com.ottogroup.bi.streaming.operator.json.aggregate.WindowedJsonContentAggregator.java
/** * Adds the requested set of optional fields to provided {@link JSONObject} * @param jsonObject// ww w . j a va2 s.c o m * The {@link JSONObject} to add optional fields to * @param optionalFields * The optional fields along with the requested values to be added to the provided {@link JSONObject} * @param dateFormatter * The format to apply when adding time stamp values * @param totalMessageCount * The total number of messages received from the window * @return * The provided {@link JSONObject} enhanced by the requested values * @throws JSONException * Thrown in case anything fails during operations on the JSON object */ protected JSONObject addOptionalFields(final JSONObject jsonObject, final Map<String, String> optionalFields, final SimpleDateFormat dateFormatter, final int totalMessageCount) throws JSONException { // step through the optional fields if any were provided if (jsonObject != null && optionalFields != null && !optionalFields.isEmpty()) { for (final String fieldName : optionalFields.keySet()) { final String value = optionalFields.get(fieldName); // check if the value references a pre-defined type and thus requests a special value or // whether the field name must be added along with the value without any modifications if (StringUtils.equalsIgnoreCase(value, OPTIONAL_FIELD_TYPE_TIMESTAMP)) jsonObject.put(fieldName, dateFormatter.format(new Date())); else if (StringUtils.equalsIgnoreCase(value, OPTIONAL_FIELD_TYPE_TOTAL_MESSAGE_COUNT)) jsonObject.put(fieldName, totalMessageCount); else jsonObject.put(fieldName, value); } } return jsonObject; }
From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineFactory.java
/** * Initializes a {@link StreamingMessageQueue} instance according to provided information. * @param queueConfiguration+/*from w w w. java2s .c om*/ * @return * @throws RequiredInputMissingException * @throws QueueInitializationFailedException */ protected StreamingMessageQueue initializeQueue(final StreamingMessageQueueConfiguration queueConfiguration) throws RequiredInputMissingException, QueueInitializationFailedException { /////////////////////////////////////////////////////////////////////////////////// // validate input if (queueConfiguration == null) throw new RequiredInputMissingException("Missing required queue configuration"); if (StringUtils.isBlank(queueConfiguration.getId())) throw new RequiredInputMissingException("Missing required queue identifier"); // /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// // check properties for optional settings boolean inMemoryQueue = false; if (queueConfiguration.getProperties() != null && !queueConfiguration.getProperties().isEmpty()) { String queueType = StringUtils.lowerCase(StringUtils .trim(queueConfiguration.getProperties().getProperty(StreamingMessageQueue.CFG_QUEUE_TYPE))); inMemoryQueue = StringUtils.equalsIgnoreCase(queueType, InMemoryStreamingMessageQueue.CFG_QUEUE_TYPE); } /////////////////////////////////////////////////////////////////////////////////// if (inMemoryQueue) { try { StreamingMessageQueue queue = new InMemoryStreamingMessageQueue(); queue.setId(StringUtils.lowerCase(StringUtils.trim(queueConfiguration.getId()))); queue.initialize((queueConfiguration.getProperties() != null ? queueConfiguration.getProperties() : new Properties())); return queue; } catch (Exception e) { throw new QueueInitializationFailedException("Failed to initialize streaming message queue '" + queueConfiguration.getId() + "'. Error: " + e.getMessage()); } } try { StreamingMessageQueue queue = new DefaultStreamingMessageQueue(); queue.setId(StringUtils.lowerCase(StringUtils.trim(queueConfiguration.getId()))); queue.initialize((queueConfiguration.getProperties() != null ? queueConfiguration.getProperties() : new Properties())); return queue; } catch (Exception e) { throw new QueueInitializationFailedException("Failed to initialize streaming message queue '" + queueConfiguration.getId() + "'. Error: " + e.getMessage()); } }
From source file:com.glaf.core.service.impl.MxSysDataTableServiceImpl.java
@Transactional public void saveData(String datatableId, Map<String, Object> dataMap) { SysDataTable dataTable = this.getDataTableById(datatableId); Map<String, Object> newData = new HashMap<String, Object>(); Set<Entry<String, Object>> entrySet = dataMap.entrySet(); for (Entry<String, Object> entry : entrySet) { String key = entry.getKey(); Object value = entry.getValue(); if (value != null) { newData.put(key, value);//w w w . ja va 2s . c om newData.put(key.toUpperCase(), value); } } SysDataField idField = null; List<SysDataField> fields = dataTable.getFields(); if (fields != null && !fields.isEmpty()) { for (SysDataField field : fields) { if (StringUtils.equalsIgnoreCase("1", field.getPrimaryKey()) || StringUtils.equalsIgnoreCase("Y", field.getPrimaryKey()) || StringUtils.equalsIgnoreCase("true", field.getPrimaryKey())) { idField = field; break; } } } if (idField == null) { throw new java.lang.RuntimeException("primary key not found."); } Object idValue = newData.get(idField.getColumnName().toUpperCase()); if (idValue == null) { idValue = newData.get(idField.getName().toUpperCase()); } TableModel row = new TableModel(); row.setTableName(dataTable.getTablename()); ColumnModel col01 = new ColumnModel(); col01.setColumnName(idField.getColumnName()); if (idValue == null) { if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Integer")) { col01.setJavaType("Long"); Long id = idGenerator.nextId(); col01.setIntValue(id.intValue()); col01.setValue(Integer.valueOf(id.intValue())); } else if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Long")) { col01.setJavaType("Long"); Long id = idGenerator.nextId(); col01.setLongValue(id); col01.setValue(id); } else { col01.setJavaType("String"); String id = idGenerator.getNextId(); col01.setStringValue(id); col01.setValue(id); } row.setIdColumn(col01); row.addColumn(col01); } else { if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Integer")) { col01.setJavaType("Long"); String id = idValue.toString(); col01.setIntValue(Integer.parseInt(id)); col01.setValue(col01.getIntValue()); } else if (StringUtils.equalsIgnoreCase(idField.getDataType(), "Long")) { col01.setJavaType("Long"); String id = idValue.toString(); col01.setLongValue(Long.parseLong(id)); col01.setValue(col01.getLongValue()); } else { col01.setJavaType("String"); String id = idValue.toString(); col01.setStringValue(id); col01.setValue(id); } row.setIdColumn(col01); row.addColumn(col01); } if (fields != null && !fields.isEmpty()) { for (SysDataField field : fields) { if (StringUtils.equalsIgnoreCase(idField.getColumnName(), field.getColumnName())) { continue; } String name = field.getColumnName().toUpperCase(); String javaType = field.getDataType(); ColumnModel c = new ColumnModel(); c.setColumnName(field.getColumnName()); c.setJavaType(javaType); Object value = newData.get(name); if (value != null) { if ("Integer".equals(javaType)) { value = ParamUtils.getInt(newData, name); } else if ("Long".equals(javaType)) { value = ParamUtils.getLong(newData, name); } else if ("Double".equals(javaType)) { value = ParamUtils.getDouble(newData, name); } else if ("Date".equals(javaType)) { value = ParamUtils.getTimestamp(newData, name); } else if ("String".equals(javaType)) { value = ParamUtils.getString(newData, name); } else if ("Clob".equals(javaType)) { value = ParamUtils.getString(newData, name); } c.setValue(value); row.addColumn(c); } else { name = field.getName().toUpperCase(); value = newData.get(name); if (value != null) { if ("Integer".equals(javaType)) { value = ParamUtils.getInt(newData, name); } else if ("Long".equals(javaType)) { value = ParamUtils.getLong(newData, name); } else if ("Double".equals(javaType)) { value = ParamUtils.getDouble(newData, name); } else if ("Date".equals(javaType)) { value = ParamUtils.getTimestamp(newData, name); } else if ("String".equals(javaType)) { value = ParamUtils.getString(newData, name); } else if ("Clob".equals(javaType)) { value = ParamUtils.getString(newData, name); } c.setValue(value); row.addColumn(c); } } } } if (idValue == null) { tableDataMapper.insertTableData(row); } else { tableDataMapper.updateTableDataByPrimaryKey(row); } }
From source file:com.glaf.dts.transform.MxTransformManager.java
/** * ?/*w ww . ja v a2 s.c o m*/ * * @param query * * @param target * (?) */ protected void transformSingle(QueryDefinition query, TableDefinition target, Map<String, Object> paramMap) { logger.debug("------------------------------transformSingle--------------"); if (!StringUtils.equalsIgnoreCase(query.getTargetTableName(), target.getTableName())) { return; } String taskId = query.getId() + "_exec_0"; TransformTask task = new TransformTask(); task.setId(taskId); task.setStatus(0); task.setQueryId(query.getId()); task.setTitle(query.getTitle() + " "); task.setSortNo(0); JsonFactory f = new JsonFactory(); ObjectMapper mapper = new ObjectMapper(f); Writer w = new StringWriter(); try { mapper.writeValue(w, paramMap); task.setParameter(w.toString()); } catch (Exception e) { task.setParameter(JsonUtils.encode(paramMap)); } transformTaskService.save(task); MxTransformThread thread = new MxTransformThread(taskId); thread.run(); // org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor // executor = ContextFactory // .getBean("threadPoolTaskExecutor"); // if (executor != null) { // executor.execute(thread); // } }
From source file:com.glaf.core.util.DBUtils.java
public static void createIndex(String systemName, String tableName, String columnName, String indexName) { Connection connection = null; DatabaseMetaData dbmd = null; Statement stmt = null;/* www.j av a 2s. c o m*/ ResultSet rs = null; boolean hasIndex = false; try { connection = DBConnectionFactory.getConnection(systemName); dbmd = connection.getMetaData(); rs = dbmd.getIndexInfo(null, null, tableName, false, false); while (rs.next()) { String col = rs.getString("COLUMN_NAME"); if (StringUtils.equalsIgnoreCase(columnName, col)) { hasIndex = true; break; } } JdbcUtils.close(rs); if (!hasIndex) { String sql = " create index " + indexName.toUpperCase() + " on " + tableName + " (" + columnName + ") "; connection.setAutoCommit(false); stmt = connection.createStatement(); stmt.executeUpdate(sql); JdbcUtils.close(stmt); connection.commit(); } } catch (Exception ex) { throw new RuntimeException(ex); } finally { JdbcUtils.close(rs); JdbcUtils.close(stmt); JdbcUtils.close(connection); } }
From source file:com.nridge.connector.fs.con_fs.task.TaskConnectorFS.java
private boolean executePhase(String aName) { for (String phaseName : mPhases) { if ((StringUtils.equalsIgnoreCase(aName, phaseName)) || (StringUtils.equalsIgnoreCase(phaseName, Connector.PHASE_ALL))) return true; }//from w ww . j ava2 s . c o m return false; }