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

The following examples show how to use org.apache.commons.lang3.StringUtils#isAlpha() . 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: ResourceUtils.java    From submarine with 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
Source File: XPathAutocompleteProvider.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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
Source File: NEMUtils.java    From VersionChecker with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 File: SqlFunctionUtils.java    From flink with 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 File: CustomerServiceImpl.java    From Spring with 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 File: CustomerServiceImpl.java    From Spring with 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 File: CustomerServiceImpl.java    From Spring with 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 File: DefaultSignavioStringLib.java    From jdmn with 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 File: SqlFunctionUtils.java    From flink with 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 File: UnknownContactPanel.java    From jitsi with 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 File: IsAlpha.java    From vscrawler with Apache License 2.0 4 votes vote down vote up
@Override
protected  boolean handle(CharSequence str) {
    return StringUtils.isAlpha(str);
}