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

The following examples show how to use org.apache.commons.lang.StringUtils#isAlphanumeric() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: cloudstack   File: SolidFireUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static String getSolidFireVolumeName(String strCloudStackVolumeName) {
    final String specialChar = "-";

    StringBuilder strSolidFireVolumeName = new StringBuilder();

    for (int i = 0; i < strCloudStackVolumeName.length(); i++) {
        String strChar = strCloudStackVolumeName.substring(i, i + 1);

        if (StringUtils.isAlphanumeric(strChar)) {
            strSolidFireVolumeName.append(strChar);
        } else {
            strSolidFireVolumeName.append(specialChar);
        }
    }

    return strSolidFireVolumeName.toString();
}
 
Example 2
@Override
public void valueChanged(ListSelectionEvent e) {
  boolean hasFocus = otrosApplication.getApplicationJFrame().isFocused();
  final boolean enabled = otrosApplication.getConfiguration().getBoolean(ConfKeys.JUMP_TO_CODE_AUTO_JUMP_ENABLED, false);
  if (hasFocus && enabled && !e.getValueIsAdjusting()) {
    try {
      final LogData logData = dataTableModel.getLogData(table.convertRowIndexToModel(e.getFirstIndex()));
      Optional<Integer> line = Optional.empty();
      if (StringUtils.isNotBlank(logData.getLine()) && StringUtils.isAlphanumeric(logData.getLine())) {
        line = Optional.of(Integer.valueOf(logData.getLine()));
      }
      final LocationInfo li = new LocationInfo(
        Optional.ofNullable(logData.getClazz()).orElseGet(logData::getLoggerName),
        logData.getMethod(), logData.getFile(),
        line,
        Optional.ofNullable(logData.getMessage()));
      final JumpToCodeService jumpToCodeService = otrosApplication.getServices().getJumpToCodeService();
      final boolean ideAvailable = jumpToCodeService.isIdeAvailable();
      if (ideAvailable) {
        scheduledJump.map(input -> {
          input.cancel(false);
          return Boolean.TRUE;
        });
        ListeningScheduledExecutorService scheduledExecutorService = otrosApplication.getServices().getTaskSchedulerService().getListeningScheduledExecutorService();
        delayMs = 300;
        ListenableScheduledFuture<?> jump = scheduledExecutorService.schedule(
          new JumpRunnable(li, jumpToCodeService), delayMs, TimeUnit.MILLISECONDS
        );

        scheduledJump = Optional.of(jump);
      }
    } catch (Exception e1) {
      LOGGER.warn("Can't perform jump to code: " + e1.getMessage(), e1);
      e1.printStackTrace();
    }

  }
}
 
Example 3
@Activate
public void activate(ComponentContext ctx) {
    Dictionary<String, Object> config = ctx.getProperties();

    Enumeration<String> keys = config.keys();
    while (keys.hasMoreElements()) {
        String foldername = keys.nextElement();
        if (!StringUtils.isAlphanumeric(foldername)) {
            // we allow only simple alphanumeric names for model folders - everything else might be other service
            // properties
            continue;
        }

        String[] fileExts = ((String) config.get(foldername)).split(",");

        File folder = getFile(foldername);
        if (folder.exists() && folder.isDirectory()) {
            folderFileExtMap.put(foldername, fileExts);
        } else {
            logger.warn("Directory '{}' does not exist in '{}'. Please check your configuration settings!",
                    foldername, ConfigConstants.getConfigFolder());
        }
    }

    addModelsToRepo();

    super.activate();
}
 
Example 4
Source Project: dubbox   File: StringUtil.java    License: Apache License 2.0 4 votes vote down vote up
public static boolean isAlphanumeric(String str) {
	return StringUtils.isAlphanumeric(str);
}