List of usage examples for java.lang CharSequence toString
public String toString();
From source file:Main.java
public static void autoCompleteTime(CharSequence text, EditText time, TextView timeHint) { String stringText = text.toString(); String textToBeSet = ""; int inputType = InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_TIME; time.setError(null); //remove any error set from previously boolean error = false; if (stringText.matches("^\\d$")) { if (stringText.equals("1") || stringText.equals("0")) textToBeSet = "0:00AM"; else {// w w w .jav a 2 s.co m textToBeSet = ":00AM"; } } else if (stringText.matches("^\\d\\d$")) { int intText = Integer.parseInt(stringText); if (intText >= 0 && intText <= 12) textToBeSet = ":00AM"; else error = true; } else if (stringText.matches("^\\d+:$")) textToBeSet = "00AM"; else if (stringText.matches("^\\d+:\\d$")) textToBeSet = "0AM"; else if (stringText.matches("^\\d+:\\d\\d$")) { int intText = Integer.parseInt(stringText.replaceAll("^\\d+:", "")); //get minutes if (intText > 0 && intText < 60) { inputType = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; textToBeSet = "AM"; } else error = true; } else if (stringText.matches("^\\d+:\\d\\d(A|P)$")) { inputType = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS; textToBeSet = "M"; } else if (stringText.equals("")) textToBeSet = ""; else if (stringText.matches("^\\d+:\\d+(A|P)M")) { //To-do - take control to next input field } else {//error condition error = true; } if (error) { textToBeSet = ""; time.setError("Incorrect time format"); } time.setInputType(inputType); timeHint.setText(textToBeSet); }
From source file:net.darkmist.alib.str.StrUtil.java
/** * Join strings with a delimiter./*from w w w. j av a 2s . c o m*/ * @param delimiter The delimiter to use between strings. * @param strs The Strings to join. */ // not deprecated because this allows vargs public static final String join(CharSequence delimiter, CharSequence... strs) { return StringUtils.join(strs, delimiter.toString()); }
From source file:Main.java
protected static String transformSerial(CharSequence n, int srcBase, int dstBase, int p1Width, int p1Padding, int p2Padding) { String p1 = lPad(Long.toString(Long.parseLong(n.toString().substring(0, p1Width), srcBase), dstBase), p1Padding, "0"); String p2 = lPad(Long.toString(Long.parseLong(n.toString().substring(p1Width), srcBase), dstBase), p2Padding, "0"); String c = p1 + p2;//from w w w . j a va 2s.c o m return c.toUpperCase(); }
From source file:Main.java
public static CharSequence ZawGyiDrawFix(CharSequence input, int fixCode) { if (fixCode == 0x0) return input; String output = input.toString(); int index = 0; char[] chArray = new char[output.length()]; for (int i = 0; i < output.length(); i++) { int ch = (int) output.charAt(i); if ((ch != NULL_CHAR) && (isMyChar(ch))) { chArray[index++] = (char) (ch + fixCode); // 0xEA00 } else {//from w ww. jav a 2s. c o m chArray[index++] = (char) ch; } } return String.valueOf(chArray); }
From source file:org.matrix.security.crypto.encrypt.Encryptors.java
/** * Creates an encryptor for queryable text strings that uses standard password-based encryption. * Uses a 16-byte all-zero initialization vector so encrypting the same data results in the same encryption result. * This is done to allow encrypted data to be queried against. * Encrypted text is hex-encoded./*from w w w . j a va2s. c om*/ * * @param password the password used to generate the encryptor's secret key; should not be shared * @param salt a hex-encoded, random, site-global salt value to use to generate the secret key */ public static TextEncryptor queryableText(CharSequence password, CharSequence salt) { return new HexEncodingTextEncryptor(new AesBytesEncryptor(password.toString(), salt)); }
From source file:com.cloudera.oryx.kmeans.computation.VectorConvert.java
public static RealVector fromString(CharSequence input) { RealVector rv = VECTOR_FORMAT.parse(input.toString()); int density = 0; for (int i = 0; i < rv.getDimension(); i++) { if (rv.getEntry(i) != 0.0) { density++;//from w ww . jav a 2s . c o m } } if (2 * density < rv.getDimension()) { return new OpenMapRealVector(rv); } else { return rv; } }
From source file:Main.java
public static final int convertValueToInt(CharSequence charSeq, int defaultValue) { if (null == charSeq) { return defaultValue; }// w w w .ja v a 2 s . co m String nm = charSeq.toString(); int sign = 1; int index = 0; int len = nm.length(); int base = 10; if ('-' == nm.charAt(0)) { sign = -1; index++; } if ('0' == nm.charAt(index)) { // Quick check for a zero by itself if (index == len - 1) { return 0; } char c = nm.charAt(index + 1); if ('x' == c || 'X' == c) { index += 2; base = 16; } else { index++; base = 8; } } else if ('#' == nm.charAt(index)) { index++; base = 16; } return Integer.parseInt(nm.substring(index), base) * sign; }
From source file:Main.java
/** * Gets the activity list./* ww w . ja v a2 s. co m*/ * * @param context * the context * @param intent * the intent * * @return the activity list */ public static List<Hashtable<String, Object>> getActivityList(Context context, Intent intent) { List<Hashtable<String, Object>> result = new ArrayList<Hashtable<String, Object>>(); PackageManager pm = context.getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(intent.addCategory("android.intent.category.DEFAULT"), 0); for (ResolveInfo info : list) { Hashtable<String, Object> h = new Hashtable<String, Object>(); CharSequence labelSeq = info.activityInfo.loadLabel(pm); String label = labelSeq != null ? labelSeq.toString() : info.activityInfo.name; h.put(LABEL, label); h.put(INTENT, activityIntent(info.activityInfo.applicationInfo.packageName, info.activityInfo.name)); result.add(h); } Collections.sort(result, displayNameComparator); return result; }
From source file:Main.java
public static String igFormattedDate(String timestamp) { /**/*from w w w .ja va 2 s.c o m*/ * From the group discussion board. */ CharSequence relativeDateTimeString = DateUtils.getRelativeTimeSpanString(Long.parseLong(timestamp) * 1000, System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS); return relativeDateTimeString.toString().replaceAll("[^0-9]+", "s"); }
From source file:com.threewks.thundr.search.QueryComponent.java
/** * Create a {@link QueryComponent} for a raw query string. * //ww w . ja va 2s .c om * @param query * @return */ public static QueryComponent forRawQuery(CharSequence query) { return new QueryComponent(query.toString(), null, null); }