Java Code Examples for org.apache.commons.lang3.StringUtils#isAlpha()

The following examples show how to use org.apache.commons.lang3.StringUtils#isAlpha() . 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 check out the related API usage on the sidebar.
Example 1
Source Project: submarine   File: ResourceUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Extract unit and actual value from resource value.
 * @param resourceValue Value of the resource
 * @return Array containing unit and value. [0]=unit, [1]=value
 * @throws IllegalArgumentException if units contain non alpha characters
 */
private static String[] parseResourceValue(String resourceValue) {
  String[] resource = new String[2];
  int i = 0;
  for (; i < resourceValue.length(); i++) {
    if (Character.isAlphabetic(resourceValue.charAt(i))) {
      break;
    }
  }
  String units = resourceValue.substring(i);

  if (StringUtils.isAlpha(units) || units.equals("")) {
    resource[0] = units;
    resource[1] = resourceValue.substring(0, i);
    return resource;
  } else {
    throw new IllegalArgumentException("Units '" + units + "'"
        + " contains non alphabet characters, which is not allowed.");
  }
}
 
Example 2
@Nullable
private Tuple2<Integer, String> getInsertionPointAndQuery(int searchPoint) {
    String input = myCodeArea.getText();

    int insertionPoint = getInsertionPoint(searchPoint, input);

    if (searchPoint > input.length()) {
        searchPoint = input.length();
    }
    if (insertionPoint > searchPoint) {
        new StringIndexOutOfBoundsException("Cannot extract query from subtext \"" + input.substring(0, insertionPoint) + "\"").printStackTrace();
        return null;
    }

    // don't trim, if there is any whitespace we abort
    input = input.substring(insertionPoint, searchPoint);

    return StringUtils.isAlpha(input) ? Tuples.t(insertionPoint, input.trim()) : null;
}
 
Example 3
public static String patchVersion(String modVersion) {
    modVersion = modVersion.replaceAll(Pattern.quote("(" + NEMChecker.getMcVersion() + ")"), "");
    modVersion = modVersion.replaceAll(Pattern.quote("[" + NEMChecker.getMcVersion() + "]"), "");
    modVersion = modVersion.replaceAll("[\\)\\]]", "").replaceAll("[\\(\\[]", ".");
    modVersion = modVersion.replaceAll(Pattern.quote("_" + NEMChecker.getMcVersion()), "");
    modVersion = modVersion.replaceAll(Pattern.quote(NEMChecker.getMcVersion() + "_"), "");
    modVersion = modVersion.replaceAll(Pattern.quote(NEMChecker.getMcVersion() + "-"), "");
    modVersion = modVersion.replaceAll("^v", "").replaceAll("^V", "");
    modVersion = modVersion.replaceAll(" build ", ".").replaceAll("\\s","");

    int index = modVersion.lastIndexOf('-');
    if (index != -1)
    {
        String lastPart = modVersion.substring(index + 1);
        if (StringUtils.isAlpha(lastPart))
            modVersion = modVersion.substring(0, index);
    }

    return modVersion;
}
 
Example 4
Source Project: flink   File: SqlFunctionUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean isAlpha(Object obj) {
	if (obj == null){
		return false;
	}
	if (!(obj instanceof String)){
		return false;
	}
	String s = obj.toString();
	if ("".equals(s)) {
		return false;
	}
	return StringUtils.isAlpha(s);
}
 
Example 5
Source Project: Spring   File: CustomerServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<Customer> findCustomersByFNameLName(String firstName, String lastName) throws CustomerSerivceClientException {
	if(StringUtils.isEmpty(firstName) || StringUtils.isEmpty(lastName)) {
		throw new CustomerSerivceClientException("Missing required parameter!");
	} else if (!StringUtils.isAlpha(firstName) || !StringUtils.isAlpha(lastName)) {
		throw new CustomerSerivceClientException("First and/or last name is not in proper format!");
	}
	return repo.findCustomersByFirstNameAndLastName(firstName, lastName);
}
 
Example 6
Source Project: Spring   File: CustomerServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<Customer> findCustomersByFNameLName(String firstName, String lastName) throws CustomerSerivceClientException {
	if(StringUtils.isEmpty(firstName) || StringUtils.isEmpty(lastName)) {
		throw new CustomerSerivceClientException("Missing required parameter!");
	} else if (!StringUtils.isAlpha(firstName) || !StringUtils.isAlpha(lastName)) {
		throw new CustomerSerivceClientException("First and/or last name is not in proper format!");
	}
	return repo.findCustomersByFirstNameAndLastName(firstName, lastName);
}
 
Example 7
Source Project: Spring   File: CustomerServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<Customer> findCustomersByFNameLName(String firstName, String lastName) throws CustomerSerivceClientException {
	if(StringUtils.isEmpty(firstName) || StringUtils.isEmpty(lastName)) {
		throw new CustomerSerivceClientException("Missing required parameter!");
	} else if (!StringUtils.isAlpha(firstName) || !StringUtils.isAlpha(lastName)) {
		throw new CustomerSerivceClientException("First and/or last name is not in proper format!");
	}
	return repo.findCustomersByFirstNameAndLastName(firstName, lastName);
}
 
Example 8
Source Project: jdmn   File: DefaultSignavioStringLib.java    License: Apache License 2.0 5 votes vote down vote up
public Boolean isAlpha(String text) {
    if (text == null) {
        return null;
    }

    return StringUtils.isAlpha(text);
}
 
Example 9
Source Project: flink   File: SqlFunctionUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean isAlpha(Object obj) {
	if (obj == null){
		return false;
	}
	if (!(obj instanceof String)){
		return false;
	}
	String s = obj.toString();
	if ("".equals(s)) {
		return false;
	}
	return StringUtils.isAlpha(s);
}
 
Example 10
Source Project: jitsi   File: UnknownContactPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the call button.
 */
private void initSMSButton()
{
    if(parentWindow.hasOperationSet(OperationSetSmsMessaging.class)
        && !StringUtils.isAlpha(parentWindow.getCurrentSearchText()))
    {
        if (smsButton != null && smsButton.getParent() != null)
            return;

        smsButton = new JButton(GuiActivator.getResources()
            .getI18NString("service.gui.SEND_SMS"));

        smsButton.setIcon(GuiActivator.getResources()
            .getImage("service.gui.icons.SMS_BUTTON_ICON"));

        buttonPanel.add(smsButton);

        smsButton.addActionListener(new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                final String searchText
                    = parentWindow.getCurrentSearchText();

                if(searchText == null)
                    return;

                SMSManager.sendSMS(smsButton, searchText);
            }
        });
    }
    else
    {
        if(smsButton != null)
            buttonPanel.remove(smsButton);
    }
}
 
Example 11
Source Project: vscrawler   File: IsAlpha.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected  boolean handle(CharSequence str) {
    return StringUtils.isAlpha(str);
}