List of usage examples for java.lang Character isLetterOrDigit
public static boolean isLetterOrDigit(int codePoint)
From source file:com.awt.supark.EditCar.java
public void radioListener() { InputFilter charFilter = filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { if (!Character.isLetterOrDigit(source.charAt(i))) { return ""; }/*from ww w . j a v a 2 s. c o m*/ } return null; } }; if (radioNewSrb.isChecked()) { txtCity.setVisibility(View.VISIBLE); licensePlate.setBackgroundDrawable(getResources().getDrawable(R.drawable.licenseplate)); updateLicensePlate(licenseNum); //txtNum.setFilters(new InputFilter[]{filter, new InputFilter.LengthFilter(7), new InputFilter.AllCaps()}); carLicense.setFilters( new InputFilter[] { new InputFilter.LengthFilter(8), new InputFilter.AllCaps(), charFilter }); } else if (radioGeneric.isChecked()) { txtCity.setVisibility(View.GONE); licensePlate.setBackgroundDrawable(getResources().getDrawable(R.drawable.licenseplate2)); // Reset txtCity.setText(""); updateLicensePlate(licenseNum); //txtNum.setFilters(new InputFilter[]{filter, new InputFilter.LengthFilter(12), new InputFilter.AllCaps()}); carLicense.setFilters( new InputFilter[] { new InputFilter.LengthFilter(12), new InputFilter.AllCaps(), charFilter }); } }
From source file:org.noise_planet.noisecapture.CommentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_comment); View mainView = findViewById(R.id.mainLayout); if (mainView != null) { mainView.setOnTouchListener(new MainOnTouchListener(this)); }//from ww w .j av a2s . c om // Read record activity parameter // Use last record of no parameter provided this.measurementManager = new MeasurementManager(this); Intent intent = getIntent(); // Read the last stored record List<Storage.Record> recordList = measurementManager.getRecords(); if (intent != null && intent.hasExtra(COMMENT_RECORD_ID)) { record = measurementManager.getRecord(intent.getIntExtra(COMMENT_RECORD_ID, -1)); } else { if (!recordList.isEmpty()) { record = recordList.get(0); } else { // Message for starting a record Toast.makeText(getApplicationContext(), getString(R.string.no_results), Toast.LENGTH_LONG).show(); return; } } if (record != null) { View addPhoto = findViewById(R.id.btn_add_photo); addPhoto.setOnClickListener(new OnAddPhotoClickListener(this)); View resultsBtn = findViewById(R.id.resultsBtn); resultsBtn.setOnClickListener(new OnGoToResultPage(this)); View deleteBts = findViewById(R.id.deleteBtn); deleteBts.setOnClickListener(new OnDeleteMeasurement(this)); TextView noisePartyTag = (TextView) findViewById(R.id.edit_noiseparty_tag); noisePartyTag.setEnabled(record.getUploadId().isEmpty()); noisePartyTag.setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { // [^A-Za-z0-9_] StringBuilder stringBuilder = new StringBuilder(); for (int i = start; i < end; i++) { char c = source.charAt(i); if (Character.isLetterOrDigit(c) || c == '_') { stringBuilder.append(c); } } // keep original if unchanged or return swapped chars boolean modified = (stringBuilder.length() == end - start); return modified ? null : stringBuilder.toString(); } } }); if (record.getNoisePartyTag() == null) { // Read last stored NoiseParty id for (Storage.Record recordItem : recordList) { if (recordItem.getId() != record.getId()) { if (recordItem.getNoisePartyTag() != null) { noisePartyTag.setText(recordItem.getNoisePartyTag()); } break; } } } else { noisePartyTag.setText(record.getNoisePartyTag()); } } initDrawer(record != null ? record.getId() : null); SeekBar seekBar = (SeekBar) findViewById(R.id.pleasantness_slider); // Load stored user comment // Pleasantness and tags are read only if the record has been uploaded Map<String, Storage.TagInfo> tagToIndex = new HashMap<>(Storage.TAGS_INFO.length); for (Storage.TagInfo sysTag : Storage.TAGS_INFO) { tagToIndex.put(sysTag.name, sysTag); } View thumbnail = findViewById(R.id.image_thumbnail); thumbnail.setOnClickListener(new OnImageClickListener(this)); if (record != null) { // Load selected tags for (String sysTag : measurementManager.getTags(record.getId())) { Storage.TagInfo tagInfo = tagToIndex.get(sysTag); if (tagInfo != null) { checkedTags.add(tagInfo.id); } } // Load description if (record.getDescription() != null) { TextView description = (TextView) findViewById(R.id.edit_description); description.setText(record.getDescription()); } Integer pleasantness = record.getPleasantness(); if (pleasantness != null) { seekBar.setProgress((int) (Math.round((pleasantness / 100.0) * seekBar.getMax()))); seekBar.setThumb( seekBar.getResources().getDrawable(R.drawable.seekguess_scrubber_control_normal_holo)); userInputSeekBar.set(true); } else { seekBar.setThumb( seekBar.getResources().getDrawable(R.drawable.seekguess_scrubber_control_disabled_holo)); } photo_uri = record.getPhotoUri(); // User can only update not uploaded data seekBar.setEnabled(record.getUploadId().isEmpty()); } else { // Message for starting a record Toast.makeText(getApplicationContext(), getString(R.string.no_results), Toast.LENGTH_LONG).show(); } thumbnailImageLayoutDoneObserver = new OnThumbnailImageLayoutDoneObserver(this); thumbnail.getViewTreeObserver().addOnGlobalLayoutListener(thumbnailImageLayoutDoneObserver); seekBar.setOnSeekBarChangeListener(new OnSeekBarUserInput(userInputSeekBar)); // Fill tags grid Resources r = getResources(); String[] tags = r.getStringArray(R.array.tags); // Append tags items for (Storage.TagInfo tagInfo : Storage.TAGS_INFO) { ViewGroup tagContainer = (ViewGroup) findViewById(tagInfo.location); if (tagContainer != null && tagInfo.id < tags.length) { addTag(tags[tagInfo.id], tagInfo.id, tagContainer, tagInfo.color != -1 ? r.getColor(tagInfo.color) : -1); } } }
From source file:org.echocat.jemoni.jmx.JmxRegistry.java
@Nonnull protected String normalize(@Nonnull String what) { final char[] in = what.toCharArray(); final char[] out = new char[in.length]; int i = 0;//from w w w . j a va 2s .c o m for (char c : in) { if (Character.isLetterOrDigit(c) || c == '_' || c == '-' || c == '.') { out[i++] = c; } else if (Character.isWhitespace(c)) { out[i++] = '_'; } } return new String(out, 0, i); }
From source file:com.taobao.common.tfs.impl.TfsSession.java
/** * get tfs cluster index from nameserver * * @return/*from w w w.ja v a 2 s . c om*/ */ private int getTfsClusterIndexFromNs() { ClientCmdMessage cmd = new ClientCmdMessage(clientManager.getTranscoder()); cmd.setType(CLIENT_CMD_SET_PARAM); // CLIENT_CMD_SET_PARAM cmd.setBlockId(20); // TfsClusterIndex param cmd.setServerId(0); // no meaning cmd.setVersion(0); cmd.setFromServerId(0); int ret = TfsConstant.TFS_ERROR; try { BasePacket retPacket = clientManager.sendPacket(this.nameServerId, cmd); if (retPacket != null && retPacket.getPcode() == TfsConstant.STATUS_MESSAGE) { StatusMessage status = (StatusMessage) retPacket; if (status.getStatus() == StatusMessage.STATUS_MESSAGE_OK) { String value = status.getError(); if (value.length() > 0) { int index = Integer.parseInt(value); if (Character.isLetterOrDigit(index)) { this.tfsClusterIndex = (char) index; ret = TfsConstant.TFS_SUCCESS; } } } } } catch (ConnectionException e) { log.error("get tfs cluster index error:", e); } catch (NumberFormatException e) { log.error("get tfs cluster index error:", e); } return ret; }
From source file:com.knowbout.nlp.keywords.KeywordExtracter.java
/** * Attempts to clobber trailing punctuation, explicitley leaves the possessive ' * character in place if found./* w ww .j a va 2s . c o m*/ * * @param dirtyToken * @return */ private String cleanToken(String dirtyToken) { Configuration config = Config.getConfiguration(); String regex = config.getString("preprocessingRegex", null); if (regex != null) { if (log.isDebugEnabled()) { log.debug("preprocessing keyword " + dirtyToken + " with regex " + regex + " to get " + dirtyToken.replaceAll(regex, "")); } dirtyToken = dirtyToken.replaceAll(regex, ""); } int l = dirtyToken.length(); if (l > 1 && !Character.isLetterOrDigit(dirtyToken.charAt(l - 1))) { // But don't clobber the possessive suffix of a '. if (!dirtyToken.endsWith("'")) dirtyToken = dirtyToken.substring(0, l - 1); } return dirtyToken; // Which should now be a clean token... }
From source file:org.egov.android.view.activity.EditProfileActivity.java
/** * To initialize and set the layout for the ProfileActivity.Set click listeners to the save * changes, change picture and calendar icon. Here we have checked the api level to set the * layout. If api level is greater than 13, then call activity_edit_profile layout else call * activity_lower_version_edit_profile layout. activity_edit_profile layout contains * EGovRoundedImageView component which is not supported in lower api levels. get all the user * profile field values from the intent that is passed from the Profile Activity and displays * those values to the corresponding UI fields of EditProfile Layout StorageManager is the * interface to the systems' storage service. The storage manager handles storage-related items. * profile picture is stored in /egovernments/profile directory on device storage area. profile * picture is displayed using setImageBitmap method. *///w ww .j a va2 s .com @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); apiLevel = AndroidLibrary.getInstance().getSession().getInt("api_level", 0); if (apiLevel > 13) { setContentView(R.layout.activity_edit_profile); } else { setContentView(R.layout.activity_lower_version_edit_profile); } ((Button) findViewById(R.id.editprofile_doEditprofile)).setOnClickListener(this); ((Button) findViewById(R.id.changepicture)).setOnClickListener(this); ((ImageView) findViewById(R.id.edit_profile_calendar)).setOnClickListener(this); mobileNo = getIntent().getExtras().getString("mobileNo"); userName = getIntent().getExtras().getString("userName"); mailId = getIntent().getExtras().getString("mailId"); gender = getIntent().getExtras().getString("gender"); altContactNumber = getIntent().getExtras().getString("altContactNumber"); dateOfBirth = getIntent().getExtras().getString("dateOfBirth"); panCardNumber = getIntent().getExtras().getString("panCardNumber"); aadhaarCardNumber = getIntent().getExtras().getString("aadhaarCardNumber"); ((EditText) findViewById(R.id.edit_profile_name)).setText(userName); ((EditText) findViewById(R.id.edit_profile_alt_contact)).setText(altContactNumber); ((EditText) findViewById(R.id.edit_profile_pan)).setText(panCardNumber); ((EditText) findViewById(R.id.edit_profile_aadhaar)).setText(aadhaarCardNumber); ((TextView) findViewById(R.id.edit_profile_dob)).setText(dateOfBirth); InputFilter filter = new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { if (!Character.isLetterOrDigit(source.charAt(i))) { return ""; } } return null; } }; ((EditText) findViewById(R.id.edit_profile_pan)).setFilters(new InputFilter[] { filter }); int selected_gender = (gender.equalsIgnoreCase("male")) ? R.id.male : (gender.equalsIgnoreCase("female")) ? R.id.female : R.id.male; ((RadioGroup) findViewById(R.id.gender)).check(selected_gender); StorageManager sm = new StorageManager(); Object[] obj = sm.getStorageInfo(EditProfileActivity.this); profPath = obj[0].toString() + "/egovernments/profile"; String path = profPath + "/photo_" + mobileNo + ".jpg"; profileImage = new File(profPath + "/photo_temp_user.jpg"); File imgFile = new File(path); if (imgFile.exists()) { ((ImageView) findViewById(R.id.profile_image)).setImageBitmap(_getBitmapImage(path)); } if (profileImage.exists()) { profileImage.delete(); } }
From source file:org.pegdown.JshPegdownToHtmlSerializer.java
@Override protected void printWithAbbreviations(String string) { Map<Integer, Map.Entry<String, String>> expansions = null; for (Map.Entry<String, String> entry : abbreviations.entrySet()) { // first check, whether we have a legal match String abbr = entry.getKey(); int ix = 0; while (true) { int sx = string.indexOf(abbr, ix); if (sx == -1) break; // only allow whole word matches ix = sx + abbr.length();/*from w w w .java 2 s . com*/ if (sx > 0 && Character.isLetterOrDigit(string.charAt(sx - 1))) continue; if (ix < string.length() && Character.isLetterOrDigit(string.charAt(ix))) { continue; } // ok, legal match so save an expansions "task" for all matches if (expansions == null) { expansions = new TreeMap<Integer, Map.Entry<String, String>>(); } expansions.put(sx, entry); } } if (expansions != null) { int ix = 0; for (Map.Entry<Integer, Map.Entry<String, String>> entry : expansions.entrySet()) { int sx = entry.getKey(); String abbr = entry.getValue().getKey(); String expansion = entry.getValue().getValue(); printer.printEncoded(string.substring(ix, sx)); printer.print("<abbr"); if (StringUtils.isNotEmpty(expansion)) { printer.print(" title=\""); printer.printEncoded(expansion); printer.print("\""); } printer.print(">"); printer.printEncoded(abbr); printer.print("</abbr>"); ix = sx + abbr.length(); } printer.print(string.substring(ix)); } else { printer.print(string); } }
From source file:org.sd.util.cmd.AbstractExecutor.java
protected static int nextSymbol(String string, int fromPos) { final int len = string.length(); while (fromPos < len && Character.isLetterOrDigit(string.charAt(fromPos))) ++fromPos;//from ww w.j av a 2 s .c om return fromPos; }
From source file:com.sun.socialsite.util.Utilities.java
/** * Remove occurences of non-alphanumeric characters. *//*from w w w. j a v a2 s . c o m*/ public static String removeNonAlphanumeric(String str) { StringBuffer ret = new StringBuffer(str.length()); char[] testChars = str.toCharArray(); for (int i = 0; i < testChars.length; i++) { // MR: Allow periods in page links if (Character.isLetterOrDigit(testChars[i]) || testChars[i] == '.') { ret.append(testChars[i]); } } return ret.toString(); }
From source file:com.abstratt.mdd.frontend.textuml.renderer.TextUMLRenderingUtils.java
private static String escapeIdentifierIfNeeded(String identifier) { if (StringUtils.isBlank(identifier)) return ""; if (!StringUtils.isAlpha(identifier)) { StringBuffer result = new StringBuffer(identifier.length()); char[] chars = identifier.toCharArray(); for (int i = 0; i < chars.length; i++) { if (chars[i] != '_' && ((Character.isDigit(chars[i]) && i == 0) || !Character.isLetterOrDigit(chars[i]))) result.append('\\'); result.append(chars[i]);//ww w .jav a 2s .com } return result.toString(); } if (Arrays.binarySearch(TextUMLConstants.KEYWORDS, identifier) >= 0) return "\\" + identifier; return identifier; }