List of usage examples for java.lang Character isLetter
public static boolean isLetter(int codePoint)
From source file:com.avricot.prediction.utils.Steemer.java
/** * Checks a term if it can be processed correctly. *//w ww .j a v a2 s . c o m * @return boolean - true if, and only if, the given term consists in letters. */ private boolean isStemmable(String term) { boolean upper = false; int first = -1; for (int c = 0; c < term.length(); c++) { // Discard terms that contain non-letter characters. if (!Character.isLetter(term.charAt(c))) { return false; } // Discard terms that contain multiple uppercase letters. if (Character.isUpperCase(term.charAt(c))) { if (upper) { return false; } // First encountered uppercase letter, set flag and save // position. else { first = c; upper = true; } } } // Discard the term if it contains a single uppercase letter that // is not starting the term. if (first > 0) { return false; } return true; }
From source file:org.sleuthkit.autopsy.casemodule.Case.java
/** * Sanitize the case name for PostgreSQL database, Solr cores, and ActiveMQ * topics. Makes it plain-vanilla enough that each item should be able to * use it./*from w w w .j a v a 2s . c o m*/ * * Sanitize the PostgreSQL/Solr core, and ActiveMQ name by excluding: * Control characters Non-ASCII characters Various others shown below * * Solr: * http://stackoverflow.com/questions/29977519/what-makes-an-invalid-core-name * may not be / \ : * * ActiveMQ: * http://activemq.2283324.n4.nabble.com/What-are-limitations-restrictions-on-destination-name-td4664141.html * may not be ? * * PostgreSQL: * http://www.postgresql.org/docs/9.4/static/sql-syntax-lexical.html 63 * chars max, must start with a-z or _ following chars can be letters _ or * digits * * SQLite: Uses autopsy.db for the database name follows Windows naming * convention * * @param caseName The name of the case as typed in by the user * * @return the sanitized case name to use for Database, Solr, and ActiveMQ */ static String sanitizeCaseName(String caseName) { String result; // Remove all non-ASCII characters result = caseName.replaceAll("[^\\p{ASCII}]", "_"); // Remove all control characters result = result.replaceAll("[\\p{Cntrl}]", "_"); // Remove / \ : ? space ' " result = result.replaceAll("[ /?:'\"\\\\]", "_"); // Make it all lowercase result = result.toLowerCase(); // Must start with letter or underscore for PostgreSQL. If not, prepend an underscore. if (result.length() > 0 && !(Character.isLetter(result.codePointAt(0))) && !(result.codePointAt(0) == '_')) { result = "_" + result; } // Chop to 63-16=47 left (63 max for PostgreSQL, taking 16 for the date _20151225_123456) if (result.length() > MAX_SANITIZED_NAME_LENGTH) { result = result.substring(0, MAX_SANITIZED_NAME_LENGTH); } if (result.isEmpty()) { result = "case"; } return result; }
From source file:interfazGrafica.frmMoverRFC.java
private void txtCapturaCurpKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCapturaCurpKeyTyped char caracter = evt.getKeyChar(); if (Character.isDigit(caracter) || Character.isLetter(caracter)) { String texto = txtCapturaCurp.getText() + caracter; txtCapturaCurp.setText(texto.toUpperCase()); evt.consume();/* w w w. jav a 2s .co m*/ this.repaint(); } else { getToolkit().beep(); evt.consume(); } }
From source file:fiskinfoo.no.sintef.fiskinfoo.MapFragment.java
private void createProximityAlertSetupDialog() { final Dialog dialog = dialogInterface.getDialog(getActivity(), R.layout.dialog_proximity_alert_create, R.string.create_proximity_alert); Button setProximityAlertWatcherButton = (Button) dialog .findViewById(R.id.create_proximity_alert_create_alert_watcher_button); Button stopCurrentProximityAlertWatcherButton = (Button) dialog .findViewById(R.id.create_proximity_alert_stop_existing_alert_button); Button cancelButton = (Button) dialog.findViewById(R.id.create_proximity_alert_cancel_button); SeekBar seekbar = (SeekBar) dialog.findViewById(R.id.create_proximity_alert_seekBar); final EditText radiusEditText = (EditText) dialog.findViewById(R.id.create_proximity_alert_range_edit_text); final Switch formatSwitch = (Switch) dialog.findViewById(R.id.create_proximity_alert_format_switch); final double seekBarStepSize = (double) (getResources() .getInteger(R.integer.proximity_alert_maximum_warning_range_meters) - getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters)) / 100; radiusEditText.setText(//from w ww.ja v a2 s . co m String.valueOf(getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters))); formatSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { buttonView.setText(getString(R.string.range_format_nautical_miles)); } else { buttonView.setText(getString(R.string.range_format_meters)); } } }); seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { String range = String.valueOf( (int) (getResources().getInteger(R.integer.proximity_alert_minimum_warning_range_meters) + (seekBarStepSize * progress))); radiusEditText.setText(range); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); setProximityAlertWatcherButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String toastText; if (proximityAlertWatcher == null) { toastText = getString(R.string.proximity_alert_set); } else { toastText = getString(R.string.proximity_alert_replace); } if (proximityAlertWatcher != null) { proximityAlertWatcher.cancel(true); } mGpsLocationTracker = new GpsLocationTracker(getActivity()); double latitude, longitude; if (mGpsLocationTracker.canGetLocation()) { latitude = mGpsLocationTracker.getLatitude(); cachedLat = latitude; longitude = mGpsLocationTracker.getLongitude(); cachedLon = longitude; } else { mGpsLocationTracker.showSettingsAlert(); return; } if (formatSwitch.isChecked()) { cachedDistance = Double.valueOf(radiusEditText.getText().toString()) * getResources().getInteger(R.integer.meters_per_nautical_mile); } else { cachedDistance = Double.valueOf(radiusEditText.getText().toString()); } dialog.dismiss(); Response response; try { String apiName = "fishingfacility"; String format = "OLEX"; String filePath; String fileName = "collisionCheckToolsFile"; response = barentswatchApi.getApi().geoDataDownload(apiName, format); if (response == null) { Log.d(TAG, "RESPONSE == NULL"); throw new InternalError(); } if (fiskInfoUtility.isExternalStorageWritable()) { String directoryPath = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString(); String directoryName = "FiskInfo"; filePath = directoryPath + "/" + directoryName + "/"; InputStream zippedInputStream = null; try { TypedInput responseInput = response.getBody(); zippedInputStream = responseInput.in(); zippedInputStream = new GZIPInputStream(zippedInputStream); InputSource inputSource = new InputSource(zippedInputStream); InputStream input = new BufferedInputStream(inputSource.getByteStream()); byte data[]; data = FiskInfoUtility.toByteArray(input); InputStream inputStream = new ByteArrayInputStream(data); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); FiskInfoPolygon2D serializablePolygon2D = new FiskInfoPolygon2D(); String line; boolean startSet = false; String[] convertedLine; List<Point> shape = new ArrayList<>(); while ((line = reader.readLine()) != null) { Point currPoint = new Point(); if (line.length() == 0 || line.equals("")) { continue; } if (Character.isLetter(line.charAt(0))) { continue; } convertedLine = line.split("\\s+"); if (line.length() > 150) { Log.d(TAG, "line " + line); } if (convertedLine[0].startsWith("3sl")) { continue; } if (convertedLine[3].equalsIgnoreCase("Garnstart") && startSet) { if (shape.size() == 1) { // Point serializablePolygon2D.addPoint(shape.get(0)); shape = new ArrayList<>(); } else if (shape.size() == 2) { // line serializablePolygon2D.addLine(new Line(shape.get(0), shape.get(1))); shape = new ArrayList<>(); } else { serializablePolygon2D.addPolygon(new Polygon(shape)); shape = new ArrayList<>(); } startSet = false; } if (convertedLine[3].equalsIgnoreCase("Garnstart") && !startSet) { double lat = Double.parseDouble(convertedLine[0]) / 60; double lon = Double.parseDouble(convertedLine[1]) / 60; currPoint.setNewPointValues(lat, lon); shape.add(currPoint); startSet = true; } else if (convertedLine[3].equalsIgnoreCase("Brunsirkel")) { double lat = Double.parseDouble(convertedLine[0]) / 60; double lon = Double.parseDouble(convertedLine[1]) / 60; currPoint.setNewPointValues(lat, lon); shape.add(currPoint); } } reader.close(); new FiskInfoUtility().serializeFiskInfoPolygon2D(filePath + fileName + "." + format, serializablePolygon2D); tools = serializablePolygon2D; } catch (IOException e) { e.printStackTrace(); } catch (ArrayIndexOutOfBoundsException e) { Log.e(TAG, "Error when trying to serialize file."); Toast error = Toast.makeText(getActivity(), "Ingen redskaper i omrdet du definerte", Toast.LENGTH_LONG); e.printStackTrace(); error.show(); return; } finally { try { if (zippedInputStream != null) { zippedInputStream.close(); } } catch (IOException e) { e.printStackTrace(); } } } else { Toast.makeText(v.getContext(), R.string.download_failed, Toast.LENGTH_LONG).show(); dialog.dismiss(); return; } } catch (Exception e) { Log.d(TAG, "Could not download tools file"); Toast.makeText(getActivity(), R.string.download_failed, Toast.LENGTH_LONG).show(); } runScheduledAlarm(getResources().getInteger(R.integer.zero), getResources().getInteger(R.integer.proximity_alert_interval_time_seconds)); Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show(); } }); if (proximityAlertWatcher != null) { TypedValue outValue = new TypedValue(); stopCurrentProximityAlertWatcherButton.setVisibility(View.VISIBLE); getResources().getValue(R.dimen.proximity_alert_dialog_button_text_size_small, outValue, true); float textSize = outValue.getFloat(); setProximityAlertWatcherButton.setTextSize(textSize); stopCurrentProximityAlertWatcherButton.setTextSize(textSize); cancelButton.setTextSize(textSize); stopCurrentProximityAlertWatcherButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { proximityAlertWatcher.cancel(true); proximityAlertWatcher = null; dialog.dismiss(); } }); } cancelButton.setOnClickListener(onClickListenerInterface.getDismissDialogListener(dialog)); dialog.show(); }
From source file:org.wings.SComponent.java
/** * Sets the name property of a component which must be <b>unique</b>! * <br/>Assigning the same name multiple times will cause strange results! * <p/>//from w w w.ja v a2s. c o m * <p>Valid names must begin with a letter ([A-Za-z]), underscores ("_") or dollars ("$") and may be followed by any number of * letters, digits ([0-9]), underscores ("_") and dollars ("$") * <p/> * <p>If no name is set, it is generated when necessary. * <p/> * <p><i>Explanation:</i> This property is an identifier which is used inside the generated HTML as an element identifier (id="") * and sometimes as a javascript function name. * * @param uniqueName A <b>unique</b> name to set. <b>Only valid identifier as described are allowed!</b> * @see Character */ public void setName(String uniqueName) { if (uniqueName != null) { char ch = uniqueName.charAt(0); if (uniqueName.length() == 0 || !(Character.isLetter(ch) || ch == '_' || ch == '$')) throw new IllegalArgumentException(uniqueName + " is not a valid identifier"); for (int i = 1; i < uniqueName.length(); i++) { ch = uniqueName.charAt(i); if (!(Character.isLetter(ch) || Character.isDigit(ch) || ch == '_' || ch == '$')) throw new IllegalArgumentException(uniqueName + " is not a valid identifier"); } } setNameRaw(uniqueName); }
From source file:org.nuxeo.ecm.platform.ui.web.tag.fn.Functions.java
/** * Helper that escapes a string used as a JSF tag id: this is useful to replace characters that are not handled * correctly in JSF context.//from www . j a v a 2s.c o m * <p> * This method currently removes ASCII characters from the given string, and replaces "-" characters by "_" because * the dash is an issue for forms rendered in ajax (see NXP-10793). * <p> * Also starting digits are replaced by the "_" character because a tag id cannot start with a digit. * * @since 5.7 * @return the escaped string */ public static String jsfTagIdEscape(String base) { if (base == null) { return null; } int n = base.length(); StringBuilder res = new StringBuilder(); for (int i = 0; i < n; i++) { char c = base.charAt(i); if (i == 0) { if (!Character.isLetter(c) && (c != '_')) { res.append("_"); } else { res.append(c); } } else { if (!Character.isLetter(c) && !Character.isDigit(c) && (c != '_')) { res.append("_"); } else { res.append(c); } } } return org.nuxeo.common.utils.StringUtils.toAscii(res.toString()); }
From source file:org.celllife.idart.gui.patient.AddPatient.java
/** * This method initializes grpParticulars * //from w w w . j a v a 2s. c om */ private void createGrpParticulars() { int col2x = 105; // grpParticulars grpParticulars = new Group(compPatientInfo, SWT.NONE); grpParticulars.setBounds(new Rectangle(30, 40, 400, 255)); grpParticulars.setText(Messages.getString("patient.group.particulars")); //$NON-NLS-1$ grpParticulars.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); // Patient ID Label lblPatientId = new Label(grpParticulars, SWT.NONE); lblPatientId.setBounds(new Rectangle(7, 25, 84, 20)); lblPatientId.setText( Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.patientid")); //$NON-NLS-1$ //$NON-NLS-2$ lblPatientId.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); /*if(iDartProperties.country.equalsIgnoreCase("Nigeria")){ txtPatientId = new CustomIdField(grpParticulars, SWT.BORDER); txtPatientId.setBounds(new Rectangle(col2x, 25, 270, 20)); } else { txtPatientId = new TextAdapter(grpParticulars, SWT.BORDER); txtPatientId.setBounds(new Rectangle(col2x, 25, 150, 20)); }*/ txtPatientId = new TextAdapter(grpParticulars, SWT.BORDER); txtPatientId.setBounds(new Rectangle(col2x, 25, 150, 20)); txtPatientId.setData(iDartProperties.SWTBOT_KEY, "txtPatientId"); //$NON-NLS-1$ txtPatientId.setFocus(); txtPatientId.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); txtPatientId.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if ((btnSearch != null) && (btnSearch.getEnabled())) { if ((e.character == SWT.CR) || (e.character == (char) iDartProperties.intValueOfAlternativeBarcodeEndChar)) { cmdSearchWidgetSelected(); } } } }); if (isAddnotUpdate) { txtPatientId.setEnabled(false); } btnSearch = new Button(grpParticulars, SWT.NONE); btnSearch.setBounds(new Rectangle(270, 20, 119, 28)); /*if(iDartProperties.country.equalsIgnoreCase("Nigeria")){ btnSearch.setBounds(new Rectangle(270, 47, 110, 28)); } else { btnSearch.setBounds(new Rectangle(270, 20, 110, 28)); }*/ btnSearchByName = new Button(grpParticulars, SWT.NONE); btnSearchByName.setBounds(new Rectangle(270, 50, 119, 28)); if (!isAddnotUpdate) { btnSearchByName.setVisible(false); } if (isAddnotUpdate) { btnSearch.setText(Messages.getString("patient.button.editid")); //$NON-NLS-1$ btnSearch.setToolTipText(Messages.getString("patient.button.editid.tooltip")); //$NON-NLS-1$ btnSearchByName.setText(Messages.getString("patient.button.editid.nome")); //$NON-NLS-1$ btnSearchByName.setToolTipText(Messages.getString("patient.button.editid.tooltip.nome")); //$NON-NLS-1$ } else { btnSearch.setText(Messages.getString("patient.button.search")); //$NON-NLS-1$ btnSearch.setToolTipText(Messages.getString("patient.button.search.tooltip")); //$NON-NLS-1$ } btnSearch.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); btnSearch.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { cmdSearchWidgetSelected(); } }); btnSearchByName.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); btnSearchByName.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { cmdSearchWidgetSelectedSearchByName(); } }); btnEkapaSearch = new Button(grpParticulars, SWT.NONE); btnEkapaSearch.setBounds(new Rectangle(270, 47, 110, 28)); btnEkapaSearch.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); btnEkapaSearch.setText(Messages.getString("patient.button.ekapasearch")); //$NON-NLS-1$ if (!iDartProperties.isEkapaVersion || isAddnotUpdate) { btnEkapaSearch.setVisible(false); } btnEkapaSearch.setToolTipText(Messages.getString("patient.button.ekapasearch.tooltip")); //$NON-NLS-1$ btnEkapaSearch.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { cmdEkapaSearchWidgetSelected(); } }); // FirstNames Label lblFirstNames = new Label(grpParticulars, SWT.NONE); lblFirstNames.setBounds(new Rectangle(7, 55, 84, 20)); lblFirstNames.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); lblFirstNames.setText( Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.firstname")); //$NON-NLS-1$ //$NON-NLS-2$ txtFirstNames = new Text(grpParticulars, SWT.BORDER); txtFirstNames.setBounds(new Rectangle(col2x, 55, 150, 20)); txtFirstNames.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); // Surname Label lblSurname = new Label(grpParticulars, SWT.NONE); lblSurname.setBounds(new Rectangle(7, 85, 84, 20)); lblSurname.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); lblSurname.setText( Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.surname")); //$NON-NLS-1$ //$NON-NLS-2$ txtSurname = new Text(grpParticulars, SWT.BORDER); txtSurname.setBounds(new Rectangle(col2x, 85, 150, 20)); txtSurname.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); lblOtherPatientsWithThisID = new Label(grpParticulars, SWT.NONE); lblOtherPatientsWithThisID.setBounds(new Rectangle(355, 140, 40, 40)); lblOtherPatientsWithThisID.setImage(ResourceUtils.getImage(iDartImage.PATIENTDUPLICATES_30X26)); lblOtherPatientsWithThisID.setVisible(false); // Date of Birth Label lbldob = new Label(grpParticulars, SWT.NONE); lbldob.setBounds(new Rectangle(7, 115, 84, 20)); lbldob.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); lbldob.setText(Messages.getString("common.compulsory.marker") + Messages.getString("patient.label.dob")); //$NON-NLS-1$ //$NON-NLS-2$ cmbDOBDay = new Combo(grpParticulars, SWT.BORDER); cmbDOBDay.setBounds(new Rectangle(col2x, 112, 50, 18)); cmbDOBDay.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); cmbDOBDay.setBackground(ResourceUtils.getColor(iDartColor.WHITE)); cmbDOBDay.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { String theText = cmbDOBDay.getText(); if (cmbDOBDay.indexOf(theText) == -1) { cmbDOBDay.setText(cmbDOBDay.getItem(0)); } } }); cmbDOBMonth = new Combo(grpParticulars, SWT.BORDER); cmbDOBMonth.setBounds(new Rectangle(col2x + 50, 112, 97, 18)); cmbDOBMonth.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); cmbDOBMonth.setBackground(ResourceUtils.getColor(iDartColor.WHITE)); cmbDOBMonth.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { String theText = cmbDOBMonth.getText(); if (theText.length() > 2) { String s = theText.substring(0, 1); String t = theText.substring(1, theText.length()); theText = s.toUpperCase() + t; String[] items = cmbDOBMonth.getItems(); for (int i = 0; i < items.length; i++) { if (items[i].substring(0, 3).equalsIgnoreCase(theText)) { cmbDOBMonth.setText(items[i]); cmbDOBYear.setFocus(); } } } } }); cmbDOBYear = new Combo(grpParticulars, SWT.BORDER); cmbDOBYear.setBounds(new Rectangle(col2x + 148, 112, 60, 18)); cmbDOBYear.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); cmbDOBYear.setBackground(ResourceUtils.getColor(iDartColor.WHITE)); cmbDOBYear.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { String theText = cmbDOBYear.getText(); if ((cmbDOBYear.indexOf(theText) == -1) && (theText.length() >= 4)) { cmbDOBYear.setText(EMPTY); } } }); cmbDOBDay.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { cmdUpdateAge(); } }); cmbDOBMonth.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { cmdUpdateAge(); } }); cmbDOBYear.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { cmdUpdateAge(); } }); // populate the comboboxes ComboUtils.populateDateCombos(cmbDOBDay, cmbDOBMonth, cmbDOBYear, false, false); cmbDOBDay.setVisibleItemCount(cmbDOBDay.getItemCount()); cmbDOBMonth.setVisibleItemCount(cmbDOBMonth.getItemCount()); cmbDOBYear.setVisibleItemCount(31); // Sex Label lblSex = new Label(grpParticulars, SWT.NONE); lblSex.setBounds(new Rectangle(7, 152, 84, 20)); lblSex.setText(Messages.getString("patient.label.sex")); //$NON-NLS-1$ lblSex.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); cmbSex = new Combo(grpParticulars, SWT.BORDER); cmbSex.setBounds(new Rectangle(col2x, 145, 150, 18)); cmbSex.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); cmbSex.setBackground(ResourceUtils.getColor(iDartColor.WHITE)); // cmbSex.setEditable(false); //cmbSex.add(Messages.getString("common.unknown")); //$NON-NLS-1$ cmbSex.add(Messages.getString("patient.sex.female")); //$NON-NLS-1$ cmbSex.add(Messages.getString("patient.sex.male")); //$NON-NLS-1$ //cmbSex.setText(Messages.getString("common.unknown")); //$NON-NLS-1$ cmbSex.select(0); cmbSex.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { e.doit = false; Character keyPressed = new Character(Character.toLowerCase(e.character)); getLog().debug("The char pressed in cmbSex: " + keyPressed); //$NON-NLS-1$ if (Character.isLetter(keyPressed)) { if (keyPressed.equals('f')) { cmbSex.select(1); } else if (keyPressed.equals('m')) { cmbSex.select(2); } else { cmbSex.select(0); } updateClinicInfoTab(); } } }); /* * add TraverseListener to allow traversal out of combo see JavaDoc for * org.eclipse.swt.events.KeyEvent */ cmbSex.addTraverseListener(new TraverseListener() { @Override public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) { e.doit = true; } else { e.doit = false; } } }); cmbSex.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent se) { updateClinicInfoTab(); } }); // Age Label lblAge = new Label(grpParticulars, SWT.NONE); lblAge.setBounds(new Rectangle(col2x + 212, 117, 33, 20)); lblAge.setText(Messages.getString("patient.label.age")); //$NON-NLS-1$ lblAge.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); txtAge = new Text(grpParticulars, SWT.BORDER); txtAge.setBounds(new Rectangle(col2x + 249, 114, 35, 20)); txtAge.setEditable(false); txtAge.setEnabled(false); txtAge.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); // Child Icon lblPicChild = new Label(grpParticulars, SWT.NONE); lblPicChild.setBounds(new Rectangle(255, 140, 50, 43)); lblPicChild.setImage(ResourceUtils.getImage(iDartImage.CHILD_50X43)); lblPicChild.setVisible(false); transito = new Button(grpParticulars, SWT.CHECK); transito.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 1, 1)); transito.setBounds(new Rectangle(col2x, 150, 150, 18)); transito.setText("Paciente Em Transito"); transito.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); transito.setSelection(false); // Phone Cell Label lblPhoneCell = new Label(grpParticulars, SWT.NONE); lblPhoneCell.setBounds(new Rectangle(7, 207, 85, 20)); lblPhoneCell.setText(Messages.getString("patient.label.cellphone")); //$NON-NLS-1$ lblPhoneCell.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); txtCellphone = new Text(grpParticulars, SWT.BORDER); txtCellphone.setBounds(new Rectangle(col2x, 205, 150, 20)); txtCellphone.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); txtCellphone.setEnabled(false); Label lblARVStartDate = new Label(grpParticulars, SWT.NONE); lblARVStartDate.setBounds(new Rectangle(7, 233, 90, 20)); lblARVStartDate.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); lblARVStartDate.setText(Messages.getString("patient.label.arvstartdate")); //$NON-NLS-1$ btnARVStart = new DateButton(grpParticulars, DateButton.ZERO_TIMESTAMP, new DateInputValidator(DateRuleFactory.beforeNowInclusive(true))); btnARVStart.setBounds(new Rectangle(col2x, 230, 150, 20)); btnARVStart.setFont(ResourceUtils.getFont(iDartFont.VERASANS_8)); btnARVStart.setText(Messages.getString("common.unknown")); //$NON-NLS-1$ btnPatientHistoryReport = new Button(grpParticulars, SWT.NONE); btnPatientHistoryReport.setBounds(new Rectangle(310, 140, 40, 40)); btnPatientHistoryReport.setToolTipText(Messages.getString("patient.button.report.tooltip")); //$NON-NLS-1$ btnPatientHistoryReport.setImage(ResourceUtils.getImage(iDartImage.REPORT_PATIENTHISTORY_30X26)); btnPatientHistoryReport.addMouseListener(new MouseAdapter() { @Override public void mouseUp(MouseEvent mu) { cmdPatientHistoryWidgetSelected(); } }); }
From source file:CharUtils.java
/** * True if string is all caps./*from w ww. j a v a 2s .c om*/ * * @param s * String to check for being all capitals. * * @return True if string is all capitals. */ public static boolean isAllCaps(String s) { boolean result = true; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (Character.isLetter(ch)) { result = result && Character.isUpperCase(ch); if (!result) break; } } return result; }
From source file:org.rhq.core.domain.server.PersistenceUtility.java
private static int findSelectListEndIndex(String query) { int nesting = 0; query = query.toLowerCase();/*from w w w . ja v a 2s .co m*/ StringBuilder wordBuffer = new StringBuilder(); for (int i = 0; i < query.length(); i++) { char next = query.charAt(i); if (next == '(') { nesting++; } else if (next == ')') { nesting--; } else { if (nesting != 0) { continue; } if (Character.isLetter(next)) { wordBuffer.append(next); if (wordBuffer.toString().equals("from")) { return i - 4; // return index representing the character just before "from" } } else { wordBuffer.setLength(0); // clear buffer if we find any non-letter } } } throw new IllegalArgumentException("Could not find select list end index"); }
From source file:org.nines.NinesStatementHandler.java
public static ArrayList<String> parseYears(String value) { ArrayList<String> years = new ArrayList<String>(); if ("unknown".equalsIgnoreCase(value.trim()) || uncertain.equalsIgnoreCase(value.trim())) { return (years); }/* w ww . j ava 2 s. c o m*/ // deal with embedded whitespace in ranges value = value.replace(", ", ",").replace(" ,", ","); StringTokenizer tokenizer = new StringTokenizer(value); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); int range = token.indexOf(','); int wild = token.indexOf('u'); // if we have a leading alpha (e.g "Aug") it is ignored if (Character.isLetter(token.charAt(0)) == true) { years.clear(); return (years); } // ranges containing wildcards are forbidden if (range != -1 && wild != -1) { years.clear(); return (years); } if (range != -1) { parseYearRange(years, token); } else if (wild != -1) { parseYearWild(years, token); } else { if (token.length() >= 4) { years.add(token.substring(0, 4)); } else { // invalid date, less than 4 characters years.clear(); return (years); } } } return (years); }