public static String[] parseTokenizedString(String string2BeParsed, String demiliter) { StringTokenizer tokenizer = new StringTokenizer(string2BeParsed, demiliter); String[] choices = new String[tokenizer.countTokens()]; int index = 0; // each token is the display name for the column while (tokenizer.hasMoreTokens()) { choices[index] = tokenizer.nextToken(); index++; } return choices; }
/** * Parses the given accelerator text, and converts it to an accelerator key code. * * @param acceleratorText the accelerator text * @result the SWT key code, or 0 if there is no accelerator */ private int convertAccelerator(String acceleratorText) { int accelerator = 0; StringTokenizer stok = new StringTokenizer(acceleratorText, "+"); // $NON-NLS-1$ int keyCode = -1; boolean hasMoreTokens = stok.hasMoreTokens(); while (hasMoreTokens) { String token = stok.nextToken(); hasMoreTokens = stok.hasMoreTokens(); // Every token except the last must be one of the modifiers // Ctrl, Shift, or Alt. if (hasMoreTokens) { int modifier = Action.findModifier(token); if (modifier != 0) { accelerator |= modifier; } else { // Leave if there are none return 0; } } else { keyCode = Action.findKeyCode(token); } } if (keyCode != -1) { accelerator |= keyCode; } return accelerator; }
/** * Parses the input string to a GRB object. * * @param string The input string. * @return The RGB object represented the string. */ protected RGB parseString(String string) { int colors[] = ColorUtil.getRGBs(string); if (colors != null) return new RGB(colors[0], colors[1], colors[2]); StringTokenizer st = new StringTokenizer(string, " ,()"); // $NON-NLS-1$ if (!st.hasMoreTokens()) return null; int[] rgb = new int[] {0, 0, 0}; int index = 0; while (st.hasMoreTokens()) { try { rgb[index] = Integer.decode(st.nextToken()).intValue(); if (rgb[index] < 0 || rgb[index] > 255) return null; index++; } catch (Exception e) { return null; } } return new RGB(rgb[0], rgb[1], rgb[2]); }
/** * Determines if currently tracing a category * * @param category * @return true if tracing category, false otherwise */ public static boolean isTracing(String category) { if (!isDebugging()) return false; String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION); if (traceFilter != null) { StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); // $NON-NLS-1$ while (tokenizer.hasMoreTokens()) { String cat = tokenizer.nextToken().trim(); if (category.equals(cat)) { return true; } } } return false; }
private String getConvertedOrthogonalSampleDataRepresentation(String sOldRepresentation) { StringTokenizer strtok = new StringTokenizer(sOldRepresentation, ","); // $NON-NLS-1$ StringBuffer sbNewRepresentation = new StringBuffer(""); // $NON-NLS-1$ while (strtok.hasMoreTokens()) { String sElement = strtok.nextToken().trim(); if (sElement.startsWith("H")) // $NON-NLS-1$ // Orthogonal sample data is for a // stock chart (Orthogonal sample // data CANNOT // be text { StringTokenizer strStockTokenizer = new StringTokenizer(sElement); sbNewRepresentation.append(strStockTokenizer.nextToken().trim().substring(1)); } else { sbNewRepresentation.append(sElement); } sbNewRepresentation.append(","); // $NON-NLS-1$ } return sbNewRepresentation.toString().substring(0, sbNewRepresentation.length() - 1); }