Java Code Examples for java.util.StringTokenizer

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/generic/.

Source file: Utils.java

  20 
vote

public static int matchSpan(String pattern,String string){
  int result=0;
  StringTokenizer st=new StringTokenizer(pattern,"|");
  while (st.hasMoreTokens()) {
    int len=matchSpan1(st.nextToken(),string);
    if (len > result)     result=len;
  }
  return result;
}
 

Example 2

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.nmrshiftdb/src/net/bioclipse/nmrshiftdb/wizards/.

Source file: SpectrumTypeWizardPage.java

  19 
vote

/** 
 * Initializes the UI of the page.
 * @throws Exception
 */
public void initUi() throws Exception {
  spectrumTypes=Activator.getDefault().getJavaNmrshiftdbManager().getSpectrumTypes(((PredictWizard)this.getWizard()).getServerPage().getSelectedServer());
  StringTokenizer st=new StringTokenizer("13C 1H");
  combo.removeAll();
  combo.add("   ");
  while (st.hasMoreTokens()) {
    combo.add(st.nextToken());
  }
  combo.setText(combo.getItem(0));
  dwPage=(DisplayWizardPage)(this.getWizard()).getNextPage(this);
}
 

Example 3

From project bndtools, under directory /bndtools.core/src/bndtools/editor/model/.

Source file: ServiceComponentAttribs.java

  19 
vote

private static List<String> parseList(String string){
  if (string == null)   return null;
  List<String> result=new ArrayList<String>();
  StringTokenizer tokenizer=new StringTokenizer(string,",");
  while (tokenizer.hasMoreTokens()) {
    result.add(tokenizer.nextToken().trim());
  }
  return result;
}
 

Example 4

From project Aardvark, under directory /aardvark-core/src/main/java/gw/vark/task/.

Source file: GosuInitTask.java

  18 
vote

private List<File> deriveClasspath(){
  AntClassLoader loader=(AntClassLoader)getClass().getClassLoader();
  String cpString=loader.getClasspath();
  StringTokenizer st=new StringTokenizer(cpString,File.pathSeparator);
  List<File> cp=new ArrayList<File>();
  while (st.hasMoreTokens()) {
    cp.add(new File(st.nextToken()));
  }
  return cp;
}
 

Example 5

From project activejdbc, under directory /javalite-common/src/main/java/org/javalite/common/.

Source file: Inflector.java

  18 
vote

/** 
 * Generates a camel case version of a phrase from underscore.
 * @param underscore underscore version of a word to converted to camel case.
 * @param capitalizeFirstChar set to true if first character needs to be capitalized, false if not.
 * @return camel case version of underscore.
 */
public static String camelize(String underscore,boolean capitalizeFirstChar){
  String result="";
  StringTokenizer st=new StringTokenizer(underscore,"_");
  while (st.hasMoreTokens()) {
    result+=capitalize(st.nextToken());
  }
  return capitalizeFirstChar ? result : result.substring(0,1).toLowerCase() + result.substring(1);
}
 

Example 6

From project addis, under directory /application/src/main/java/org/drugis/addis/util/.

Source file: PubMedListFormat.java

  18 
vote

@Override public Object parseObject(String source,ParsePosition pos){
  pos.setIndex(source.length() + 1);
  PubMedIdList list=new PubMedIdList();
  StringTokenizer tokenizer=new StringTokenizer(source,",");
  while (tokenizer.hasMoreTokens()) {
    validatePubMedID(tokenizer.nextToken(),list);
  }
  return list;
}
 

Example 7

From project Agot-Java, under directory /src/main/java/got/utility/.

Source file: PointFileReaderWriter.java

  18 
vote

private static void readSingle(final String aLine,final Map<String,Point> mapping) throws IOException {
  final StringTokenizer tokens=new StringTokenizer(aLine,"",false);
  final String name=tokens.nextToken("(").trim();
  if (mapping.containsKey(name))   throw new IOException("name found twice:" + name);
  final int x=Integer.parseInt(tokens.nextToken("(, "));
  final int y=Integer.parseInt(tokens.nextToken(",) "));
  final Point p=new Point(x,y);
  mapping.put(name,p);
}
 

Example 8

From project amber, under directory /oauth-2.0/common/src/main/java/org/apache/amber/oauth2/common/utils/.

Source file: OAuthUtils.java

  18 
vote

public static Set<String> decodeScopes(String s){
  Set<String> scopes=new HashSet<String>();
  if (!OAuthUtils.isEmpty(s)) {
    StringTokenizer tokenizer=new StringTokenizer(s," ");
    while (tokenizer.hasMoreElements()) {
      scopes.add(tokenizer.nextToken());
    }
  }
  return scopes;
}
 

Example 9

From project AmDroid, under directory /httpclientandroidlib/src/ch/boye/httpclientandroidlib/client/utils/.

Source file: Rfc3492Idn.java

  18 
vote

public String toUnicode(String punycode){
  StringBuilder unicode=new StringBuilder(punycode.length());
  StringTokenizer tok=new StringTokenizer(punycode,".");
  while (tok.hasMoreTokens()) {
    String t=tok.nextToken();
    if (unicode.length() > 0)     unicode.append('.');
    if (t.startsWith(ACE_PREFIX))     t=decode(t.substring(4));
    unicode.append(t);
  }
  return unicode.toString();
}
 

Example 10

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/server/.

Source file: MultipleServerPool.java

  18 
vote

public void init() throws InitialisationException {
  if (!StringUtil.isEmpty(this.poolNames)) {
    StringTokenizer tokenizer=new StringTokenizer(poolNames," ,	");
    ObjectPool[] objectPools=new ObjectPool[tokenizer.countTokens()];
    int index=0;
    while (tokenizer.hasMoreTokens()) {
      String poolName=tokenizer.nextToken().trim();
      objectPools[index++]=ProxyRuntimeContext.getInstance().getPoolMap().get(poolName);
    }
    this.setObjectPools(objectPools);
  }
}
 

Example 11

From project android-thaiime, under directory /latinime/tests/src/com/sugree/inputmethod/latin/.

Source file: UserBigramSuggestHelper.java

  18 
vote

public void addToUserBigram(String sentence){
  StringTokenizer st=new StringTokenizer(sentence);
  String previous=null;
  while (st.hasMoreTokens()) {
    String current=st.nextToken();
    if (previous != null) {
      addToUserBigram(new String[]{previous,current});
    }
    previous=current;
  }
}
 

Example 12

From project AndroidCommon, under directory /src/com/asksven/android/common/utils/.

Source file: StringUtils.java

  18 
vote

public static void splitLine(String line,ArrayList<String> outSplit){
  outSplit.clear();
  final StringTokenizer t=new StringTokenizer(line," \t\n\r\f:");
  while (t.hasMoreTokens()) {
    outSplit.add(t.nextToken());
  }
}
 

Example 13

From project AndroidLab, under directory /samples/AndroidLdapClient/src/com/unboundid/android/ldap/client/.

Source file: AddToContactsOnClickListener.java

  18 
vote

/** 
 * Adds the provided postal address to the contact.
 * @param address The postal address to add.
 * @param type The type of address to add.
 * @return a addPostalAdress Operation
 */
private ContentProviderOperation addPostalAddress(final String address,final int type){
  final StringBuilder addr=new StringBuilder();
  final StringTokenizer tokenizer=new StringTokenizer(address,"$");
  while (tokenizer.hasMoreTokens()) {
    addr.append(tokenizer.nextToken().trim());
    if (tokenizer.hasMoreTokens()) {
      addr.append(EOL);
    }
  }
  return ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI).withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID,0).withValue(ContactsContract.Data.MIMETYPE,ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE).withValue(ContactsContract.CommonDataKinds.StructuredPostal.TYPE,type).withValue(ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS,addr.toString()).build();
}
 

Example 14

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/data/.

Source file: Face.java

  18 
vote

public Face(String name,String personId,String rect){
  mName=name;
  mPersonId=personId;
  Utils.assertTrue(mName != null && mPersonId != null && rect != null);
  StringTokenizer tokenizer=new StringTokenizer(rect);
  mPosition=new Rect();
  while (tokenizer.hasMoreElements()) {
    mPosition.left=Integer.parseInt(tokenizer.nextToken());
    mPosition.top=Integer.parseInt(tokenizer.nextToken());
    mPosition.right=Integer.parseInt(tokenizer.nextToken());
    mPosition.bottom=Integer.parseInt(tokenizer.nextToken());
  }
}
 

Example 15

From project android_packages_inputmethods_LatinIME, under directory /tests/src/com/android/inputmethod/latin/.

Source file: UserBigramSuggestHelper.java

  18 
vote

public void addToUserBigram(String sentence){
  StringTokenizer st=new StringTokenizer(sentence);
  String previous=null;
  while (st.hasMoreTokens()) {
    String current=st.nextToken();
    if (previous != null) {
      addToUserBigram(new String[]{previous,current});
    }
    previous=current;
  }
}
 

Example 16

From project ant4eclipse, under directory /org.ant4eclipse.ant.jdt/src/org/ant4eclipse/ant/jdt/.

Source file: JdtProjectFileSet.java

  18 
vote

/** 
 * Adds <code>includes</code> to the current list of include patterns. Patterns may be separated by a comma or a space.
 * @param includes the string containing the include patterns
 */
public void setIncludes(String includes){
  if (isReference()) {
    throw tooManyAttributes();
  }
  if (Utilities.hasText(includes)) {
    StringTokenizer stringTokenizer=new StringTokenizer(includes," ,",false);
    while (stringTokenizer.hasMoreElements()) {
      String include=stringTokenizer.nextToken();
      createInclude().setName(include);
    }
  }
}
 

Example 17

From project any23, under directory /core/src/main/java/org/apache/any23/extractor/csv/.

Source file: CSVExtractor.java

  18 
vote

private URI normalize(String toBeNormalized,URI documentURI){
  toBeNormalized=toBeNormalized.trim().toLowerCase().replace("?","").replace("&","");
  StringBuilder result=new StringBuilder(documentURI.toString());
  StringTokenizer tokenizer=new StringTokenizer(toBeNormalized," ");
  while (tokenizer.hasMoreTokens()) {
    String current=tokenizer.nextToken();
    result.append(toUpperCase(current.charAt(0))).append(current.substring(1));
  }
  return new URIImpl(result.toString());
}
 

Example 18

From project apb, under directory /modules/apb-base/src/apb/idegen/.

Source file: IdeaTask.java

  18 
vote

private static void setWildcardResourcePatterns(@NotNull Element content,@NotNull String patterns){
  Element compilerConfig=findComponent(content,"CompilerConfiguration");
  if (patterns.isEmpty()) {
    removeOldElements(compilerConfig,WILDCARD_RESOURCE_PATTERNS);
    Element wildcardPatterns=createElement(compilerConfig,WILDCARD_RESOURCE_PATTERNS);
    StringTokenizer tokenizer=new StringTokenizer(patterns,";");
    while (tokenizer.hasMoreTokens()) {
      String wildcardPattern=tokenizer.nextToken();
      Element entryElement=createElement(wildcardPatterns,"entry");
      entryElement.setAttribute("name",wildcardPattern);
    }
  }
}
 

Example 19

From project arquillian-extension-android, under directory /android-impl/src/main/java/org/jboss/arquillian/android/impl/.

Source file: EmulatorStartup.java

  18 
vote

private List<String> getEmulatorOptions(List<String> properties,String valueString){
  if (valueString == null) {
    return properties;
  }
  StringTokenizer tokenizer=new StringTokenizer(valueString," ");
  while (tokenizer.hasMoreTokens()) {
    String property=tokenizer.nextToken().trim();
    properties.add(property);
  }
  return properties;
}
 

Example 20

From project arquillian-extension-drone, under directory /drone-selenium-server/src/main/java/org/jboss/arquillian/drone/selenium/server/impl/.

Source file: SystemEnvHolder.java

  18 
vote

private List<String> getSystemProperties(String valueString){
  List<String> properties=new ArrayList<String>();
  StringTokenizer tokenizer=new StringTokenizer(valueString," ");
  while (tokenizer.hasMoreTokens()) {
    String property=tokenizer.nextToken().trim();
    if (property.indexOf('=') == -1) {
      continue;
    }
    properties.add(property);
  }
  return properties;
}
 

Example 21

From project avro, under directory /lang/java/mapred/src/main/java/org/apache/avro/mapred/.

Source file: AvroMultipleOutputs.java

  18 
vote

/** 
 * Returns list of channel names.
 * @param conf job conf
 * @return List of channel Names
 */
public static List<String> getNamedOutputsList(JobConf conf){
  List<String> names=new ArrayList<String>();
  StringTokenizer st=new StringTokenizer(conf.get(NAMED_OUTPUTS,"")," ");
  while (st.hasMoreTokens()) {
    names.add(st.nextToken());
  }
  return names;
}
 

Example 22

From project azkaban, under directory /test/src/java/azkaban/test/.

Source file: WordCountGrid.java

  18 
vote

public void map(LongWritable key,Text value,OutputCollector<Text,IntWritable> output,Reporter reporter) throws IOException {
  String line=value.toString();
  StringTokenizer tokenizer=new StringTokenizer(line);
  while (tokenizer.hasMoreTokens()) {
    word.set(tokenizer.nextToken());
    if (word.toString().equals("end_here")) {
      String[] errArray=new String[1];
      System.out.println("string in possition 2 is " + errArray[1]);
    }
    output.collect(word,one);
  }
}
 

Example 23

From project b1-pack, under directory /standard/src/main/java/org/b1/pack/standard/writer/.

Source file: CompressedFormatDetector.java

  18 
vote

private static void readResource(final URL url,ImmutableSet.Builder<String> builder) throws IOException {
  StringTokenizer tokenizer=new StringTokenizer(CharStreams.toString(new InputSupplier<Reader>(){
    @Override public Reader getInput() throws IOException {
      return new InputStreamReader(url.openStream(),Charsets.UTF_8);
    }
  }
));
  while (tokenizer.hasMoreTokens()) {
    builder.add(tokenizer.nextToken().toLowerCase());
  }
}
 

Example 24

From project bel-editor, under directory /org.openbel.editor.ui/src/org/openbel/editor/ui/launch/.

Source file: LaunchDelegate.java

  18 
vote

/** 
 * Returns the tokens after tokenizing the string by the  {@code ;}delimiter.
 * @param string {@link String}
 * @return {@code String[]}
 */
public static String[] tokenize(String string){
  List<String> ret=new ArrayList<String>();
  StringTokenizer toker=new StringTokenizer(string,";");
  while (toker.hasMoreTokens()) {
    ret.add(toker.nextToken());
  }
  return ret.toArray(new String[0]);
}
 

Example 25

From project big-data-plugin, under directory /samples/jobs/hadoop/pentaho-mapreduce-sample-src/org/pentaho/hadoop/sample/wordcount/.

Source file: WordCountMapper.java

  18 
vote

public void map(Object key,Text value,OutputCollector<Text,IntWritable> output,Reporter reporter) throws IOException {
  StringTokenizer wordList=new StringTokenizer(value.toString());
  while (wordList.hasMoreTokens()) {
    this.word.set(wordList.nextToken());
    output.collect(this.word,ONE);
  }
}
 

Example 26

From project bioclipse.opentox, under directory /plugins/net.bioclipse.opentox.ds/src/net/bioclipse/opentox/ds/prefs/.

Source file: OpenToxModelsPrefsPage.java

  18 
vote

public static String[] parsePreferenceString(String stringList){
  StringTokenizer st=new StringTokenizer(stringList,OpenToxConstants.PREFS_SEPERATOR);
  List<String> v=new ArrayList<String>();
  while (st.hasMoreElements()) {
    v.add((String)st.nextElement());
  }
  return (String[])v.toArray(new String[v.size()]);
}
 

Example 27

From project bpelunit, under directory /net.bpelunit.framework/src/main/java/net/bpelunit/framework/control/datasource/.

Source file: VelocityDataSource.java

  18 
vote

/** 
 * Space-separated list of one or more variables which will be iterated over each row. These variables must all be lists with the same number of elements. The initialized context for the n-th row will have their n-th elements in variables with the same names as the lists. The rest of the variables will be available as-is. For instance, suppose we had these contents and this property was set to "v w": <code> #set($v = [1, 2, 3]) #set($w = [2, 4, 6]) #set($z = 3) </code> This data source would have 3 rows: the first would have v = 1 and w = 2, the second would have v = 2 and w = 4, and the last one would have v = 3 and w = 6. All three rows would have z = 3. <emph>This property is required</emph>.
 */
@ConfigurationOption(description="The names of the variables that should be used as test data. The list is space separated.",defaultValue="") public void setIteratedVars(String value) throws DataSourceException {
  StringTokenizer tok=new StringTokenizer(value);
  List<String> iterVars=new ArrayList<String>();
  while (tok.hasMoreTokens()) {
    iterVars.add(tok.nextToken());
  }
  if (iterVars.isEmpty()) {
    throw new DataSourceException("Iterated variable list cannot be empty");
  }
  fIteratedVars=iterVars;
}
 

Example 28

From project Briss, under directory /src/main/java/at/laborg/briss/utils/.

Source file: PageNumberParser.java

  18 
vote

/** 
 * Super simple page-number parser. It handles entries like: "1-2;34;3-16"
 * @param input String to be parsed.
 * @return
 * @throws ParseException
 */
public static Set<Integer> parsePageNumber(String input) throws ParseException {
  Pattern p=Pattern.compile("[^0-9-;]");
  Matcher m=p.matcher(input);
  if (m.find())   throw new ParseException("Allowed characters: \"0-9\" \";\" \"-\" ",0);
  StringTokenizer tokenizer=new StringTokenizer(input,";");
  Set<Integer> pNS=new HashSet<Integer>();
  while (tokenizer.hasMoreElements()) {
    pNS.addAll(extractPageNumbers(tokenizer.nextToken()));
  }
  return pNS;
}
 

Example 29

From project buzzwords, under directory /src/com/buzzwords/.

Source file: Card.java

  18 
vote

/** 
 * Function for breaking a string into an array list of strings based on the presence of commas. The bad words are stored in the database as a comma separated list for each card.
 * @param commaSeparated - a comma separated string
 * @return an array list of the substrings
 */
public static ArrayList<String> bustString(String commaSeparated){
  if (BuzzWordsApplication.DEBUG) {
    Log.d(TAG,"BustString()");
  }
  ArrayList<String> ret=new ArrayList<String>();
  StringTokenizer tok=new StringTokenizer(commaSeparated);
  while (tok.hasMoreTokens()) {
    ret.add(tok.nextToken(",").toUpperCase());
  }
  return ret;
}
 

Example 30

From project CalendarView_1, under directory /src/org/kazzz/util/.

Source file: StrUtil.java

  18 
vote

/** 
 * ???????????????????????????????
 * @param className ?????????????????????
 * @return String ?????????????
 */
public static final String getPackageName(String className){
  StringTokenizer tokennizer=new StringTokenizer(className,".");
  StringBuilder result=new StringBuilder();
  int tokenCount=tokennizer.countTokens();
  if (tokennizer.hasMoreTokens()) {
    result.append(tokennizer.nextToken());
  }
  for (int i=0; i < tokenCount - 2; i++) {
    result.append(".").append(tokennizer.nextToken());
  }
  return result.toString().trim();
}
 

Example 31

From project capedwarf-blue, under directory /images/src/main/java/org/jboss/capedwarf/images/.

Source file: ImageRequest.java

  18 
vote

public ImageRequest(String pathInfo){
  StringTokenizer tokenizer=new StringTokenizer(pathInfo,"/");
  blobKey=new BlobKey(tokenizer.nextToken());
  if (tokenizer.hasMoreTokens()) {
    parseSizeAndCrop(tokenizer.nextToken());
  }
}
 

Example 32

From project caseconductor-platform, under directory /utest-domain-services/src/main/java/com/utest/domain/service/impl/.

Source file: TestCaseServiceImpl.java

  18 
vote

private void loadTestCaseAssociations(Map<String,Set<Integer>> associationsMap_,String tokenizedAssociations_,String delimiter_,Integer testCaseVersionId_){
  String token;
  StringTokenizer st=new StringTokenizer(tokenizedAssociations_,delimiter_);
  while (st.hasMoreTokens()) {
    token=st.nextToken();
    if (!associationsMap_.containsKey(token)) {
      associationsMap_.put(token,new HashSet<Integer>());
    }
    associationsMap_.get(token).add(testCaseVersionId_);
  }
}
 

Example 33

From project cb2java, under directory /src/main/java/net/sf/cb2java/copybook/.

Source file: CopybookAnalyzer.java

  18 
vote

private String removeChars(String s,String charToRemove){
  StringTokenizer st=new StringTokenizer(s,charToRemove,false);
  StringBuffer b=new StringBuffer();
  while (st.hasMoreElements()) {
    b.append(st.nextElement());
  }
  return b.toString();
}
 

Example 34

From project cdh-maven-archetype, under directory /hbase-driver/src/main/java/com/cloudera/hbase/.

Source file: OldWordCount.java

  18 
vote

public void map(LongWritable key,Text value,OutputCollector<Text,IntWritable> output,Reporter reporter) throws IOException {
  String line=value.toString();
  StringTokenizer tokenizer=new StringTokenizer(line);
  while (tokenizer.hasMoreTokens()) {
    word.set(tokenizer.nextToken());
    output.collect(word,one);
  }
}
 

Example 35

From project ceres, under directory /ceres-binding/src/main/java/com/bc/ceres/binding/converters/.

Source file: ArrayConverter.java

  18 
vote

@Override public Object parse(String text) throws ConversionException {
  if (text.isEmpty()) {
    return null;
  }
  StringTokenizer st=new StringTokenizer(text,SEPARATOR);
  int length=st.countTokens();
  Object array=Array.newInstance(arrayType.getComponentType(),length);
  for (int i=0; i < length; i++) {
    Object component=componentConverter.parse(st.nextToken().replace(SEPARATOR_ESC,SEPARATOR));
    Array.set(array,i,component);
  }
  return array;
}
 

Example 36

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/quickfix/.

Source file: ChangeCorrectionProposal.java

  18 
vote

public static StyledString style(String name){
  StyledString result=new StyledString();
  StringTokenizer tokens=new StringTokenizer(name,"'",false);
  result.append(tokens.nextToken());
  while (tokens.hasMoreTokens()) {
    result.append('\'');
    CompletionProposal.style(result,tokens.nextToken());
    result.append('\'');
    if (tokens.hasMoreTokens()) {
      result.append(tokens.nextToken());
    }
  }
  return result;
}
 

Example 37

From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/analysis/salsa/fsm/.

Source file: ParseUtilities.java

  18 
vote

public static FSMIntermedEntry splitChukwaRecordKey(String origkey,FSMIntermedEntry rec,String delim) throws Exception {
  StringTokenizer st=new StringTokenizer(origkey,delim);
  if (st.countTokens() != 3) {
    throw new Exception("Expected 3 tokens from ChukwaRecordKey but only found " + st.countTokens() + ".");
  }
  rec.time_orig_epoch=new String(st.nextToken());
  rec.job_id=new String(st.nextToken());
  rec.time_orig=new String(st.nextToken());
  return rec;
}
 

Example 38

From project cider, under directory /src/net/yacy/cider/util/.

Source file: FileUtils.java

  18 
vote

public static Set<String> loadSet(final File file,final String sep,final boolean tree) throws IOException {
  final Set<String> set=(tree) ? (Set<String>)new TreeSet<String>() : (Set<String>)new HashSet<String>();
  final byte[] b=read(file);
  final StringTokenizer st=new StringTokenizer(new String(b,"UTF-8"),sep);
  while (st.hasMoreTokens()) {
    set.add(st.nextToken());
  }
  return set;
}
 

Example 39

From project Cilia_1, under directory /framework/core/src/main/java/fr/liglab/adele/cilia/builder/impl/.

Source file: BinderImpl.java

  18 
vote

private String[] split(String toSplit,String separator){
  StringTokenizer tokenizer=new StringTokenizer(toSplit,separator);
  String[] result=new String[tokenizer.countTokens()];
  int index=0;
  while (tokenizer.hasMoreElements()) {
    result[index]=tokenizer.nextToken().trim();
    index++;
  }
  return result;
}
 

Example 40

From project CIShell, under directory /core/org.cishell.utilities/src/org/cishell/utilities/.

Source file: StringUtilities.java

  18 
vote

public static String[] tokenizeByWhitespace(String originalString){
  StringTokenizer tokenizer=new StringTokenizer(originalString);
  int tokenCount=tokenizer.countTokens();
  String[] tokens=new String[tokenCount];
  for (int ii=0; ii < tokenCount; ii++) {
    tokens[ii]=tokenizer.nextToken();
  }
  return tokens;
}
 

Example 41

From project Cloud9, under directory /src/dist/edu/umd/cloud9/example/bigram/.

Source file: BigramCount.java

  18 
vote

@Override public void map(LongWritable key,Text value,Context context) throws IOException, InterruptedException {
  String line=value.toString();
  String prev=null;
  StringTokenizer itr=new StringTokenizer(line);
  while (itr.hasMoreTokens()) {
    String cur=itr.nextToken();
    if (prev != null) {
      bigram.set(prev + " " + cur);
      context.write(bigram,one);
    }
    prev=cur;
  }
}
 

Example 42

From project cloudhopper-commons-util, under directory /src/main/java/com/cloudhopper/commons/util/.

Source file: StringUtil.java

  18 
vote

/** 
 * Splits a string around matches of the given delimiter character. Where applicable, this method can be used as a substitute for <code>String.split(String regex)</code>, which is not available on a JSR169/Java ME platform.
 * @param str the string to be split
 * @param delim the delimiter
 * @throws NullPointerException if str is null
 */
static public String[] split(String str,char delim){
  if (str == null) {
    throw new NullPointerException("str can't be null");
  }
  StringTokenizer st=new StringTokenizer(str,String.valueOf(delim));
  int n=st.countTokens();
  String[] s=new String[n];
  for (int i=0; i < n; i++) {
    s[i]=st.nextToken();
  }
  return s;
}
 

Example 43

From project codjo-data-process, under directory /codjo-data-process-common/src/main/java/net/codjo/dataprocess/common/model/.

Source file: TreatmentModel.java

  18 
vote

private static List<String> stringToList(String parameters){
  List<String> parametersList=new ArrayList<String>();
  StringTokenizer stringTokenizer=new StringTokenizer(parameters,",");
  while (stringTokenizer.hasMoreTokens()) {
    String token=stringTokenizer.nextToken().trim();
    parametersList.add(token);
  }
  return parametersList;
}
 

Example 44

From project codjo-segmentation, under directory /codjo-segmentation-gui/src/main/java/net/codjo/segmentation/gui/importParam/agent/.

Source file: ImportInitiatorAgent.java

  18 
vote

private void initializeQuarantine(String quarantineMessage){
  StringTokenizer lineTokenizer=new StringTokenizer(quarantineMessage,"\n");
  int numberOfRows=lineTokenizer.countTokens();
  for (int rowIndex=0; rowIndex < numberOfRows; rowIndex++) {
    StringTokenizer columnTokenizer=new StringTokenizer(lineTokenizer.nextToken(),"\t");
    int numberOfColumns=columnTokenizer.countTokens();
    for (int colIndex=0; colIndex < numberOfColumns; colIndex++) {
      if (quarantine == null) {
        quarantine=new String[numberOfRows][numberOfColumns];
      }
      quarantine[rowIndex][colIndex]=columnTokenizer.nextToken();
    }
  }
}
 

Example 45

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaModelWizard.java

  17 
vote

/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected Collection<String> getEncodings(){
  if (encodings == null) {
    encodings=new ArrayList<String>();
    for (StringTokenizer stringTokenizer=new StringTokenizer(ScalaEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) {
      encodings.add(stringTokenizer.nextToken());
    }
  }
  return encodings;
}
 

Example 46

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.webapp.editor/src-gen/org/eclipse/acceleo/tutorial/webapp/presentation/.

Source file: WebappModelWizard.java

  17 
vote

/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected Collection<String> getEncodings(){
  if (encodings == null) {
    encodings=new ArrayList<String>();
    for (StringTokenizer stringTokenizer=new StringTokenizer(WebappEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) {
      encodings.add(stringTokenizer.nextToken());
    }
  }
  return encodings;
}
 

Example 47

From project AdminStuff, under directory /src/main/java/de/minestar/AdminStuff/commands/.

Source file: cmdTempBan.java

  17 
vote

private int[] parseString(String date,CommandSender sender){
  int[] result=new int[3];
  try {
    StringTokenizer st=new StringTokenizer(date,"[d,h,m]",true);
    int i=0;
    char c=0;
    while (st.hasMoreTokens()) {
      i=Integer.parseInt(st.nextToken());
      c=st.nextToken().charAt(0);
      fillDates(result,c,i);
    }
  }
 catch (  Exception e) {
    ChatUtils.writeError(sender,pluginName,"Falsche Syntax! Beispiele: ");
    showExamples(sender);
    return null;
  }
  if (result[0] < 1 && result[1] < 1 && result[2] < 1) {
    ChatUtils.writeError(sender,pluginName,Arrays.toString(result) + "sind ungueltige Eingabe! Eine Zahl muss wenigstens positiv ungleich null sein!");
    showExamples(sender);
    return null;
  }
  return result;
}
 

Example 48

From project AdServing, under directory /modules/db/src/main/java/net/mad/ads/db/utils/.

Source file: ValidateIP.java

  17 
vote

/** 
 * A.B.C.D ip = ((A*256+B)*256+C)*256 + D
 * @param ip
 * @return
 */
private static String INET_ATON(String ip){
  if (!validate(ip)) {
    return null;
  }
  String result=null;
  int[] ipns=new int[4];
  StringTokenizer tokens=new StringTokenizer(ip,".");
  int i=0;
  while (tokens.hasMoreTokens()) {
    String token=tokens.nextToken();
    ipns[i]=Integer.valueOf(token);
    i++;
  }
  result=String.valueOf((((ipns[0] * 256 + ipns[1]) * 256 + ipns[2]) * 256 + ipns[3]));
  return result;
}
 

Example 49

From project aether-core, under directory /aether-test-util/src/main/java/org/eclipse/aether/internal/test/util/connector/.

Source file: TestConnectorPathUtils.java

  17 
vote

private static String[] split(final String str,final String separator,final int max){
  final StringTokenizer tok;
  if (separator == null) {
    tok=new StringTokenizer(str);
  }
 else {
    tok=new StringTokenizer(str,separator);
  }
  int listSize=tok.countTokens();
  if (max > 0 && listSize > max) {
    listSize=max;
  }
  final String[] list=new String[listSize];
  int i=0;
  int lastTokenBegin;
  int lastTokenEnd=0;
  while (tok.hasMoreTokens()) {
    if (max > 0 && i == listSize - 1) {
      final String endToken=tok.nextToken();
      lastTokenBegin=str.indexOf(endToken,lastTokenEnd);
      list[i]=str.substring(lastTokenBegin);
      break;
    }
 else {
      list[i]=tok.nextToken();
      lastTokenBegin=str.indexOf(list[i],lastTokenEnd);
      lastTokenEnd=lastTokenBegin + list[i].length();
    }
    i++;
  }
  return list;
}
 

Example 50

From project agile, under directory /agile-apps/agile-app-files/src/main/java/org/headsupdev/agile/app/files/.

Source file: ScmCommentParser.java

  17 
vote

public static void parseComment(String comment,ChangeSet set){
  if (comment == null) {
    return;
  }
  StringTokenizer tokenizer=new StringTokenizer(comment," \t\n\r\f<>(){}&.,!?;",true);
  Map<String,LinkProvider> providers=Manager.getInstance().getLinkProviders();
  String previous="";
  while (tokenizer.hasMoreTokens()) {
    String next=tokenizer.nextToken();
    if (next.indexOf(':') != -1) {
      parseLink(next,previous,set,providers);
    }
    previous=next;
  }
}
 

Example 51

From project alfredo, under directory /alfredo/src/main/java/com/cloudera/alfredo/server/.

Source file: AuthenticationToken.java

  17 
vote

/** 
 * Splits the string representation of a token into attributes pairs.
 * @param tokenStr string representation of a token.
 * @return a map with the attribute pairs of the token.
 * @throws AuthenticationException thrown if the string representation of the token could not be broken intoattribute pairs.
 */
private static Map<String,String> split(String tokenStr) throws AuthenticationException {
  Map<String,String> map=new HashMap<String,String>();
  StringTokenizer st=new StringTokenizer(tokenStr,ATTR_SEPARATOR);
  while (st.hasMoreTokens()) {
    String part=st.nextToken();
    int separator=part.indexOf('=');
    if (separator == -1) {
      throw new AuthenticationException("Invalid authentication token");
    }
    String key=part.substring(0,separator);
    String value=part.substring(separator + 1);
    map.put(key,value);
  }
  return map;
}
 

Example 52

From project andlytics, under directory /src/com/github/andlyticsproject/.

Source file: DeveloperConsole.java

  17 
vote

public String login(String email,String password){
  Map<String,String> params=new LinkedHashMap<String,String>();
  params.put("Email",email);
  params.put("Passwd",password);
  params.put("service",SERVICE);
  params.put("accountType",ACCOUNT_TYPE);
  String authKey=null;
  try {
    String data=postUrl(URL_GOOGLE_LOGIN,params);
    StringTokenizer st=new StringTokenizer(data,"\n\r=");
    while (st.hasMoreTokens()) {
      if (st.nextToken().equalsIgnoreCase("Auth")) {
        authKey=st.nextToken();
        break;
      }
    }
    if (authKey == null)     throw new RuntimeException("authKey not found in " + data);
  }
 catch (  IOException ex) {
    throw new RuntimeException(ex);
  }
  return authKey;
}
 

Example 53

From project android_8, under directory /src/com/google/gson/.

Source file: DefaultTypeAdapters.java

  17 
vote

@Override public Locale deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context) throws JsonParseException {
  String locale=json.getAsString();
  StringTokenizer tokenizer=new StringTokenizer(locale,"_");
  String language=null;
  String country=null;
  String variant=null;
  if (tokenizer.hasMoreElements()) {
    language=tokenizer.nextToken();
  }
  if (tokenizer.hasMoreElements()) {
    country=tokenizer.nextToken();
  }
  if (tokenizer.hasMoreElements()) {
    variant=tokenizer.nextToken();
  }
  if (country == null && variant == null) {
    return new Locale(language);
  }
 else   if (variant == null) {
    return new Locale(language,country);
  }
 else {
    return new Locale(language,country,variant);
  }
}
 

Example 54

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: TextToSpeechSettings.java

  17 
vote

private void parseLocaleInfo(String locale){
  StringTokenizer tokenizer=new StringTokenizer(locale,LOCALE_DELIMITER);
  mDefaultLanguage="";
  mDefaultCountry="";
  mDefaultLocVariant="";
  if (tokenizer.hasMoreTokens()) {
    mDefaultLanguage=tokenizer.nextToken().trim();
  }
  if (tokenizer.hasMoreTokens()) {
    mDefaultCountry=tokenizer.nextToken().trim();
  }
  if (tokenizer.hasMoreTokens()) {
    mDefaultLocVariant=tokenizer.nextToken().trim();
  }
}
 

Example 55

From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/keyboards/.

Source file: Keyboard.java

  17 
vote

int[] parseCSV(String value){
  int count=0;
  int lastIndex=0;
  if (value.length() > 0) {
    count++;
    while ((lastIndex=value.indexOf(",",lastIndex + 1)) > 0) {
      count++;
    }
  }
  int[] values=new int[count];
  count=0;
  StringTokenizer st=new StringTokenizer(value,",");
  while (st.hasMoreTokens()) {
    String nextToken=st.nextToken();
    try {
      if (nextToken.length() != 1) {
        values[count++]=Integer.parseInt(nextToken);
      }
 else {
        values[count++]=(int)nextToken.charAt(0);
      }
    }
 catch (    NumberFormatException nfe) {
      Log.e(TAG,"Error parsing keycodes " + value);
    }
  }
  return values;
}
 

Example 56

From project apollo, under directory /injector/src/main/java/com/bskyb/cg/environments/message/.

Source file: AuditdMessageFormat.java

  17 
vote

@Override public Message parse(byte[] inMessage) throws ParseException {
  Message message=new LogMessage();
  String textMessage=new String(inMessage);
  StringTokenizer st=new StringTokenizer(textMessage,delimiter);
  String msgType=(String)st.nextElement();
  String timeStamp=(String)st.nextElement();
  DateTime longDate=null;
  try {
    longDate=parseDate(timeStamp);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (longDate == null) {
    return message;
  }
  String year=new Integer(longDate.getYear()).toString();
  String month=String.format("%02d",new Integer(longDate.getMonthOfYear()));
  String day=String.format("%02d",new Integer(longDate.getDayOfMonth()));
  String hostName=(String)st.nextElement();
  long epochTime=longDate.getMillis();
  UUID uuid=TimeUUIDUtils.getTimeUUID(epochTime);
  String filename=year + "-" + month+ "-"+ day+ "_"+ hostName+ "_"+ msgType+ "_"+ uuid.toString()+ "_"+ new Long(epochTime).toString();
  String messageText=(String)st.nextElement();
  message.setKey(filename);
  message.setMessage(messageText.getBytes());
  return message;
}
 

Example 57

From project ARCInputFormat, under directory /src/org/commoncrawl/util/shared/.

Source file: ArcFileReader.java

  17 
vote

/** 
 * process the metadata line of an ARC File Entry 
 */
private final void processMetadataLine(String metadata) throws IOException {
  StringTokenizer tokenizer=new StringTokenizer(metadata," ");
  int tokenCount=0;
  while (tokenizer.hasMoreElements() && tokenCount <= 5) {
switch (++tokenCount) {
case 1:
{
        _item.setUri(tokenizer.nextToken());
      }
    break;
case 2:
{
    _item.setHostIP(tokenizer.nextToken());
  }
break;
case 3:
{
String timeStamp=tokenizer.nextToken();
try {
  _item.setTimestamp(TIMESTAMP14.parse(timeStamp).getTime());
}
 catch (ParseException e) {
  LOG.error("Invalid Timestamp Encountered in Item Metdata. URL:" + _item.getUri() + " Timestamp:"+ timeStamp+ " Metadata:"+ metadata);
  _item.setTimestamp(0);
}
}
break;
case 4:
{
_item.setMimeType(tokenizer.nextToken());
}
break;
case 5:
{
_item.setRecordLength(Integer.parseInt(tokenizer.nextToken()));
}
break;
}
}
}
 

Example 58

From project Arecibo, under directory /agent/src/main/java/com/ning/arecibo/agent/config/.

Source file: Config.java

  17 
vote

public Config(String eventType,String eventAttributeType,List<MonitoringType> monitoringTypes,TimeSpan pollingInterval,String host,String fullConfigPath,String deployedType) throws ConfigException {
  if (eventType == null || eventAttributeType == null)   throw new ConfigException("eventType and eventAttributeType cannot be null");
  this.host=host;
  this.eventType=eventType;
  this.eventAttributeType=eventAttributeType;
  this.deployedType=deployedType;
  this.pollingInterval=pollingInterval;
  if (fullConfigPath == null)   fullConfigPath="";
  StringTokenizer st=new StringTokenizer(fullConfigPath,"/");
  if (st.hasMoreTokens()) {
    this.deployedEnv=st.nextToken();
  }
 else {
    this.deployedEnv=null;
  }
  if (st.hasMoreTokens()) {
    this.deployedVersion=st.nextToken();
  }
 else {
    this.deployedVersion=null;
  }
  if (st.hasMoreTokens())   st.nextToken();
  String configSubPath=null;
  while (st.hasMoreTokens()) {
    if (configSubPath == null) {
      configSubPath=st.nextToken();
    }
 else {
      configSubPath+="_" + st.nextToken();
    }
  }
  if (configSubPath == null)   configSubPath="unspecified";
  this.deployedConfigSubPath=configSubPath;
  if (monitoringTypes == null) {
    monitoringTypes=new ArrayList<MonitoringType>();
    monitoringTypes.add(MonitoringType.VALUE);
  }
  this.monitoringTypes=monitoringTypes;
  this.monitoringTypesString=this.getMonitoringTypesString();
}
 

Example 59

From project AuthDB, under directory /src/main/java/com/authdb/util/.

Source file: Util.java

  17 
vote

public static String forumCacheValue(String cache,String value){
  StringTokenizer st=new StringTokenizer(cache,":");
  int i=0;
  List<String> array=new ArrayList<String>();
  while (st.hasMoreTokens()) {
    array.add(st.nextToken() + ":");
  }
  while (array.size() > i) {
    if (array.get(i).equals("\"" + value + "\";s:") && value != null) {
      String temp=array.get(i + 2);
      temp=removeChar(temp,'"');
      temp=removeChar(temp,':');
      temp=removeChar(temp,'s');
      temp=removeChar(temp,';');
      temp=temp.trim();
      return temp;
    }
    i++;
  }
  return "no";
}
 

Example 60

From project autopatch, under directory /src/main/java/com/tacitknowledge/util/migration/jdbc/loader/.

Source file: DelimitedFileLoader.java

  17 
vote

/** 
 * Parses a line of data, and sets the prepared statement with the values.  If a token contains "&lt;null&gt;" then a null value is passed in.
 * @param data the tokenized string that is mapped to a row
 * @param stmt the statement to populate with data to be inserted
 * @return false if the header is returned, true otherwise
 * @throws SQLException if an error occurs while inserting data into the database
 */
protected boolean insert(String data,PreparedStatement stmt) throws SQLException {
  if (!parsedHeader) {
    parsedHeader=true;
    log.info("Header returned: " + data);
    return false;
  }
  StringTokenizer st=new StringTokenizer(data,getDelimiter());
  int counter=1;
  log.info("Row being parsed: " + data);
  while (st.hasMoreTokens()) {
    String colVal=st.nextToken();
    if (colVal.equalsIgnoreCase("<null>")) {
      stmt.setString(counter,null);
    }
 else {
      stmt.setString(counter,colVal);
    }
    counter++;
  }
  return true;
}
 

Example 61

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/coreutils/.

Source file: StringExtract.java

  17 
vote

/** 
 * Initialization, loads unicode tables
 * @return true if initialized properly, false otherwise
 */
private boolean init(){
  Properties properties=new Properties();
  try {
    InputStream inputStream=StringExtract.class.getResourceAsStream(PROPERTY_FILE);
    properties.load(inputStream);
    String table=properties.getProperty("UnicodeTable");
    StringTokenizer st=new StringTokenizer(table," ");
    int toks=st.countTokens();
    if (toks != UNICODE_TABLE_SIZE) {
      logger.log(Level.WARNING,"Unicode table corrupt, expecting: " + UNICODE_TABLE_SIZE,", have: " + toks);
      return false;
    }
    int tableIndex=0;
    while (st.hasMoreTokens()) {
      String tok=st.nextToken();
      char code=(char)Integer.parseInt(tok);
      unicodeTable[tableIndex++]=code;
    }
    logger.log(Level.INFO,"initialized, unicode table loaded");
  }
 catch (  IOException ex) {
    logger.log(Level.WARNING,"Could not load" + PROPERTY_FILE);
    return false;
  }
  return true;
}
 

Example 62

From project b3log-latke, under directory /latke/src/main/java/org/b3log/latke/util/.

Source file: AntPathMatcher.java

  17 
vote

/** 
 * Tokenize the given String into a String array via a StringTokenizer. <p>The given delimiters string is supposed to consist of any number of delimiter characters. Each of those characters can be used to separate tokens. A delimiter is always a single character; for multi-character delimiters, consider using <code>delimitedListToStringArray</code>
 * @param str the String to tokenize
 * @param delimiters the delimiter characters, assembled as String(each of those characters is individually considered as delimiter)
 * @param trimTokens trim the tokens via String's <code>trim</code>
 * @param ignoreEmptyTokens omit empty tokens from the result array(only applies to tokens that are empty after trimming; StringTokenizer will not consider subsequent delimiters as token in the first place).
 * @return an array of the tokens (<code>null</code> if the input Stringwas <code>null</code>)
 * @see java.util.StringTokenizer
 * @see java.lang.String#trim()
 * @see #delimitedListToStringArray
 */
private static String[] tokenizeToStringArray(String str,String delimiters){
  if (str == null) {
    return null;
  }
  StringTokenizer st=new StringTokenizer(str,delimiters);
  List tokens=new ArrayList();
  while (st.hasMoreTokens()) {
    String token=st.nextToken();
    token=token.trim();
    if (token.length() > 0) {
      tokens.add(token);
    }
  }
  return toStringArray(tokens);
}
 

Example 63

From project babel, under directory /src/babel/content/eqclasses/.

Source file: PrefixEquivalenceClass.java

  17 
vote

public void unpersistFromString(String str) throws Exception {
  String[] toks=str.split("\t");
  m_id=Long.parseLong(toks[0]);
  m_initialized=Boolean.parseBoolean(toks[1]);
  m_caseSensitive=Boolean.parseBoolean(toks[2]);
  m_allWords.clear();
  m_endings.clear();
  m_properties.clear();
  StringTokenizer tokenizer=new StringTokenizer(toks[3],"{} ,");
  m_prefix=tokenizer.nextToken();
  boolean addedEndings=false;
  while (tokenizer.hasMoreTokens()) {
    m_endings.add(tokenizer.nextToken().substring(1));
    addedEndings=true;
  }
  if (!addedEndings) {
    m_endings.add("");
  }
}
 

Example 64

From project beam-meris-icol, under directory /src/main/java/org/esa/beam/meris/icol/.

Source file: KernelOffNadir.java

  17 
vote

private void readKernelMatrixRayleighOld() throws IOException {
  BufferedReader bufferedReader;
  InputStream inputStream;
  inputStream=CoeffW.class.getResourceAsStream(fileName);
  bufferedReader=new BufferedReader(new InputStreamReader(inputStream));
  StringTokenizer st;
  try {
    kernelList=new ArrayList<Float>();
    int i=0;
    String line;
    while ((line=bufferedReader.readLine()) != null && i < KERNEL_MATRIX_WIDTH_RR) {
      line=line.trim();
      st=new StringTokenizer(line,", ",false);
      if ((i - 1) % 3 == 0) {
        int j=0;
        while (st.hasMoreTokens() && j < KERNEL_MATRIX_WIDTH_RR) {
          if ((j - 1) % 3 == 0) {
            kernelList.add(Float.parseFloat(st.nextToken()));
          }
 else {
            st.nextToken();
          }
          j++;
        }
      }
      i++;
    }
  }
 catch (  IOException e) {
    throw new OperatorException("Failed to load W matrix: \n" + e.getMessage(),e);
  }
catch (  NumberFormatException e) {
    throw new OperatorException("Failed to load W matrix: \n" + e.getMessage(),e);
  }
 finally {
    if (inputStream != null) {
      inputStream.close();
    }
  }
}
 

Example 65

From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/net/bioclipse/seneca/util/.

Source file: PredictionTool.java

  17 
vote

/** 
 * Constructor for the PredictionTool object
 * @exception IOException  Problems reading the HOSE code file.
 */
public PredictionTool(List<String> symbols) throws IOException {
  String filename="nmrshiftdb.csv";
  InputStream ins=this.getClass().getClassLoader().getResourceAsStream(filename);
  BufferedReader reader=new BufferedReader(new InputStreamReader(ins));
  String input;
  int counter=0;
  int stored=0;
  int found=0;
  while ((input=reader.readLine()) != null) {
    StringTokenizer st2=new StringTokenizer(input,"|");
    String symbol=st2.nextToken();
    String code=st2.nextToken();
    if (applicable(code,symbols)) {
      float min=Float.parseFloat(st2.nextToken());
      float av=Float.parseFloat(st2.nextToken());
      float max=Float.parseFloat(st2.nextToken());
      if (mapsmap.get(symbol) == null) {
        mapsmap.put(symbol,new HashMap(5));
      }
      ((HashMap)mapsmap.get(symbol)).put(code,new ValueBean(min,av,max));
      stored++;
    }
    counter++;
    found++;
    if (counter == 10000) {
      System.out.print("x");
      counter=0;
    }
  }
}
 

Example 66

From project Bit4Tat, under directory /Bit4Tat/src/com/Bit4Tat/.

Source file: Bit4Tat.java

  17 
vote

public static void main(String[] args){
  SchedulerGateway simpleScheduler=new DefaultScheduler();
  WalletFileIO f=new WalletFileIO("wallet.csv");
  f.openReader();
  StringTokenizer tokenizer=f.getTokenizer(",");
  userpass=new Hashtable<String,String[]>();
  String service="";
  String[] account=new String[2];
  try {
    if (tokenizer.countTokens() == 0)     throw (new Exception("empty"));
    while (tokenizer.hasMoreTokens()) {
      service=tokenizer.nextToken();
      if ((service.equals("mtgox")) && (service.equals("tradehill")))       throw (new Exception("unknown service"));
      account[0]=tokenizer.nextToken();
      account[1]=tokenizer.nextToken();
      userpass.put(service,account);
    }
  }
 catch (  Exception e) {
    if (e.getMessage().equals("empty"))     System.err.println("Wallet file is empty!");
 else     if (e.getMessage().equals("unknown service")) {
      System.err.println("Unknown service!");
      System.err.println(service);
    }
 else {
      System.err.println(e.getMessage());
      System.err.println(e);
    }
  }
  Wallet coinPurse=new Wallet(userpass);
  BitFrame frame=new BitFrame(coinPurse);
  frame.setTitle("Bit4Tat " + version);
  frame.setVisible(true);
}
 

Example 67

From project blacktie, under directory /jatmibroker-xatmi/src/main/java/org/jboss/narayana/blacktie/jatmibroker/xatmi/server/.

Source file: BlackTieServer.java

  17 
vote

/** 
 * Initialize the server
 * @param serverName The name of the server
 * @throws ConfigurationException If the server does not exist
 * @throws ConnectionException If the server cannot connect to the infrastructure configured
 */
public BlackTieServer(String serverName) throws ConfigurationException, ConnectionException {
  ORB orb=com.arjuna.orbportability.ORB.getInstance("ClientSide");
  RootOA oa=com.arjuna.orbportability.OA.getRootOA(orb);
  orb.initORB(new String[]{},null);
  try {
    oa.initOA();
  }
 catch (  Throwable t) {
    throw new ConnectionException(Connection.TPESYSTEM,"Could not connect to the orb",t);
  }
  ORBManager.setORB(orb);
  ORBManager.setPOA(oa);
  this.serverName=serverName;
  AtmiBrokerEnvXML server=new AtmiBrokerEnvXML();
  properties=server.getProperties();
  transportFactory=new TransportFactory(properties);
  String services=(String)properties.get("blacktie." + serverName + ".services");
  if (services != null) {
    StringTokenizer st=new StringTokenizer(services,",",false);
    while (st.hasMoreElements()) {
      String serviceName=st.nextToken();
      String functionName=(String)properties.get("blacktie." + serviceName + ".java_class_name");
      tpadvertise(serviceName,functionName);
    }
  }
}
 

Example 68

From project BlameSubversion-plugin, under directory /src/main/java/hudson/scm/.

Source file: BlameSubversionSCM.java

  17 
vote

/** 
 * list of all configured svn locations, expanded according to build parameters values;
 * @param build If non-null, variable expansions are performed against the build parameters.
 * @since 1.252
 */
public ModuleLocation[] getLocations(AbstractBuild<?,?> build){
  if (modules != null) {
    List<ModuleLocation> oldLocations=new ArrayList<ModuleLocation>();
    StringTokenizer tokens=new StringTokenizer(modules);
    while (tokens.hasMoreTokens()) {
      String remoteLoc=Util.removeTrailingSlash(tokens.nextToken());
      oldLocations.add(new ModuleLocation(remoteLoc,null));
    }
    locations=oldLocations.toArray(new ModuleLocation[oldLocations.size()]);
    modules=null;
  }
  if (build == null)   return locations;
  ModuleLocation[] outLocations=new ModuleLocation[locations.length];
  for (int i=0; i < outLocations.length; i++) {
    outLocations[i]=locations[i].getExpandedLocation(build);
  }
  return outLocations;
}
 

Example 69

From project bulk-builder-plugin, under directory /src/main/java/org/jenkinsci/plugins/bulkbuilder/model/.

Source file: BulkParamProcessor.java

  17 
vote

/** 
 * Process and return input parameter string
 * @return
 */
public Map<String,String> getProjectParams(){
  if (rawParams == null) {
    return null;
  }
  StringTokenizer tokeniser=new StringTokenizer(rawParams,"&");
  Map<String,String> values=new HashMap<String,String>(tokeniser.countTokens());
  while (tokeniser.hasMoreTokens()) {
    String rawParam=tokeniser.nextToken();
    String[] split=rawParam.split("=");
    if (split.length == 2) {
      values.put(split[0],split[1]);
      if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.log(Level.INFO,"Added {0}",split);
      }
    }
  }
  if (values.isEmpty()) {
    return null;
  }
  return values;
}
 

Example 70

From project candlepin, under directory /src/main/java/org/candlepin/util/.

Source file: X509V3ExtensionUtil.java

  17 
vote

private org.candlepin.json.model.Product mapProduct(Product product,String contentPrefix,Map<String,EnvironmentContent> promotedContent,Consumer consumer,Entitlement ent){
  org.candlepin.json.model.Product toReturn=new org.candlepin.json.model.Product();
  toReturn.setId(product.getId());
  toReturn.setName(product.getName());
  String version=product.hasAttribute("version") ? product.getAttributeValue("version") : "";
  toReturn.setVersion(version);
  String arch=product.hasAttribute("arch") ? product.getAttributeValue("arch") : "";
  StringTokenizer st=new StringTokenizer(arch,",");
  List<String> archList=new ArrayList<String>();
  while (st.hasMoreElements()) {
    archList.add((String)st.nextElement());
  }
  toReturn.setArchitectures(archList);
  toReturn.setContent(createContent(filterProductContent(product,ent),contentPrefix,promotedContent,consumer));
  return toReturn;
}
 

Example 71

From project capedwarf-green, under directory /server-api/src/main/java/org/jboss/capedwarf/server/api/domain/.

Source file: Version.java

  17 
vote

/** 
 * Create a new VersionImpl.
 * @param version the version as a string
 * @throws IllegalArgumentException for a null version or invalid format
 */
private Version(String version){
  if (version == null)   throw new IllegalArgumentException("Null version");
  int major;
  int minor=0;
  int micro=0;
  String qualifier="";
  try {
    StringTokenizer st=new StringTokenizer(version,SEPARATOR,true);
    major=Integer.parseInt(st.nextToken().trim());
    if (st.hasMoreTokens()) {
      st.nextToken();
      minor=Integer.parseInt(st.nextToken().trim());
      if (st.hasMoreTokens()) {
        st.nextToken();
        micro=Integer.parseInt(st.nextToken().trim());
        if (st.hasMoreTokens()) {
          st.nextToken();
          qualifier=st.nextToken().trim();
          if (st.hasMoreTokens()) {
            throw new IllegalArgumentException("Invalid version format, too many seperators: " + version);
          }
        }
      }
    }
  }
 catch (  NoSuchElementException e) {
    throw new IllegalArgumentException("Invalid version format: " + version);
  }
catch (  NumberFormatException e) {
    throw new IllegalArgumentException("Invalid version format: " + version,e);
  }
  this.major=major;
  this.minor=minor;
  this.micro=micro;
  this.qualifier=qualifier;
  validate();
}
 

Example 72

From project Carnivore, under directory /net/sourceforge/jpcap/util/.

Source file: PropertyHelper.java

  17 
vote

/** 
 * Convert a space delimited color tuple string to a color. <p> Converts a string value like "255 255 0" to a color constant, in this case, yellow.
 * @param key the name of the property
 * @return a Color object equivalent to the provided string contents. Returns white if the string is null or can't be converted.
 */
public static Color getColorProperty(Properties properties,Object key){
  String string=(String)properties.get(key);
  if (string == null) {
    System.err.println("WARN: couldn't find color tuplet under '" + key + "'");
    return Color.white;
  }
  StringTokenizer st=new StringTokenizer(string," ");
  Color c;
  try {
    c=new Color(Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken()));
  }
 catch (  NoSuchElementException e) {
    c=Color.white;
    System.err.println("WARN: invalid color spec '" + string + "' in property file");
  }
  return c;
}
 

Example 73

From project Carolina-Digital-Repository, under directory /djatoka-cdr/src/gov/lanl/util/.

Source file: AccessManager.java

  17 
vote

private void parse(BufferedReader htin) throws IOException {
  String line;
  int limit=0;
  while ((line=htin.readLine()) != null) {
    line=line.trim();
    if (line.startsWith("#"))     continue;
    if (line.startsWith("order")) {
      if (logger.isDebugEnabled())       logger.debug("orderline=" + line + "order="+ _order);
      if (line.indexOf("allow,deny") > 0) {
        logger.debug("==>allow+deny");
        _order=1;
      }
 else       if (line.indexOf("deny,allow") > 0) {
        logger.debug("==>deny,allow");
        _order=-1;
      }
    }
 else     if (line.startsWith("allow from")) {
      int pos1=10;
      limit=line.length();
      while ((pos1 < limit) && (line.charAt(pos1) <= ' '))       pos1++;
      if (logger.isDebugEnabled())       logger.debug("allow from:" + line.substring(pos1));
      StringTokenizer tkns=new StringTokenizer(line.substring(pos1));
      while (tkns.hasMoreTokens()) {
        _allowList.add(tkns.nextToken());
      }
    }
 else     if (line.startsWith("deny from")) {
      int pos1=9;
      limit=line.length();
      while ((pos1 < limit) && (line.charAt(pos1) <= ' '))       pos1++;
      if (logger.isDebugEnabled())       logger.debug("deny from:" + line.substring(pos1));
      StringTokenizer tkns=new StringTokenizer(line.substring(pos1));
      while (tkns.hasMoreTokens()) {
        _denyList.add(tkns.nextToken());
      }
    }
  }
}
 

Example 74

From project cdh-mapreduce-ext, under directory /src/main/java/org/apache/hadoop/mapreduce/lib/partition/.

Source file: KeyFieldHelper.java

  17 
vote

public void parseOption(String option){
  if (option == null || option.equals("")) {
    return;
  }
  StringTokenizer args=new StringTokenizer(option);
  KeyDescription global=new KeyDescription();
  while (args.hasMoreTokens()) {
    String arg=args.nextToken();
    if (arg.equals("-n")) {
      global.numeric=true;
    }
    if (arg.equals("-r")) {
      global.reverse=true;
    }
    if (arg.equals("-nr")) {
      global.numeric=true;
      global.reverse=true;
    }
    if (arg.startsWith("-k")) {
      KeyDescription k=parseKey(arg,args);
      if (k != null) {
        allKeySpecs.add(k);
        keySpecSeen=true;
      }
    }
  }
  for (  KeyDescription key : allKeySpecs) {
    if (!(key.reverse | key.numeric)) {
      key.reverse=global.reverse;
      key.numeric=global.numeric;
    }
  }
  if (allKeySpecs.size() == 0) {
    allKeySpecs.add(global);
  }
}
 

Example 75

From project ceylon-runtime, under directory /api/src/main/java/ceylon/modules/api/util/.

Source file: ModuleVersion.java

  17 
vote

/** 
 * Create a new VersionImpl.
 * @param version the version as a string
 * @throws IllegalArgumentException for a null version or invalid format
 */
private ModuleVersion(String version){
  if (version == null)   throw new IllegalArgumentException("Null version");
  int major;
  int minor=0;
  int micro=0;
  String qualifier="";
  try {
    StringTokenizer st=new StringTokenizer(version,SEPARATOR,true);
    major=Integer.parseInt(st.nextToken().trim());
    if (st.hasMoreTokens()) {
      st.nextToken();
      minor=Integer.parseInt(st.nextToken().trim());
      if (st.hasMoreTokens()) {
        st.nextToken();
        micro=Integer.parseInt(st.nextToken().trim());
        if (st.hasMoreTokens()) {
          st.nextToken();
          qualifier=st.nextToken().trim();
          if (st.hasMoreTokens()) {
            throw new IllegalArgumentException("Invalid version format, too many seperators: " + version);
          }
        }
      }
    }
  }
 catch (  NoSuchElementException e) {
    throw new IllegalArgumentException("Invalid version format: " + version);
  }
catch (  NumberFormatException e) {
    throw new IllegalArgumentException("Invalid version format: " + version,e);
  }
  this.major=major;
  this.minor=minor;
  this.micro=micro;
  this.qualifier=qualifier;
  validate();
}
 

Example 76

From project ciel-java, under directory /examples/WordCount/src/skywriting/examples/wordcount/.

Source file: WordCountMapper.java

  17 
vote

public void invoke(InputStream[] inputs,OutputStream[] outputs,String[] args){
  int nReducers=outputs.length;
  int nInputs=inputs.length;
  BufferedReader[] dis=new BufferedReader[nInputs];
  DataOutputStream[] dos=new DataOutputStream[nReducers];
  for (int i=0; i < nInputs; i++) {
    dis[i]=new BufferedReader(new InputStreamReader(inputs[i]));
  }
  for (int i=0; i < nReducers; i++) {
    dos[i]=new DataOutputStream(new BufferedOutputStream(outputs[i]));
  }
  String line;
  try {
    IncrementerCombiner comb=new IncrementerCombiner();
    PartialHashOutputCollector<Text,IntWritable> outMap=new PartialHashOutputCollector<Text,IntWritable>(dos,nReducers,1000,comb);
    while ((line=dis[0].readLine()) != null) {
      StringTokenizer itr=new StringTokenizer(line);
      while (itr.hasMoreTokens()) {
        Text word=new Text();
        word.set(itr.nextToken());
        outMap.collect(word,one);
      }
    }
    outMap.flushAll();
    for (    DataOutputStream d : dos)     d.close();
  }
 catch (  IOException e) {
    System.out.println("IOException while running mapper");
    e.printStackTrace();
    System.exit(1);
  }
}
 

Example 77

From project cipango, under directory /cipango-server/src/main/java/org/cipango/server/sipapp/rules/.

Source file: RequestRule.java

  17 
vote

protected RequestRule(String varName){
  _varName=varName;
  _extractors=new ArrayList<Extractor>();
  StringTokenizer st=new StringTokenizer(varName,".");
  String lastToken=st.nextToken();
  if (!lastToken.equals("request"))   throw new IllegalArgumentException("Expression does not start with request: " + varName);
  while (st.hasMoreTokens()) {
    String token=st.nextToken();
    if (token.equals("from"))     _extractors.add(new From(lastToken));
 else     if (token.equals("uri"))     _extractors.add(new Uri(lastToken));
 else     if (token.equals("method"))     _extractors.add(new Method(lastToken));
 else     if (token.equals("user"))     _extractors.add(new User(lastToken));
 else     if (token.equals("scheme"))     _extractors.add(new Scheme(lastToken));
 else     if (token.equals("host"))     _extractors.add(new Host(lastToken));
 else     if (token.equals("port"))     _extractors.add(new Port(lastToken));
 else     if (token.equals("tel"))     _extractors.add(new Tel(lastToken));
 else     if (token.equals("display-name"))     _extractors.add(new DisplayName(lastToken));
 else     if (token.equals("to"))     _extractors.add(new To(lastToken));
 else     if (token.equals("route"))     _extractors.add(new Route(lastToken));
 else     if (token.equals("param")) {
      if (!st.hasMoreTokens())       throw new IllegalArgumentException("No param name: " + varName);
      String param=st.nextToken();
      _extractors.add(new Param(lastToken,param));
      if (st.hasMoreTokens())       throw new IllegalArgumentException("Invalid var: " + st.nextToken() + " in "+ varName);
    }
 else     throw new IllegalArgumentException("Invalid property: " + token + " in "+ varName);
    lastToken=token;
  }
}
 

Example 78

From project Clotho-Core, under directory /ClothoApps/SequenceChecker/src/jaligner/matrix/.

Source file: MatrixLoader.java

  17 
vote

/** 
 * Loads scoring matrix from  {@link InputStream}
 * @param nis named input stream
 * @return loaded matrix
 * @throws MatrixLoaderException
 * @see Matrix
 * @see NamedInputStream
 */
public static Matrix load(NamedInputStream nis) throws MatrixLoaderException {
  char[] acids=new char[Matrix.SIZE];
  for (int i=0; i < Matrix.SIZE; i++) {
    acids[i]=0;
  }
  float[][] scores=new float[Matrix.SIZE][Matrix.SIZE];
  BufferedReader reader=new BufferedReader(new InputStreamReader(nis.getInputStream()));
  String line;
  try {
    while ((line=reader.readLine()) != null && line.trim().charAt(0) == COMMENT_STARTER)     ;
  }
 catch (  Exception e) {
    String message="Failed reading from input stream: " + e.getMessage();
    logger.log(Level.SEVERE,message,e);
    throw new MatrixLoaderException(message);
  }
  StringTokenizer tokenizer;
  tokenizer=new StringTokenizer(line.trim());
  for (int j=0; tokenizer.hasMoreTokens(); j++) {
    acids[j]=tokenizer.nextToken().charAt(0);
  }
  try {
    while ((line=reader.readLine()) != null) {
      tokenizer=new StringTokenizer(line.trim());
      char acid=tokenizer.nextToken().charAt(0);
      for (int i=0; i < Matrix.SIZE; i++) {
        if (acids[i] != 0) {
          scores[acid][acids[i]]=Float.parseFloat(tokenizer.nextToken());
        }
      }
    }
  }
 catch (  Exception e) {
    String message="Failed reading from input stream: " + e.getMessage();
    logger.log(Level.SEVERE,message,e);
    throw new MatrixLoaderException(message);
  }
  return new Matrix(nis.getName(),scores);
}
 

Example 79

From project clustermeister, under directory /node-common/src/main/java/com/github/nethad/clustermeister/node/common/.

Source file: JvmOptionsConfigurationSource.java

  17 
vote

@Override public InputStream getPropertyStream() throws IOException {
  String jvmOptions=System.getProperty(Constants.JPPF_JVM_OPTIONS);
  Properties properties=new Properties();
  if (jvmOptions != null) {
    StringTokenizer tokenizer=new StringTokenizer(jvmOptions);
    while (tokenizer.hasMoreTokens()) {
      String token=tokenizer.nextToken();
      if (token.startsWith("-D") && token.contains("=")) {
        String[] property=token.substring(2).split("=",2);
        properties.setProperty(property[0],property[1]);
      }
    }
  }
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  properties.store(baos,null);
  System.out.println("HMM: " + new String(baos.toByteArray()));
  return new ByteArrayInputStream(baos.toByteArray());
}
 

Example 80

From project CMake-runner-plugin, under directory /cmake-runner-agent/src/jetbrains/buildServer/cmakerunner/agent/util/.

Source file: FileUtil.java

  17 
vote

@Nullable public static String findExecutableByNameInPATH(@NotNull final String exeName,@NotNull final Map<String,String> environment){
  final String path=OSUtil.getPathEnvVariable(environment);
  if (path != null) {
    final StringTokenizer st=new StringTokenizer(path,File.pathSeparator);
    while (st.hasMoreTokens()) {
      final String possible_path=st.nextToken() + "/" + exeName;
      if (FileUtil.checkIfExists(possible_path)) {
        return possible_path;
      }
    }
  }
  if (!exeName.endsWith(".exe") && SystemInfo.isWindows) {
    return findExecutableByNameInPATH(exeName + ".exe",environment);
  }
  if (!exeName.endsWith(".bat") && SystemInfo.isWindows) {
    return findExecutableByNameInPATH(exeName + ".bat",environment);
  }
  return null;
}
 

Example 81

From project codjo-imports, under directory /codjo-imports-common/src/main/java/net/codjo/imports/common/translator/.

Source file: BooleanTranslator.java

  17 
vote

/** 
 * Traduction du champ en objet Boolean. <p> Conversion du booleen d'entr? (VRAI/FAUX) en booleen de sortie. </p>
 * @param field Champ  traduire.
 * @return Le champ en format SQL.
 * @exception BadFormatException Description of Exception
 */
public Object translate(String field) throws BadFormatException {
  if (field == null) {
    return Boolean.FALSE;
  }
  if ("".equalsIgnoreCase(field)) {
    return Boolean.FALSE;
  }
  String yesString="OUI;O;VRAI;YES;TRUE;1";
  String noString="NON;N;FAUX;NO;FALSE;0";
  StringTokenizer yesTokenizer=new StringTokenizer(yesString,";");
  StringTokenizer noTokenizer=new StringTokenizer(noString,";");
  while (yesTokenizer.hasMoreTokens()) {
    if (yesTokenizer.nextToken().equalsIgnoreCase(field)) {
      return Boolean.TRUE;
    }
  }
  while (noTokenizer.hasMoreTokens()) {
    if (noTokenizer.nextToken().equalsIgnoreCase(field)) {
      return Boolean.FALSE;
    }
  }
  throw new BadFormatException(this,field + " n'est pas un booleen");
}