Java Code Examples for org.apache.commons.lang.StringUtils#lowerCase()

The following examples show how to use org.apache.commons.lang.StringUtils#lowerCase() . 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: PageRequest.java    From DWSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 设置排序方式向.
 * 
 * @param orderDir
 *            可选值为desc或asc,多个排序字段时用','分隔.
 */
public void setOrderDir(final String orderDir) {
	String lowcaseOrderDir = StringUtils.lowerCase(orderDir);

	// 检查order字符串的合法值
	String[] orderDirs = StringUtils.split(lowcaseOrderDir, ',');
	for (String orderDirStr : orderDirs) {
		if (!StringUtils.equals(Sort.DESC, orderDirStr)
				&& !StringUtils.equals(Sort.ASC, orderDirStr)) {
			throw new IllegalArgumentException("排序方向" + orderDirStr
					+ "不是合法值");
		}
	}

	this.orderDir = lowcaseOrderDir;
}
 
Example 2
Source File: ProjectExplorerContentProvider.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
   * Tests whether primary extension defined in the SDK permits resource to be shown in navigator tree
   * @param sdk
   * @param resource
   * @return
   */
  private boolean isSdkSettingsAllowXdsElementInNavigator( Sdk sdk, IXdsElement  xdsElement) {
  	String fullPath = getNameWithExtension(xdsElement);
  	if (fullPath == null) {
  		return false;
  	}
  	String[] extensions;
  	if (sdk != null) {
  		extensions = sdk.getPrimaryFileExtensionsAsArray();
  	}
  	else {
          extensions = Sdk.getDefaultPrimaryFileExtensionsAsArray();
  	}
  	String resourceName = StringUtils.lowerCase(fullPath);
if (ArrayUtils.indexOf(extensions, FilenameUtils.getExtension(resourceName))> -1) {
	return true;
  	}
  	
  	return false;
  }
 
Example 3
Source File: ServerUtil.java    From mcspring-boot with MIT License 5 votes vote down vote up
/**
 * Get the most unique id available for the {@param sender}.
 * If the server is in online mode, it will return the {@param sender} UUID, otherwise will return the player username in lower case.
 *
 * @param sender the sender to get the id from
 * @return the sender id, null if null sender input
 */
public String getSenderId(CommandSender sender) {
    if (sender == null) {
        return null;
    }
    if (sender instanceof ConsoleCommandSender) {
        return CONSOLE_SENDER_ID;
    }
    if (!(sender instanceof OfflinePlayer)) {
        return null;
    }
    val player = (OfflinePlayer) sender;
    return server.getOnlineMode() ? player.getUniqueId().toString() : StringUtils.lowerCase(player.getName());
}
 
Example 4
Source File: CurricularCourse.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String constructUniqueEnrollmentKey(String code, String name, DegreeType degreeType) {
    StringBuilder stringBuffer = new StringBuilder(50);
    stringBuffer.append(code);
    stringBuffer.append(name);
    if (degreeType != null) {
        stringBuffer.append(degreeType.toString());
    }
    return StringUtils.lowerCase(stringBuffer.toString());
}
 
Example 5
Source File: QueryFilter.java    From snakerflow with Apache License 2.0 5 votes vote down vote up
/**
 * 设置排序类型.
 * @param order 可选值为desc或asc,多个排序字段时用','分隔.
 */
public void setOrder(String order) {
    String lowcaseOrder = StringUtils.lowerCase(order);
    //检查order字符串的合法值
    String[] orders = StringUtils.split(lowcaseOrder, ',');
    for (String orderStr : orders) {
        if (!StringUtils.equals(DESC, orderStr) && !StringUtils.equals(ASC, orderStr)) {
            throw new IllegalArgumentException("排序类型[" + orderStr + "]不是合法值");
        }
    }
    this.order = lowcaseOrder;
}
 
Example 6
Source File: ShowCreateTableMyHandler.java    From tddl5 with Apache License 2.0 5 votes vote down vote up
public ISchematicCursor doShow(IDataNodeExecutor executor, ExecutionContext executionContext) throws TddlException {
    ISchematicCursor cursor = null;
    try {
        ArrayResultCursor result = new ArrayResultCursor("Create Table", executionContext);
        result.addColumn("Table", DataType.StringType);
        result.addColumn("Create Table", DataType.StringType);
        result.initMeta();

        ShowWithTable show = (ShowWithTable) executor;
        cursor = super.doShow(executor, executionContext);
        IRowSet row = null;
        while ((row = cursor.next()) != null) {
            String table = StringUtils.lowerCase(row.getString(0));
            String sql = row.getString(1);
            result.addRow(new Object[] { show.getTableName(),
                    StringUtils.replaceOnce(sql, table, show.getTableName()) });
        }

        return result;
    } finally {
        // 关闭cursor
        if (cursor != null) {
            cursor.close(new ArrayList<TddlException>());
        }
    }

}
 
Example 7
Source File: ImportTransformer.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Override
public Object apply(Object o) {
    Object ret = o;

    if(o instanceof String) {
        ret = StringUtils.lowerCase((String) o);
    }

    return ret;
}
 
Example 8
Source File: ImportPlaylistController.java    From subsonic with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map<String, Object> map = new HashMap<String, Object>();

    try {
        if (ServletFileUpload.isMultipartContent(request)) {

            FileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload upload = new ServletFileUpload(factory);
            List<?> items = upload.parseRequest(request);
            for (Object o : items) {
                FileItem item = (FileItem) o;

                if ("file".equals(item.getFieldName()) && !StringUtils.isBlank(item.getName())) {
                    if (item.getSize() > MAX_PLAYLIST_SIZE_MB * 1024L * 1024L) {
                        throw new Exception("The playlist file is too large. Max file size is " + MAX_PLAYLIST_SIZE_MB + " MB.");
                    }
                    String playlistName = FilenameUtils.getBaseName(item.getName());
                    String fileName = FilenameUtils.getName(item.getName());
                    String format = StringUtils.lowerCase(FilenameUtils.getExtension(item.getName()));
                    String username = securityService.getCurrentUsername(request);
                    Playlist playlist = playlistService.importPlaylist(username, playlistName, fileName, format, item.getInputStream(), null);
                    map.put("playlist", playlist);
                }
            }
        }
    } catch (Exception e) {
        map.put("error", e.getMessage());
    }

    ModelAndView result = super.handleRequestInternal(request, response);
    result.addObject("model", map);
    return result;
}
 
Example 9
Source File: TableMetaGenerator.java    From yugong with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 根据{@linkplain DatabaseMetaData}获取正确的表名
 *
 * <pre>
 * metaData中的storesUpperCaseIdentifiers,storesUpperCaseQuotedIdentifiers,storesLowerCaseIdentifiers,
 * storesLowerCaseQuotedIdentifiers,storesMixedCaseIdentifiers,storesMixedCaseQuotedIdentifiers
 * </pre>
 */
private static String getIdentifierName(String name, DatabaseMetaData metaData) throws SQLException {
    if (metaData.storesMixedCaseIdentifiers()) {
        return name; // 保留原始名
    } else if (metaData.storesUpperCaseIdentifiers()) {
        return StringUtils.upperCase(name);
    } else if (metaData.storesLowerCaseIdentifiers()) {
        return StringUtils.lowerCase(name);
    } else {
        return name;
    }
}
 
Example 10
Source File: ImportTransformer.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public Object apply(Object o) {
    Object ret = o;

    if(o instanceof String) {
        ret = StringUtils.lowerCase((String) o);
    }

    return ret;
}
 
Example 11
Source File: XdsFileUtils.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public static String getLowercasedExtension (String fileName) {
    return StringUtils.lowerCase(FilenameUtils.getExtension(fileName));
}
 
Example 12
Source File: RepoProxy.java    From ymate-platform-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public Object doProxy(IProxyChain proxyChain) throws Throwable {
    Repository _repo = proxyChain.getTargetMethod().getAnnotation(Repository.class);
    if (_repo == null) {
        return proxyChain.doProxyChain();
    }
    //
    IDatabase _db = JDBC.get(proxyChain.getProxyFactory().getOwner());
    ISession _session = null;
    try {
        if (StringUtils.isNotBlank(_repo.dsName())) {
            _session = _db.openSession(_repo.dsName());
        } else {
            Repository _superRepo = proxyChain.getTargetClass().getAnnotation(Repository.class);
            if (StringUtils.isNotBlank(_superRepo.dsName())) {
                _session = _db.openSession(_superRepo.dsName());
            } else {
                _session = _db.openSession();
            }
        }
        //
        IRepoScriptProcessor _processor = null;
        String _targetSQL = _repo.value();
        if (StringUtils.isBlank(_targetSQL)) {
            try {
                IConfiguration _conf = ((IRepository) proxyChain.getTargetObject()).getConfig();
                String _keyStr = StringUtils.lowerCase(_repo.item() + "_" + _session.getConnectionHolder().getDialect().getName());
                Map<String, String> _statementMap = _conf.getMap(_keyStr);
                if (_statementMap == null || _statementMap.isEmpty()) {
                    _keyStr = StringUtils.lowerCase(_repo.item());
                    _statementMap = _conf.getMap(_keyStr);
                }
                if (_statementMap == null || _statementMap.isEmpty()) {
                    throw new NullArgumentException(_keyStr);
                } else {
                    _targetSQL = _conf.getString(_keyStr);
                }
                String _targetType = StringUtils.trimToNull(_statementMap.get("language"));
                if (StringUtils.isNotBlank(_targetType)) {
                    _processor = IRepoScriptProcessor.Manager.getScriptProcessor(_targetType);
                    if (_processor != null) {
                        _processor.init(_targetSQL);
                        _targetSQL = _processor.process(_repo.item(), proxyChain.getMethodParams());
                    }
                }
            } catch (Exception e) {
                _LOG.warn("", RuntimeUtils.unwrapThrow(e));
            }
        }
        if (StringUtils.isNotBlank(_targetSQL)) {
            Object _result;
            switch (_repo.type()) {
                case UPDATE:
                    _result = _session.executeForUpdate(__buildSQL(_targetSQL, proxyChain.getTargetMethod(), proxyChain.getMethodParams()));
                    break;
                default:
                    _result = _session.find(__buildSQL(_targetSQL, proxyChain.getTargetMethod(), proxyChain.getMethodParams()), new ArrayResultSetHandler());
                    if (_processor != null && _processor.isFilterable()) {
                        _result = _processor.doFilter(_result);
                    }
            }
            if (_repo.useFilter()) {
                // 将执行结果赋予目标方法的最后一个参数
                int _position = proxyChain.getMethodParams().length - 1;
                Object _lastParam = proxyChain.getMethodParams()[_position];
                Class<?> _paramType = _lastParam != null ? proxyChain.getMethodParams()[_position].getClass() : null;
                if (_paramType != null && _paramType.isArray()) {
                    if (_result != null) {
                        proxyChain.getMethodParams()[_position] = ArrayUtils.add((Object[]) proxyChain.getMethodParams()[_position], _result);
                    }
                } else {
                    proxyChain.getMethodParams()[_position] = _result;
                }
            } else {
                return _result;
            }
        }
        return proxyChain.doProxyChain();
    } finally {
        if (_session != null) {
            _session.close();
        }
    }
}
 
Example 13
Source File: HiveResolver.java    From pxf with Apache License 2.0 4 votes vote down vote up
void initPartitionFields() {
    partitionColumnNames = new HashMap<>();
    if (partitionKeys.equals(HiveDataFragmenter.HIVE_NO_PART_TBL)) {
        return;
    }

    String[] partitionLevels = partitionKeys.split(HiveDataFragmenter.HIVE_PARTITIONS_DELIM);
    for (String partLevel : partitionLevels) {
        String[] levelKey = partLevel.split(HiveDataFragmenter.HIVE_1_PART_DELIM);
        String columnName = StringUtils.lowerCase(levelKey[0]);
        String type = levelKey[1];
        String val = levelKey[2];
        DataType convertedType;
        Object convertedValue;
        boolean isDefaultPartition;

        // check if value is default partition
        isDefaultPartition = isDefaultPartition(type, val);
        // ignore the type's parameters
        String typeName = type.replaceAll("\\(.*\\)", "");

        switch (typeName) {
            case serdeConstants.STRING_TYPE_NAME:
                convertedType = DataType.TEXT;
                convertedValue = isDefaultPartition ? null : val;
                break;
            case serdeConstants.BOOLEAN_TYPE_NAME:
                convertedType = DataType.BOOLEAN;
                convertedValue = isDefaultPartition ? null
                        : Boolean.valueOf(val);
                break;
            case serdeConstants.TINYINT_TYPE_NAME:
            case serdeConstants.SMALLINT_TYPE_NAME:
                convertedType = DataType.SMALLINT;
                convertedValue = isDefaultPartition ? null
                        : Short.parseShort(val);
                break;
            case serdeConstants.INT_TYPE_NAME:
                convertedType = DataType.INTEGER;
                convertedValue = isDefaultPartition ? null
                        : Integer.parseInt(val);
                break;
            case serdeConstants.BIGINT_TYPE_NAME:
                convertedType = DataType.BIGINT;
                convertedValue = isDefaultPartition ? null
                        : Long.parseLong(val);
                break;
            case serdeConstants.FLOAT_TYPE_NAME:
                convertedType = DataType.REAL;
                convertedValue = isDefaultPartition ? null
                        : Float.parseFloat(val);
                break;
            case serdeConstants.DOUBLE_TYPE_NAME:
                convertedType = DataType.FLOAT8;
                convertedValue = isDefaultPartition ? null
                        : Double.parseDouble(val);
                break;
            case serdeConstants.TIMESTAMP_TYPE_NAME:
                convertedType = DataType.TIMESTAMP;
                convertedValue = isDefaultPartition ? null
                        : Timestamp.valueOf(val);
                break;
            case serdeConstants.DATE_TYPE_NAME:
                convertedType = DataType.DATE;
                convertedValue = isDefaultPartition ? null
                        : Date.valueOf(val);
                break;
            case serdeConstants.DECIMAL_TYPE_NAME:
                convertedType = DataType.NUMERIC;
                convertedValue = isDefaultPartition ? null
                        : HiveDecimal.create(val).bigDecimalValue().toString();
                break;
            case serdeConstants.VARCHAR_TYPE_NAME:
                convertedType = DataType.VARCHAR;
                convertedValue = isDefaultPartition ? null : val;
                break;
            case serdeConstants.CHAR_TYPE_NAME:
                convertedType = DataType.BPCHAR;
                convertedValue = isDefaultPartition ? null : val;
                break;
            case serdeConstants.BINARY_TYPE_NAME:
                convertedType = DataType.BYTEA;
                convertedValue = isDefaultPartition ? null : val.getBytes();
                break;
            default:
                throw new UnsupportedTypeException(
                        "Unsupported partition type: " + type);
        }

        if (columnDescriptorContainsColumn(columnName)) {
            partitionColumnNames.put(columnName, new OneField(convertedType.getOID(), convertedValue));
        }
    }
    numberOfPartitions = partitionColumnNames.size();
}
 
Example 14
Source File: JAXBConfigImpl.java    From rice with Educational Community License v2.0 4 votes vote down vote up
protected boolean isPropertiesFile(String filename) {
    String lower = StringUtils.lowerCase(filename);
    return StringUtils.endsWith(lower, ".properties");
}
 
Example 15
Source File: JsonPipe.java    From iaf with Apache License 2.0 4 votes vote down vote up
public String getDirection() {
	return StringUtils.lowerCase(direction);
}
 
Example 16
Source File: CpEntityManagerFactory.java    From usergrid with Apache License 2.0 4 votes vote down vote up
private String buildAppName( String organizationName, String name ) {
    return StringUtils.lowerCase(name.contains("/") ? name : organizationName + "/" + name);
}
 
Example 17
Source File: KeyValue.java    From pentaho-kettle with Apache License 2.0 3 votes vote down vote up
/**
 * Constructor. Key will be converted to lower case.
 *
 * @param key
 *          key to set.
 * @param value
 *          value to set, may be null.
 * @throws IllegalArgumentException
 *           if key is invalid.
 */
public KeyValue( final String key, final T value ) throws IllegalArgumentException {
  final String keyToSet = StringUtils.lowerCase( key );
  assertKey( keyToSet );
  this.key = keyToSet;
  this.value = value;
}
 
Example 18
Source File: KeyValue.java    From hop with Apache License 2.0 3 votes vote down vote up
/**
 * Constructor. Key will be converted to lower case.
 *
 * @param key   key to set.
 * @param value value to set, may be null.
 * @throws IllegalArgumentException if key is invalid.
 */
public KeyValue( final String key, final T value ) throws IllegalArgumentException {
  final String keyToSet = StringUtils.lowerCase( key );
  assertKey( keyToSet );
  this.key = keyToSet;
  this.value = value;
}