List of usage examples for org.apache.commons.lang3 StringUtils isNoneEmpty
public static boolean isNoneEmpty(final CharSequence... css)
Checks if none of the CharSequences are empty ("") or null.
StringUtils.isNoneEmpty(null) = false StringUtils.isNoneEmpty(null, "foo") = false StringUtils.isNoneEmpty("", "bar") = false StringUtils.isNoneEmpty("bob", "") = false StringUtils.isNoneEmpty(" bob ", null) = false StringUtils.isNoneEmpty(" ", "bar") = true StringUtils.isNoneEmpty("foo", "bar") = true
From source file:io.cloudslang.content.utils.BooleanUtilities.java
/** * If the string is null or empty string, it returns the defaultValue otherwise it returns the boolean value (see tooBoolean) * * @param booleanStr the string to convert to boolean * @param defaultValue the default value if the string is empty or null * @return true if the booleanStr is 'true', false if it's 'false' * @throws IllegalArgumentException if the booleanStr is not a valid boolean *//*from w ww. j a v a 2 s .com*/ public static boolean toBoolean(@Nullable final String booleanStr, final boolean defaultValue) { return StringUtils.isNoneEmpty(booleanStr) ? toBoolean(booleanStr) : defaultValue; }
From source file:com.gst.commands.provider.CommandHandlerProvider.java
/** * Returns a handler for the given entity and action.<br/> * <br/>/*from w ww .j a v a 2 s . c om*/ * Throws an {@link UnsupportedCommandException} if no handler * for the given entity, action combination can be found. * @param entity the entity to lookup the handler, must be given. * @param action the action to lookup the handler, must be given. */ public NewCommandSourceHandler getHandler(final String entity, final String action) { Preconditions.checkArgument(StringUtils.isNoneEmpty(entity), "An entity must be given!"); Preconditions.checkArgument(StringUtils.isNoneEmpty(action), "An action must be given!"); final String key = entity + "|" + action; if (!this.registeredHandlers.containsKey(key)) { throw new UnsupportedCommandException(key); } return (NewCommandSourceHandler) this.applicationContext.getBean(this.registeredHandlers.get(key)); }
From source file:com.axibase.tsd.driver.jdbc.AtsdDriver.java
private DriverVersion getDriverVersion(final Properties properties) { String driverName = properties.getProperty(DRIVER_NAME_KEY, JDBC_DRIVER_NAME); String driverVersion = properties.getProperty(DRIVER_VERSION_KEY, JDBC_DRIVER_VERSION_DEFAULT); String productName = properties.getProperty(PRODUCT_NAME_KEY, DATABASE_PRODUCT_NAME); String productVersion = properties.getProperty(PRODUCT_VERSION_KEY, DATABASE_PRODUCT_VERSION); String property = properties.getProperty(DATABASE_VERSION_MAJOR_KEY); int productVersionMajor = StringUtils.isNoneEmpty(property) ? NumberUtils.toInt(property) : 1; property = properties.getProperty(DATABASE_VERSION_MINOR_KEY); int productVersionMinor = StringUtils.isNoneEmpty(property) ? NumberUtils.toInt(property) : 0; property = properties.getProperty(DRIVER_VERSION_MAJOR_KEY); int driverVersionMajor = StringUtils.isNoneEmpty(property) ? NumberUtils.toInt(property) : DRIVER_VERSION_MAJOR_DEFAULT; property = properties.getProperty(DRIVER_VERSION_MINOR_KEY); int driverVersionMinor = StringUtils.isNoneEmpty(property) ? NumberUtils.toInt(property) : DRIVER_VERSION_MINOR_DEFAULT; final boolean jdbcCompliant = false; if (logger.isDebugEnabled()) { logger.debug("[createDriverVersion] " + driverVersion); }/*from w ww. j av a2s .c o m*/ return new DriverVersion(driverName, driverVersion, productName, productVersion, jdbcCompliant, driverVersionMajor, driverVersionMinor, productVersionMajor, productVersionMinor); }
From source file:com.ludgerpeters.acl.UserAclManagerImp.java
@Override public boolean checkUserPassword(String username, String password) throws AuthenticationException { String passwordHash = userRepository.getPasswordHash(username); if (passwordHash == null) { throw new UserNotFoundException(); }//w ww . j a v a2 s . c om if (StringUtils.isNoneEmpty(password)) { return passwordHashing.checkPassword(password, passwordHash); } return false; }
From source file:com.smapley.vehicle.activity.SetActivity.java
private void checkCP() { String cp = keyboardUtil.getData(); if (StringUtils.isNoneEmpty(cp) && cp.length() == 7) { updateCP(cp);//from ww w . j a v a2 s .c o m } else { showToast(R.string.set_right_cp); } }
From source file:com.smi.travel.masterdata.controller.MCommissionDetailController.java
@Override protected ModelAndView process(HttpServletRequest request, HttpServletResponse response, HttpSession session) { String action = request.getParameter("action"); String actionDelete = request.getParameter("actionDelete"); String counter = request.getParameter("counterCommission"); String currentAgentCommissionId = StringUtils.isNoneEmpty(request.getParameter("agentCommissionId")) ? request.getParameter("agentCommissionId") : null;/*from w ww . ja va 2 s .c o m*/ String agentId = request.getParameter("InputAgentId"); String agentCode = request.getParameter("InputAgentCode"); String agentName = request.getParameter("InputAgentName"); String tourId = StringUtils.isNotEmpty(request.getParameter("InputTourId")) ? request.getParameter("InputTourId") : null; String tourCode = request.getParameter("InputTourCode"); String tourName = request.getParameter("InputTourName"); String checkPay = request.getParameter("CheckPay"); String agentTourComId = request.getParameter("agentTourComId"); String AgentCommissionID = request.getParameter("AgentComID"); String operation = ""; log.info("action=" + action + ",counter=" + counter + "," + "currentAgentCommissionId=" + currentAgentCommissionId + "," + "agentId=" + agentId + ",tourId=" + tourId + ",checkPay=" + checkPay + ""); log.info("agentCode=" + agentCode + " , agentName=" + agentName); Integer checkPayInt = 0; if (checkPay != null) { checkPayInt = 1; } Agent agent = new Agent(); agent.setId(agentId); agent.setCode(agentCode); agent.setName(agentName); Daytour daytour = new Daytour(); daytour.setId(tourId); daytour.setCode(tourCode); daytour.setName(tourName); AgentComission agentcommission = new AgentComission(); List<AgentTourComission> agentTourCommissions = new <AgentTourComission>ArrayList(); if (StringUtils.isEmpty(currentAgentCommissionId)) { System.out.println("No id"); operation = "insert"; agentcommission = new AgentComission(); } else { System.out.println("Has id"); operation = "update"; agentTourCommissions = mtourCommissionService.getTourCommissionFromID(currentAgentCommissionId, tourId); if (agentTourCommissions != null) { if (!agentTourCommissions.isEmpty()) { System.out.println("agentTourCommissions = " + agentTourCommissions); agentcommission = agentTourCommissions.get(0).getAgentComission(); daytour = agentTourCommissions.get(0).getDaytour(); System.out.println("agentcommission = " + agentcommission.getId()); } } } if ("new".equalsIgnoreCase(action)) { List<Agent> listAgent = utilservice.getListAgent(); List<Daytour> listTour = daytourservice.searchTourList(daytour, 2); request.setAttribute(AgentList, listAgent); request.setAttribute(TourList, listTour); request.setAttribute(AgentTourCommissions, agentTourCommissions); request.setAttribute(AgentCommissions, agentcommission); request.setAttribute(AgentTours, daytour); return MCommissionDetail; } else if ("edit".equalsIgnoreCase(action)) { } else if ("save".equalsIgnoreCase(action)) { System.out.println("1111"); AgentTourComission agenttourcommission = new AgentTourComission(); agentcommission.setAgent(agent); agentcommission.setIsPay(checkPayInt); setAgentTourCommissionRows(request, counter, agentcommission, daytour); agenttourcommission.setAgentComission(agentcommission); agenttourcommission.setDaytour(daytour); String validateValue = mtourCommissionService.ValidateTourCommission(agenttourcommission, operation); System.out.println("validateValue :" + validateValue); if (StringUtils.isNotEmpty(validateValue)) { request.setAttribute(VALIDATE, validateValue); } else { if (StringUtils.isEmpty(currentAgentCommissionId)) { System.out.println("2222"); String saveTransaction = mtourCommissionService.SaveTourCommission(agentcommission); request.setAttribute(ResultSave, "save : " + saveTransaction); List<AgentTourComission> list = mtourCommissionService .SearchAgentTourComission(agenttourcommission, 1); request.setAttribute(AgentTourCommissions, list); return MCommission; } else { System.out.println("3333"); String transactionUpdate = mtourCommissionService.SaveTourCommission(agentcommission); //agentTourCommissions = mtourCommissionService.getTourCommissionFromID(currentAgentCommissionId, tourId); if (transactionUpdate.equalsIgnoreCase("success")) { request.setAttribute(ResultSave, "update successful"); agentTourCommissions = mtourCommissionService .getTourCommissionFromID(currentAgentCommissionId, tourId); } else { request.setAttribute(ResultSave, "update unsuccessful"); } List<AgentTourComission> list = mtourCommissionService .SearchAgentTourComission(agenttourcommission, 1); request.setAttribute(AgentTourCommissions, list); return MCommission; // return new ModelAndView("redirect:MCommissionDetail.smi?agentCommissionId="+currentAgentCommissionId+"&AgentComID="+AgentCommissionID+"&InputTourId="+tourId+"&action=edit&result="+transactionUpdate+""); //return new ModelAndView("redirect:MCommissionDetail.smi?agentCommissionId="+currentAgentCommissionId+"&AgentComID="+AgentCommissionID+"&InputTourId="+tourId+"&action=edit&result="+transactionUpdate+""); } } } if ("delete".equalsIgnoreCase(actionDelete)) { log.info("agentTourComId = " + agentTourComId); AgentTourComission agenttourcom = new AgentTourComission(); agenttourcom.setId(agentTourComId); String transactionDelete = mtourCommissionService.DeleteComissionPrice(agenttourcom); request.setAttribute(COMMISSIONDELETE, "delete " + transactionDelete); } Daytour daytours = new Daytour(); List<Agent> listAgent = utilservice.getListAgent(); List<Daytour> listTour = daytourservice.searchTourList(daytours, 2); request.setAttribute(AgentList, listAgent); request.setAttribute(TourList, listTour); request.setAttribute(AgentTourCommissions, agentTourCommissions); request.setAttribute(AgentCommissions, agentcommission); request.setAttribute(AgentTours, daytour); request.setAttribute(AgentComID, AgentCommissionID); request.setAttribute("agentCommissionId", currentAgentCommissionId); return MCommissionDetail; }
From source file:io.cloudslang.content.database.services.SQLCommandService.java
public static String executeSqlCommand(final SQLInputs sqlInputs) throws Exception { final ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)) { connection.setReadOnly(false);// w ww . j a v a2 s .com final String dbType = sqlInputs.getDbType(); if (ORACLE_DB_TYPE.equalsIgnoreCase(dbType) && sqlInputs.getSqlCommand().toLowerCase().contains(DBMS_OUTPUT)) { final PreparedStatement preparedStatement = connection.prepareStatement(sqlInputs.getSqlCommand()); preparedStatement.setQueryTimeout(sqlInputs.getTimeout()); OracleDbmsOutput oracleDbmsOutput = new OracleDbmsOutput(connection); preparedStatement.executeQuery(); sqlInputs.setIUpdateCount(preparedStatement.getUpdateCount()); preparedStatement.close(); final String output = oracleDbmsOutput.getOutput(); oracleDbmsOutput.close(); return output; } else { final Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); try { statement.execute(sqlInputs.getSqlCommand()); } catch (SQLException e) { if (SYBASE_DB_TYPE.equalsIgnoreCase(dbType)) { //during a dump sybase sends back status as exceptions. if (sqlInputs.getSqlCommand().trim().toLowerCase().startsWith("dump")) { return SQLUtils.processDumpException(e); } else if (sqlInputs.getSqlCommand().trim().toLowerCase().startsWith("load")) { return SQLUtils.processLoadException(e); } } else { throw e; } } ResultSet rs = statement.getResultSet(); if (rs != null) { ResultSetMetaData rsMtd = rs.getMetaData(); if (rsMtd != null) { sqlInputs.getLRows().clear(); int colCount = rsMtd.getColumnCount(); if (sqlInputs.getSqlCommand().trim().toLowerCase().startsWith("dbcc")) { while (rs.next()) { if (colCount >= 4) { sqlInputs.getLRows().add(rs.getString(4)); } } } else { String delimiter = (StringUtils.isNoneEmpty(sqlInputs.getStrDelim())) ? sqlInputs.getStrDelim() : ","; String strRowHolder; while (rs.next()) { strRowHolder = ""; for (int i = 1; i <= colCount; i++) { if (i > 1) { strRowHolder += delimiter; } strRowHolder += rs.getString(i); } sqlInputs.getLRows().add(strRowHolder); } } rs.close(); } } //For sybase, when dbcc command is executed, the result is shown in warning message else if (dbType.equalsIgnoreCase(SYBASE_DB_TYPE) && sqlInputs.getSqlCommand().trim().toLowerCase().startsWith("dbcc")) { SQLWarning warning = statement.getWarnings(); while (warning != null) { sqlInputs.getLRows().add(warning.getMessage()); warning = warning.getNextWarning(); } } sqlInputs.setIUpdateCount(statement.getUpdateCount()); } } return "Command completed successfully"; }
From source file:cn.afterturn.easypoi.excel.imports.base.ImportBaseService.java
/** * ?/*from w w w .j av a2 s. c o m*/ * * @param targetId * @param field * @param excelEntity * @param pojoClass * @param getMethods * @param temp * @throws Exception */ public void addEntityToMap(String targetId, Field field, ExcelImportEntity excelEntity, Class<?> pojoClass, List<Method> getMethods, Map<String, ExcelImportEntity> temp, ExcelEntity excelEntityAnn) throws Exception { Excel excel = field.getAnnotation(Excel.class); excelEntity = new ExcelImportEntity(); excelEntity.setType(excel.type()); excelEntity.setSaveUrl(excel.savePath()); excelEntity.setSaveType(excel.imageType()); excelEntity.setReplace(excel.replace()); excelEntity.setDatabaseFormat(excel.databaseFormat()); excelEntity.setSuffix(excel.suffix()); excelEntity.setImportField( Boolean.valueOf(PoiPublicUtil.getValueByTargetId(excel.isImportField(), targetId, "false"))); excelEntity.setFixedIndex(excel.fixedIndex()); excelEntity.setName(PoiPublicUtil.getValueByTargetId(excel.name(), targetId, null)); if (StringUtils.isNoneEmpty(excel.groupName())) { excelEntity.setName(excel.groupName() + "_" + excelEntity.getName()); } if (excelEntityAnn != null && excelEntityAnn.show()) { excelEntity.setName(excelEntityAnn.name() + "_" + excelEntity.getName()); } if (i18nHandler != null) { excelEntity.setName(i18nHandler.getLocaleName(excelEntity.getName())); } excelEntity.setMethod(PoiReflectorUtil.fromCache(pojoClass).getSetMethod(field.getName())); if (StringUtils.isNotEmpty(excel.importFormat())) { excelEntity.setFormat(excel.importFormat()); } else { excelEntity.setFormat(excel.format()); } excelEntity.setDict(excel.dict()); excelEntity.setEnumImportMethod(excel.enumImportMethod()); if (getMethods != null) { List<Method> newMethods = new ArrayList<Method>(); newMethods.addAll(getMethods); newMethods.add(excelEntity.getMethod()); excelEntity.setMethods(newMethods); } if (excelEntity.getFixedIndex() != -1) { temp.put("FIXED_" + excelEntity.getFixedIndex(), excelEntity); } else { temp.put(excelEntity.getName(), excelEntity); } }
From source file:cn.afterturn.easypoi.excel.export.base.ExportCommonService.java
private Object dateFormatValue(Object value, ExcelExportEntity entity) throws Exception { Date temp = null;//from w w w. jav a 2 s . co m if (value instanceof String && StringUtils.isNoneEmpty(value.toString())) { SimpleDateFormat format = new SimpleDateFormat(entity.getDatabaseFormat()); temp = format.parse(value.toString()); } else if (value instanceof Date) { temp = (Date) value; } else if (value instanceof Instant) { Instant instant = (Instant) value; temp = Date.from(instant); } else if (value instanceof LocalDate) { LocalDate localDate = (LocalDate) value; temp = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); } else if (value instanceof LocalDateTime) { LocalDateTime localDateTime = (LocalDateTime) value; temp = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); } else if (value instanceof java.sql.Date) { temp = new Date(((java.sql.Date) value).getTime()); } else if (value instanceof java.sql.Time) { temp = new Date(((java.sql.Time) value).getTime()); } else if (value instanceof java.sql.Timestamp) { temp = new Date(((java.sql.Timestamp) value).getTime()); } if (temp != null) { SimpleDateFormat format = new SimpleDateFormat(entity.getFormat()); if (StringUtils.isNotEmpty(entity.getTimezone())) { format.setTimeZone(TimeZone.getTimeZone(entity.getTimezone())); } value = format.format(temp); } return value; }
From source file:com.devicehive.resource.impl.DeviceNotificationResourceImpl.java
/** * {@inheritDoc}//w ww .ja v a2 s . c o m */ @Override public void query(String guid, String startTs, String endTs, String notification, String sortField, String sortOrderSt, Integer take, Integer skip, @Suspended final AsyncResponse asyncResponse) { logger.debug("Device notification query requested for device {}", guid); final Date timestampSt = TimestampQueryParamParser.parse(startTs); final Date timestampEnd = TimestampQueryParamParser.parse(endTs); DeviceVO byGuidWithPermissionsCheck = deviceService.getDeviceWithNetworkAndDeviceClass(guid); if (byGuidWithPermissionsCheck == null) { ErrorResponse errorCode = new ErrorResponse(NOT_FOUND.getStatusCode(), String.format(Messages.DEVICE_NOT_FOUND, guid)); Response response = ResponseFactory.response(NOT_FOUND, errorCode); asyncResponse.resume(response); } else { Set<String> notificationNames = StringUtils.isNoneEmpty(notification) ? Collections.singleton(notification) : Collections.emptySet(); notificationService.find(Collections.singleton(guid), notificationNames, timestampSt, timestampEnd) .thenApply(notifications -> { final Comparator<DeviceNotification> comparator = CommandResponseFilterAndSort .buildDeviceNotificationComparator(sortField); final Boolean reverse = sortOrderSt == null ? null : "desc".equalsIgnoreCase(sortOrderSt); final List<DeviceNotification> sortedDeviceNotifications = CommandResponseFilterAndSort .orderAndLimit(notifications, comparator, reverse, skip, take); return ResponseFactory.response(OK, sortedDeviceNotifications, JsonPolicyDef.Policy.NOTIFICATION_TO_CLIENT); }).thenAccept(asyncResponse::resume); } }