List of usage examples for java.lang Character isDigit
public static boolean isDigit(int codePoint)
From source file:android.pim.vcard.VCardBuilder.java
private List<String> splitIfSeveralPhoneNumbersExist(final String phoneNumber) { List<String> phoneList = new ArrayList<String>(); StringBuilder builder = new StringBuilder(); final int length = phoneNumber.length(); for (int i = 0; i < length; i++) { final char ch = phoneNumber.charAt(i); // TODO: add a test case for string with '+', and care the other possible issues // which may happen by ignoring non-digits other than '+'. if (Character.isDigit(ch) || ch == '+') { builder.append(ch);//from ww w . ja v a 2 s .c om } else if ((ch == ';' || ch == '\n') && builder.length() > 0) { phoneList.add(builder.toString()); builder = new StringBuilder(); } } if (builder.length() > 0) { phoneList.add(builder.toString()); } return phoneList; }
From source file:com.meiah.core.util.StringUtil.java
/** * @description ?//w w w .j a va 2s .c o m * @param string * @return * @date 2013-04-15 */ public static boolean isNumber(String string) { boolean result = true; for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (!Character.isDigit(c)) { result = false; break; } } return result; }
From source file:ca.inverse.sogo.engine.source.SOGoUtilities.java
/** * This method is used to convert a vCalendar object from v2 to v1. * We might lose some information by doing so but we try our best * to not to. Here are the required transformations. * /*from w w w . ja va 2 s .c om*/ * 1- removal of all VTIMEZONE information + UTC offset adjustments * 2- start/end (or due) date adjustments if the connecting device * doesn't support UTC * 3- if we get TZID in DTSTART/DTEND, convert DTSTART/DTEND to UTC * if our devices supports it, otherwise, leave it as is * * --------------------------------------------------------------------------- * Devices supports UTC | Input | TZ to use | Output * ----------------------|-------------------|-----------|-------------------- * YES | UTC | none | UTC * YES | non-UTC | pref. TZ | UTC * YES | non-UTC + TZID | TZID | UTC * NO | UTC | pref. TZ | non-UTC * NO | non-UTC | none | non-UTC * NO | non-UTC + TZID | none | non-UTC * * @param bytes * @return */ public static byte[] vCalendarV2toV1(byte[] bytes, String tag, String key, boolean secure, int classification, SOGoSyncSource source, SyncContext context, FunambolLogger log) { String s; log.info("About to convert vCalendar (from v2 to v1): " + new String(bytes)); s = ""; try { VCalendarConverter converter; VComponentWriter writer; VCalendar v2, calendar; CalendarContent cc; ICalendarParser p; Calendar cal; // We need to proceed with the following steps // iCalendar -> VCalendar object -> Calendar object -> VCalendar v1.0 object -> string p = new ICalendarParser( new ByteArrayInputStream(SOGoSanitizer.sanitizevCalendarInput(bytes, key, log).getBytes())); v2 = p.ICalendar(); converter = new VCalendarConverter(getUserTimeZone(source, context, log), source.getDeviceCharset(), false); cal = converter.vcalendar2calendar(v2); // HACK: Funambol (at least, v6.5-7.1) crashes in VCalendarContentConverter: cc2vcc // since it is trying to get this property's value while it might be null. SOGoSanitizer.sanitizeFunambolCalendar(cal); cc = cal.getCalendarContent(); if (tag != null) { String summary; tag = "[" + tag + "] "; summary = cc.getSummary().getPropertyValueAsString(); if (!summary.startsWith(tag)) { summary = tag + summary; cc.setSummary(new Property(summary)); } if (secure) { secureCalendarContent(cc, tag, classification); } } // The Funambol client for BlackBerry devices is a real piece of crap. // It does NOT honor the X-FUNAMBOL-ALLDAY tag so we must do some magic // here to make it believe it's an all-day event. Otherwise, the all-day // event will span two days on the BlackBerry device. if (isBlackBerry(context) && cc.isAllDay()) { SimpleDateFormat formatter; java.util.Date d; String ss; // We can either parse 20120828 or 2012-08-28 ss = cc.getDtStart().getPropertyValueAsString(); d = null; try { formatter = new SimpleDateFormat("yyyy-MM-dd"); d = formatter.parse(ss); } catch (Exception pe) { } if (d == null) { try { formatter = new SimpleDateFormat("yyyyMMdd"); d = formatter.parse(ss); } catch (Exception pe) { } } if (d != null) { formatter = new SimpleDateFormat("yyyyMMdd"); ss = formatter.format(d) + "T000000"; cc.getDtStart().setPropertyValue(ss); ss = formatter.format(d) + "T235900"; cc.getDtEnd().setPropertyValue(ss); } } // The boolean parameter triggers v1 vs. v2 conversion (v1 == true) calendar = converter.calendar2vcalendar(cal, true); copyCustomProperties(v2.getVCalendarContent(), calendar.getVCalendarContent()); // Funambol loses alarm settings when converting to a Calendar object, see // http://forge.ow2.org/tracker/index.php?func=detail&aid=314860&group_id=96&atid=100096 // Try to convert any valarm from v2 to aalarm. // This is implementation will probably fix 95% of the cases, but doesn't cover // multiple alarms or alarm times set relative to the end of the event // Also note that at least Symbian devices does not seem to support relative alarms VAlarm valarm = (VAlarm) v2.getVCalendarContent().getComponent("VALARM"); log.info("VALARM is: " + valarm); if (valarm != null) { com.funambol.common.pim.model.Property trigger; // TRIGGER;VALUE=DURATION:-PT15M trigger = valarm.getProperty("TRIGGER"); log.info("TRIGGER: " + trigger.getValue()); // -PT15 if (trigger.getParameter("VALUE") != null) { String duration; duration = trigger.getParameter("VALUE").value; if (duration.equalsIgnoreCase("DURATION")) { String value; boolean negate; int len, i, v; char c; value = trigger.getValue(); // -PT15 log.info("VALUE to parse: " + value); len = value.length(); negate = false; // v is always in seconds v = 0; // We parse : // // dur-value = (["+"] / "-") "P" (dur-date / dur-time / dur-week) // // dur-date = dur-day [dur-time] // dur-time = "T" (dur-hour / dur-minute / dur-second) // dur-week = 1*DIGIT "W" // dur-hour = 1*DIGIT "H" [dur-minute] // dur-minute = 1*DIGIT "M" [dur-second] // dur-second = 1*DIGIT "S" // dur-day = 1*DIGIT "D" // for (i = 0; i < len; i++) { c = value.charAt(i); if (c == 'P' || c == 'p' || c == 'T' || c == 't') { log.info("Skipping " + c); continue; } if (c == '-') { negate = true; log.info("Negating..."); continue; } if (Character.isDigit(c)) { int j, x; log.info("Digit found at " + i); for (j = i; j < len; j++) { c = value.charAt(j); if (!Character.isDigit(c)) break; } log.info("End digit found at " + i); x = Integer.parseInt(value.substring(i, j)); log.info("x = " + x); // Char at j is either W, H, M, S or D switch (value.charAt(j)) { case 'W': v += x * (7 * 24 * 3600); break; case 'H': v += x * 3600; break; case 'M': v += x * 60; break; case 'S': v += x; break; case 'D': default: v += x * (24 * 3600); break; } log.info("v1 = " + v); i = j + 1; } } // for (...) log.info("v2 = " + v); if (negate) v = -v; log.info("v3 = " + v); // Let's add this to our start time.. we'll support end time later if (v != 0) { SimpleDateFormat dateFormatter; java.util.Date d; log.info("DTSTART: " + cc.getDtStart().getPropertyValue()); log.info("v = " + v); try { dateFormatter = new SimpleDateFormat(TimeUtils.PATTERN_UTC); d = dateFormatter.parse(cc.getDtStart().getPropertyValueAsString()); d.setTime(d.getTime() + v * 1000); calendar.getVCalendarContent().addProperty("AALARM", dateFormatter.format(d)); // DURATION } catch (Exception e) { log.error("Exception occured in vCalendarV2toV1(): " + e.toString(), e); } } } } } // Write result writer = new VComponentWriter(VComponentWriter.NO_FOLDING); s = writer.toString(calendar); log.info(s); } catch (Exception e) { log.error("Exception occured in vCalendarV2toV1(): " + e.toString(), e); log.info("===== item content (" + key + ") ====="); log.info(new String(bytes)); log.info("======================================"); } return s.getBytes(); }
From source file:example.rest.ApiREST.java
public String checkIfExistsAndReturnValidFolder(String fileName, String name) { //System.out.println("Check if folder exists: " + fileName); //System.out.println("File name : " + name); nombreFinal = name;/*from ww w . j av a2 s. co m*/ File f = new File(fileName); if (f.exists() && f.isDirectory()) { //System.out.println("SI EXISTE : " + name); if (name.length() > 3) { String prueba = name.substring(name.length() - 3, name.length()); //System.out.println("prueba : " + prueba); if (prueba.charAt(0) == '(' && Character.isDigit(prueba.charAt(1)) && prueba.charAt(2) == ')') { //System.out.println("Estamos en lo correctop"); int i = Character.getNumericValue(prueba.charAt(1)); i++; String nuevo = name.substring(0, name.length() - 3) + "(" + i + ")"; String ruta = fileName.substring(0, fileName.lastIndexOf(name)); ruta = ruta + nuevo; return checkIfExistsAndReturnValidFolder(ruta, nuevo); } } else { } num++; String nameASumar = name; String ruta = fileName.substring(0, fileName.lastIndexOf(name)); //System.out.println("nombreOriginal : " + nombreOriginal); ruta = ruta + nombreOriginal + "(" + num + ")"; //System.out.println("ruta final antes de mandar:" + ruta); return checkIfExistsAndReturnValidFolder(ruta, nombreOriginal + "(" + num + ")"); } else { return fileName; } }
From source file:net.java.sip.communicator.gui.AuthenticationSplash.java
public boolean valid() { int idx;/* ww w .j av a2 s .c o m*/ boolean usern = true, pwd = true, nme = true, lnme = true, ml = true; // Username checks // Starts with a letter if (userName.length() == 0) usern = false; else if (!Character.isLetter(userName.charAt(0))) usern = false; // Contains only letters and numbers for (idx = 0; idx < userName.length(); idx++) { if (!Character.isLetterOrDigit(userName.charAt(idx))) usern = false; } // Is between 4 and 10 characters if ((userName.length() < 4) || (userName.length() > 18)) usern = false; // Name and last name checks // Both begin with uppercase if (name.length() == 0) nme = false; else if (!Character.isUpperCase(name.charAt(0))) nme = false; if (lastName.length() == 0) lnme = false; else if (!Character.isUpperCase(lastName.charAt(0))) lnme = false; // Both contain only letters for (idx = 0; idx < name.length(); idx++) { if (!Character.isLetter(name.charAt(idx))) nme = false; } for (idx = 0; idx < lastName.length(); idx++) { if (!Character.isLetter(lastName.charAt(idx))) lnme = false; } // Mail chekcs Pattern ptr = Pattern.compile( "(?:(?:\\r\\n)?[ \\t])*(?:(?:(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])*))*@(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031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\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])*))*@(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*))*\\>(?:(?:\\r\\n)?[ \\t])*))*)?;\\s*)"); if (!ptr.matcher(mail).matches()) ml = false; // Password checks // Check that we have a variety of different characters boolean lower = false, upper = false, number = false, other = false; for (idx = 0; idx < password.length(); idx++) { if (Character.isUpperCase(password.charAt(idx))) upper = true; if (Character.isLowerCase(password.charAt(idx))) lower = true; if (!Character.isLetterOrDigit(password.charAt(idx))) other = true; if (Character.isDigit(password.charAt(idx))) number = true; } if (!(upper && lower && number && other)) pwd = false; // Verify that the size is acceptable if (password.length() < 6 || password.length() > 30) pwd = false; // Change the label colors if (!nme) { nameLabel.setForeground(Color.RED); nameTextField.setText(""); } if (!lnme) { lastNameLabel.setForeground(Color.RED); lastNameTextField.setText(""); } if (!ml) { mailLabel.setForeground(Color.RED); mailTextField.setText(""); } if (!usern) { userNameLabel.setForeground(Color.RED); userNameTextField.setText(""); } if (!pwd) { passwordLabel.setForeground(Color.RED); passwordTextField.setText(""); } if (!(nme && lnme && usern && ml && pwd)) return false; return true; }
From source file:fi.ni.IFC_ClassModel.java
/** * Parse_ if c_ line statement.//from w w w . j a v a2 s . com * * @param line * the line */ private void parse_IFC_LineStatement(String line) { IFC_X3_VO ifcvo = new IFC_X3_VO(); int state = 0; StringBuffer sb = new StringBuffer(); int cl_count = 0; LinkedList<Object> current = ifcvo.getList(); Stack<LinkedList<Object>> list_stack = new Stack<LinkedList<Object>>(); for (int i = 0; i < line.length(); i++) { char ch = line.charAt(i); switch (state) { case 0: if (ch == '=') { ifcvo.setLine_num(toLong(sb.toString())); sb.setLength(0); state++; continue; } else if (Character.isDigit(ch)) sb.append(ch); break; case 1: // ( if (ch == '(') { ifcvo.setName(sb.toString()); sb.setLength(0); state++; continue; } else if (ch == ';') { ifcvo.setName(sb.toString()); sb.setLength(0); state = Integer.MAX_VALUE; } else if (!Character.isWhitespace(ch)) sb.append(ch); break; case 2: // (... line started and doing (... if (ch == '\'') { state++; } if (ch == '(') { list_stack.push(current); LinkedList<Object> tmp = new LinkedList<Object>(); if (sb.toString().trim().length() > 0) current.add(sb.toString().trim()); sb.setLength(0); current.add(tmp); // listaan listn lista current = tmp; cl_count++; // sb.append(ch); } else if (ch == ')') { if (cl_count == 0) { if (sb.toString().trim().length() > 0) current.add(sb.toString().trim()); sb.setLength(0); state = Integer.MAX_VALUE; // line is done continue; } else { if (sb.toString().trim().length() > 0) current.add(sb.toString().trim()); sb.setLength(0); cl_count--; current = list_stack.pop(); } } else if (ch == ',') { if (sb.toString().trim().length() > 0) current.add(sb.toString().trim()); current.add(Character.valueOf(ch)); sb.setLength(0); } else { sb.append(ch); } break; case 3: // (... if (ch == '\'') { state--; } else { sb.append(ch); } break; default: // Do nothing } } linemap.put(ifcvo.line_num, ifcvo); }
From source file:edu.stanford.epad.common.util.EPADFileUtils.java
private static boolean isNumber(String checkForNumber) { for (int i = 0; i < checkForNumber.length(); i++) { // If we find a non-digit character we return false. if (!Character.isDigit(checkForNumber.charAt(i))) return false; }/* ww w . ja v a 2 s .c om*/ return true; }
From source file:cn.kangeqiu.kq.activity.LoginActivity.java
/** * hearder?header??ABCD...????// w w w.java 2 s . co m * * @param username * @param user */ protected void setUserHearder(String username, User user) { String headerName = null; if (!TextUtils.isEmpty(user.getNick())) { headerName = user.getNick(); } else { headerName = user.getUsername(); } if (username.equals(Constant.NEW_FRIENDS_USERNAME)) { user.setHeader(""); } else if (Character.isDigit(headerName.charAt(0))) { user.setHeader("#"); } else { user.setHeader(HanziToPinyin.getInstance().get(headerName.substring(0, 1)).get(0).target.substring(0, 1) .toUpperCase()); char header = user.getHeader().toLowerCase().charAt(0); if (header < 'a' || header > 'z') { user.setHeader("#"); } } }
From source file:javax.faces.component.UIComponentBase.java
/** * @param string the component id, that should be a vaild one. *//*from w w w. ja va 2 s . c om*/ private void isIdValid(String string) { //is there any component identifier ? if (string == null) return; //Component identifiers must obey the following syntax restrictions: //1. Must not be a zero-length String. if (string.length() == 0) { throw new IllegalArgumentException("component identifier must not be a zero-length String"); } //let's look at all chars inside of the ID if it is a valid ID! char[] chars = string.toCharArray(); //2. First character must be a letter or an underscore ('_'). if (!Character.isLetter(chars[0]) && chars[0] != '_') { throw new IllegalArgumentException( "component identifier's first character must be a letter or an underscore ('_')! But it is \"" + chars[0] + "\""); } for (int i = 1; i < chars.length; i++) { //3. Subsequent characters must be a letter, a digit, an underscore ('_'), or a dash ('-'). if (!Character.isDigit(chars[i]) && !Character.isLetter(chars[i]) && chars[i] != '-' && chars[i] != '_') { throw new IllegalArgumentException( "Subsequent characters of component identifier must be a letter, a digit, an underscore ('_'), or a dash ('-')! But component identifier contains \"" + chars[i] + "\""); } } }