List of usage examples for java.lang Character isLetter
public static boolean isLetter(int codePoint)
From source file:org.opensextant.util.TextUtils.java
/** * Count number of non-alphanumeric chars are present. * // w ww . jav a 2 s . co m * @param t * @return */ public static int countNonText(final String t) { int nonText = 0; for (char c : t.toCharArray()) { if (!Character.isLetter(c) && Character.isDigit(c) && Character.isWhitespace(c)) { ++nonText; } } return nonText; }
From source file:com.jecelyin.editor.v2.core.text.TextUtils.java
/** * Determine what caps mode should be in effect at the current offset in * the text. Only the mode bits set in <var>reqModes</var> will be * checked. Note that the caps mode flags here are explicitly defined * to match those in {@link android.text.InputType}. * * @param cs The text that should be checked for caps modes. * @param off Location in the text at which to check. * @param reqModes The modes to be checked: may be any combination of * {@link #CAP_MODE_CHARACTERS}, {@link #CAP_MODE_WORDS}, and * {@link #CAP_MODE_SENTENCES}./*from w w w .j av a 2 s . co m*/ * * @return Returns the actual capitalization modes that can be in effect * at the current position, which is any combination of * {@link #CAP_MODE_CHARACTERS}, {@link #CAP_MODE_WORDS}, and * {@link #CAP_MODE_SENTENCES}. */ public static int getCapsMode(CharSequence cs, int off, int reqModes) { if (off < 0) { return 0; } int i; char c; int mode = 0; if ((reqModes & CAP_MODE_CHARACTERS) != 0) { mode |= CAP_MODE_CHARACTERS; } if ((reqModes & (CAP_MODE_WORDS | CAP_MODE_SENTENCES)) == 0) { return mode; } // Back over allowed opening punctuation. for (i = off; i > 0; i--) { c = cs.charAt(i - 1); if (c != '"' && c != '\'' && Character.getType(c) != Character.START_PUNCTUATION) { break; } } // Start of paragraph, with optional whitespace. int j = i; while (j > 0 && ((c = cs.charAt(j - 1)) == ' ' || c == '\t')) { j--; } if (j == 0 || cs.charAt(j - 1) == '\n') { return mode | CAP_MODE_WORDS; } // Or start of word if we are that style. if ((reqModes & CAP_MODE_SENTENCES) == 0) { if (i != j) mode |= CAP_MODE_WORDS; return mode; } // There must be a space if not the start of paragraph. if (i == j) { return mode; } // Back over allowed closing punctuation. for (; j > 0; j--) { c = cs.charAt(j - 1); if (c != '"' && c != '\'' && Character.getType(c) != Character.END_PUNCTUATION) { break; } } if (j > 0) { c = cs.charAt(j - 1); if (c == '.' || c == '?' || c == '!') { // Do not capitalize if the word ends with a period but // also contains a period, in which case it is an abbreviation. if (c == '.') { for (int k = j - 2; k >= 0; k--) { c = cs.charAt(k); if (c == '.') { return mode; } if (!Character.isLetter(c)) { break; } } } return mode | CAP_MODE_SENTENCES; } } return mode; }
From source file:io.manasobi.utils.StringUtils.java
/** * ? ?? ? ? ?<br><br>// w w w.ja v a 2 s . c o m * * StringUtils.isAlpha("abcfds") = true * * @param str ? * @return ?? ? ?? true */ public static boolean isAlpha(String str) { if (str == null) { return false; } int sz = str.length(); if (sz == 0) { return false; } for (int i = 0; i < sz; i++) { if (!Character.isLetter(str.charAt(i))) { return false; } } return true; }
From source file:eu.cloud4soa.governance.ems.ExecutionManagementServiceModule.java
protected GitRepoInfo deployApplicationOnPaaSUsingGit(String gitCommand, ApplicationInstance applicationInstance, PaaSInstance paaSInstance, String accountName, String publicKey, String secretKey, List<Account> accounts) throws Cloud4SoaException { GitRepoInfo gitRepoInfo;/*from w w w . ja v a 2 s . c om*/ String deployedAppUrl; String adapterAppUrl; gitRepoInfo = new GitRepoInfo(); deployedAppUrl = null; adapterAppUrl = null; //User long userid = 0; List<User> userlist = userrepository.findBy("uriID", applicationInstance.getOwnerUriId()); if (userlist != null && !userlist.isEmpty()) { userid = ((User) userlist.get(0)).getId(); } else { //DB entry - it shouldnt be here } CustomerCredentials credentials = new CustomerCredentials(publicKey, secretKey); CustomerCredentials credentialsOpenShift = new CustomerCredentials(publicKey + "_" + secretKey, secretKey); String encyptedCredentials = ExecutionManagementUtil.createCloudControlApiKey(publicKey, secretKey); CustomerCredentials credentialsCloudControl = new CustomerCredentials(encyptedCredentials, encyptedCredentials); logger.info("accounts-size: " + accounts.size()); String paas_name = paaSInstance.getProviderTitle(); String giturl = null; String reponame = null; //step 1: create repository and return the git uri if (paas_name.equalsIgnoreCase("Red Hat")) { // String gitURI = Adapter.createApplication("OpenShift", publicKey, secretKey, "", applicationInstance.getTitle(), ""); //adapter deployment if needed //adapterAppUrl = Adapter.getAppURL("OpenShift", publicKey, secretKey, "", applicationInstance.getTitle(), "", "", ""); //deployedAppUrl = adapterAppUrl; AdapterClient adapterClient = new AdapterClientCXF(); String openShiftAdapterLocation = "http://rhoshiftadapter.testurl.cloudbees.net/"; //replace this with the per application specific adapter adapterAppUrl = openShiftAdapterLocation; //String[] temp = ExecutionManagementUtil.convertFromOpenshift(gitURI); //giturl = temp[0]; //reponame = temp[1]; CreateApplicationRequest createAppRequest = new CreateApplicationRequest(); createAppRequest.setBaseUrl(adapterAppUrl); String applicationTitle = applicationInstance.getTitle(); String applicationTitleLowerCase = applicationTitle.toLowerCase(); if (!Character.isLetter(applicationTitleLowerCase.charAt(0))) { throw new Cloud4SoaException( "Application title must start with a letter in order to be deployed on OpenShift"); } createAppRequest.setApplicationName(applicationTitleLowerCase); if (applicationInstance.getProgramminglanguage() != null) { createAppRequest.setLanguage(applicationInstance.getProgramminglanguage()); } try { CreateApplicationResponse createAppResponse = adapterClient.send(createAppRequest, credentialsOpenShift); int status = createAppResponse.getStatusCode().ordinal(); logger.info("createApplication:" + " - " + createAppResponse.getStatusCode().toString() + " " + (status > 199 && status < 300 ? "successfull" : "failed") + " for app: " + applicationInstance.getTitle()); deployedAppUrl = createAppResponse.getApplication().getUrl(); String[] temp = ExecutionManagementUtil .convertFromOpenshift(createAppResponse.getApplication().getRepository()); giturl = temp[0]; reponame = temp[1]; logger.info("giturl:" + giturl); logger.info("reponame:" + reponame); } catch (AdapterClientException e) { //throw new RuntimeException(e); throw new Cloud4SoaException(new PaaSException(e.getMessage())); } catch (UnknownHostException e) { throw new Cloud4SoaException(new PaaSConnectionException(e.getMessage())); } //Read C4SOA-Proxy key If Exists Pr register String privatekeypath = System.getProperty("user.home") + "/.ssh/" + userid; String pubkeypath = System.getProperty("user.home") + "/.ssh/" + userid + ".pub"; logger.info("PUBLIC KEY PATH:" + pubkeypath); String sshkey = ""; sshkey = ExecutionManagementUtil.getPublicKey(userid); //if it does not exist if (sshkey == null || sshkey.trim().equals("")) { //generate it ExecutionManagementUtil.GenerateSSHKeyPair(userid + ""); //read it sshkey = ExecutionManagementUtil.getPublicKey(userid); } logger.info("The final key is " + sshkey); openshift.Openshift_Aux sshkeyrequest = new Openshift_Aux(publicKey, secretKey); sshkeyrequest.registerSSHKey(privatekeypath, pubkeypath, "c4sServerKey"); /* //Always register the key //CreateSSHKeyRequest createsshrequest = new CreateSSHKeyRequest(); //createsshrequest.setBaseUrl(adapterAppUrl); //createsshrequest.setApiKey(publicKey); //createsshrequest.setSshKey(sshkey); //createsshrequest.setApplicationName(applicationTitle);* try { CreateSSHKeyResponse response = adapterClient.send(createsshrequest, credentials); int status = response.getStatusCode().ordinal(); System.out.println("response:" + " - " + response.getStatusCode().toString() + " " + (status > 199 && status < 300 ? "successfull" : "failed")); } catch (AdapterClientException e) { e.printStackTrace(); }*/ } //OpenShift if (paas_name.equalsIgnoreCase("Heroku")) { AdapterClient adapterClient = new AdapterClientCXF(); String herokuAdapterLocation = "http://c4s.herokuapp.com/"; //replace this with the per application specific adapter adapterAppUrl = herokuAdapterLocation; CreateApplicationRequest createAppRequest = new CreateApplicationRequest(); createAppRequest.setBaseUrl(herokuAdapterLocation); String applicationTitle = applicationInstance.getTitle(); String applicationTitleLowerCase = applicationTitle.toLowerCase(); if (!Character.isLetter(applicationTitleLowerCase.charAt(0))) { throw new Cloud4SoaException( "Application title must start with a letter in order to be deployed on heroku"); } createAppRequest.setApplicationName(applicationTitleLowerCase); if (applicationInstance.getProgramminglanguage() != null) { createAppRequest.setLanguage(applicationInstance.getProgramminglanguage()); } try { CreateApplicationResponse createAppResponse = adapterClient.send(createAppRequest, credentials); int status = createAppResponse.getStatusCode().ordinal(); logger.info("createApplication:" + " - " + createAppResponse.getStatusCode().toString() + " " + (status > 199 && status < 300 ? "successfull" : "failed") + " for app: " + applicationInstance.getTitle()); deployedAppUrl = createAppResponse.getApplication().getUrl(); String[] temp = ExecutionManagementUtil .convertFromHeroku(createAppResponse.getApplication().getRepository()); giturl = temp[0]; reponame = temp[1]; } catch (AdapterClientException e) { //throw new RuntimeException(e); throw new Cloud4SoaException(new PaaSException(e.getMessage())); } catch (UnknownHostException e) { throw new Cloud4SoaException(new PaaSConnectionException(e.getMessage())); } //Read C4SOA-Proxy key If Exists Pr register String pubkeypath = System.getProperty("user.home") + "/.ssh/" + userid + ".pub"; logger.info("PUBLIC KEY PATH:" + pubkeypath); String sshkey = ""; sshkey = ExecutionManagementUtil.getPublicKey(userid); //if it does not exist if (sshkey == null || sshkey.trim().equals("")) { //generate it ExecutionManagementUtil.GenerateSSHKeyPair(userid + ""); //read it sshkey = ExecutionManagementUtil.getPublicKey(userid); } logger.info("The final key is " + sshkey); //Always register the key CreateSSHKeyRequest createsshrequest = new CreateSSHKeyRequest(); createsshrequest.setBaseUrl(herokuAdapterLocation); createsshrequest.setApiKey(publicKey); createsshrequest.setSshKey(sshkey); createsshrequest.setApplicationName(applicationTitle); try { CreateSSHKeyResponse response = adapterClient.send(createsshrequest, credentials); int status = response.getStatusCode().ordinal(); System.out.println("response:" + " - " + response.getStatusCode().toString() + " " + (status > 199 && status < 300 ? "successfull" : "failed")); } catch (AdapterClientException e) { //e.printStackTrace(); throw new Cloud4SoaException(new PaaSException(e.getMessage())); } catch (UnknownHostException e) { throw new Cloud4SoaException(new PaaSConnectionException(e.getMessage())); } } //Heroku if (paas_name.equalsIgnoreCase("CloudControl PaaS Provider")) { AdapterClient adapterClient = new AdapterClientCXF(); String cloudControlAdapterLocation = "http://c4s.cloudcontrolled.com/"; //replace this with the per application specific adapter adapterAppUrl = cloudControlAdapterLocation; CreateApplicationRequest createAppRequest = new CreateApplicationRequest(); createAppRequest.setBaseUrl(cloudControlAdapterLocation); String applicationTitle = applicationInstance.getTitle(); String applicationTitleLowerCase = applicationTitle.toLowerCase(); if (!Character.isLetter(applicationTitleLowerCase.charAt(0))) { throw new Cloud4SoaException("Application title must start with a letter in order to be deployed"); } createAppRequest.setApplicationName(applicationTitleLowerCase); if (applicationInstance.getProgramminglanguage() != null) { createAppRequest.setLanguage(applicationInstance.getProgramminglanguage()); } try { CreateApplicationResponse createAppResponse = adapterClient.send(createAppRequest, credentialsCloudControl); int status = createAppResponse.getStatusCode().ordinal(); logger.info("createApplication:" + " - " + createAppResponse.getStatusCode().toString() + " " + (status > 199 && status < 300 ? "successfull" : "failed") + " for app: " + applicationInstance.getTitle()); deployedAppUrl = createAppResponse.getApplication().getUrl(); String[] temp = ExecutionManagementUtil .convertFromCloudControl(createAppResponse.getApplication().getRepository()); giturl = temp[0]; reponame = temp[1]; } catch (AdapterClientException e) { //throw new RuntimeException(e); throw new Cloud4SoaException(new PaaSException(e.getMessage())); } catch (UnknownHostException e) { throw new Cloud4SoaException(new PaaSConnectionException(e.getMessage())); } //Read C4SOA-Proxy key If Exists Pr register String pubkeypath = System.getProperty("user.home") + "/.ssh/" + userid + ".pub"; logger.info("PUBLIC KEY PATH:" + pubkeypath); String sshkey = ""; sshkey = ExecutionManagementUtil.getPublicKey(userid); //if it does not exist if (sshkey == null || sshkey.trim().equals("")) { //generate it ExecutionManagementUtil.GenerateSSHKeyPair(userid + ""); //read it sshkey = ExecutionManagementUtil.getPublicKey(userid); } logger.info("The final key is " + sshkey); //Always register the key CreateSSHKeyRequest createsshrequest = new CreateSSHKeyRequest(); createsshrequest.setBaseUrl(cloudControlAdapterLocation); createsshrequest.setApiKey(publicKey); createsshrequest.setSshKey(sshkey); createsshrequest.setApplicationName(applicationTitle); try { CreateSSHKeyResponse response = adapterClient.send(createsshrequest, credentialsCloudControl); int status = response.getStatusCode().ordinal(); System.out.println("response:" + " - " + response.getStatusCode().toString() + " " + (status > 199 && status < 300 ? "successfull" : "failed")); } catch (AdapterClientException e) { // e.printStackTrace(); throw new Cloud4SoaException(new PaaSException(e.getMessage())); } catch (UnknownHostException e) { throw new Cloud4SoaException(new PaaSConnectionException(e.getMessage())); } } //CloudControl PaaS Provider long appId = 0; List<eu.cloud4soa.relational.datamodel.ApplicationInstance> applicationlist = appinstancerepository .find("uriID = ? AND account.id = ?", applicationInstance.getUriId(), accounts.get(0).getId()); if (applicationlist != null && !applicationlist.isEmpty()) { appId = ((eu.cloud4soa.relational.datamodel.ApplicationInstance) applicationlist.get(0)).getId(); } else { //DB entry - it shouldnt be here } gitRepoInfo.setUrl(giturl); gitRepoInfo.setRepositoryName(reponame); gitRepoInfo.setApplicationId("" + appId); gitRepoInfo.setUserId("" + userid); gitRepoInfo.setApplicationUrl(deployedAppUrl); gitRepoInfo.setAdapterUrl(adapterAppUrl); return gitRepoInfo; }
From source file:org.geoserver.importer.Importer.java
String findUniqueResourceName(ResourceInfo resource) throws IOException { //TODO: put an upper limit on how many times to try StoreInfo store = resource.getStore(); NamespaceInfo ns = catalog.getNamespaceByPrefix(store.getWorkspace().getName()); String name = resource.getName(); // make sure the name conforms to a legal layer name if (!Character.isLetter(name.charAt(0))) { name = "a_" + name; }/* w w w . j a v a 2s. c om*/ // strip out any non-word characters name = name.replaceAll("\\W", "_"); if (catalog.getResourceByName(ns, name, ResourceInfo.class) != null) { int i = 0; name += i; while (catalog.getResourceByName(ns, name, ResourceInfo.class) != null) { name = name.replaceAll(i + "$", String.valueOf(i + 1)); i++; } } return name; }
From source file:ee.sk.digidoc.SignedDoc.java
/** * return certificate owners last name/*from w ww .ja va 2 s . com*/ * @return certificate owners last name or null */ public static String getSubjectLastName(X509Certificate cert) { String dn = getDN(cert); String name = null; String cn = getDnPart(dn, "CN", null); if (cn != null) { int idx1 = 0; while (idx1 < cn.length() && !Character.isLetter(cn.charAt(idx1))) idx1++; int idx2 = idx1; while (idx2 < cn.length() && cn.charAt(idx2) != ',' && dn.charAt(idx2) != '/') idx2++; name = cn.substring(idx1, idx2); } return name; }
From source file:com.android.mms.ui.MessageUtils.java
public static boolean isAlias(String string) { if (!MmsConfig.isAliasEnabled()) { return false; }/*from w w w . ja v a 2 s. c o m*/ int len = string == null ? 0 : string.length(); if (len < MmsConfig.getAliasMinChars() || len > MmsConfig.getAliasMaxChars()) { return false; } if (!Character.isLetter(string.charAt(0))) { // Nickname begins with a letter return false; } for (int i = 1; i < len; i++) { char c = string.charAt(i); if (!(Character.isLetterOrDigit(c) || c == '.')) { return false; } } return true; }
From source file:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java
@Override public void onPress(final int primaryCode) { setVibration();/*from www . ja v a 2 s . co m*/ final InputConnection ic = getCurrentInputConnection(); if (popupKeypress && (primaryCode == 32 || primaryCode == 126 || primaryCode == -5 || primaryCode == -1 || primaryCode == EmojiKeyboardView.KEYCODE_EMOJI_1 || primaryCode == EmojiKeyboardView.KEYCODE_EMOJI_2 || primaryCode == EmojiKeyboardView.KEYCODE_EMOJI_3 || primaryCode == EmojiKeyboardView.KEYCODE_EMOJI_4 || primaryCode == EmojiKeyboardView.KEYCODE_EMOJI_5)) { kv.setPreviewEnabled(false); } if (oppositeCase) { timer = new CountDownTimer(300, 1) { @Override public void onTick(long millisUntilFinished) { } @Override public void onFinish() { if (!swipe) { if (primaryCode == 46) { ic.commitText(",", 1); printedCommaa = true; if (autoSpacing) { ic.commitText(" ", 1); } } else if (primaryCode == 32) { Intent intent = new Intent(getApplicationContext(), Home.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else if (primaryCode == -5) { if (voiceInput) { if (mVoiceRecognitionTrigger.isInstalled()) { mVoiceRecognitionTrigger.startVoiceRecognition(); } } } else { char code = (char) primaryCode; if (Character.isLetter(code) && caps) { code = Character.toLowerCase(code); } else if (Character.isLetter(code) && !caps) { code = Character.toUpperCase(code); } ic.commitText(String.valueOf(code), 1); } printedDifferent = true; } } }.start(); } if (spaceDot) { if (primaryCode == 32) { doubleSpace++; if (doubleSpace == 2) { ic.deleteSurroundingText(1, 0); ic.commitText(".", 1); if (autoSpacing) { ic.commitText(" ", 1); } printedDot = true; doubleSpace = 0; } else { printedDot = false; } } else { printedDot = false; doubleSpace = 0; } } }
From source file:gov.nih.nci.evs.browser.utils.SearchUtils.java
public static boolean nonAlphabetic(String s) { if (s == null) return false; if (s.length() == 0) return true; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (Character.isLetter(ch)) return false; }// w w w .java2s . c o m return true; }
From source file:org.distantshoresmedia.keyboard.LatinIME.java
private boolean isAlphabet(int code) { if (Character.isLetter(code)) { return true; } else {/*from ww w . j a va 2 s.com*/ return false; } }