Java Code Examples for java.util.StringTokenizer#hasMoreTokens()

The following examples show how to use java.util.StringTokenizer#hasMoreTokens() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WANTestBase.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void createPartitionedRegionAsAccessor(
      String regionName, String senderIds, Integer redundantCopies, Integer totalNumBuckets){
    AttributesFactory fact = new AttributesFactory();
    if(senderIds!= null){
      StringTokenizer tokenizer = new StringTokenizer(senderIds, ",");
      while (tokenizer.hasMoreTokens()){
        String senderId = tokenizer.nextToken();
//        GatewaySender sender = cache.getGatewaySender(senderId);
//        assertNotNull(sender);
        fact.addGatewaySenderId(senderId);
      }
    }
    PartitionAttributesFactory pfact = new PartitionAttributesFactory();
    pfact.setTotalNumBuckets(totalNumBuckets);
    pfact.setRedundantCopies(redundantCopies);
    pfact.setLocalMaxMemory(0);
    fact.setPartitionAttributes(pfact.create());
    Region r = cache.createRegionFactory(fact.create()).create(regionName);
    assertNotNull(r);
  }
 
Example 2
Source File: WANTestBase.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void createPersistentPartitionedRegionWithAsyncEventQueue(
    String regionName, String asyncEventQueueId, Boolean offHeap) {
  AttributesFactory fact = new AttributesFactory();

  PartitionAttributesFactory pfact = new PartitionAttributesFactory();
  fact.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
  pfact.setTotalNumBuckets(16);
  fact.setPartitionAttributes(pfact.create());
  fact.setEnableOffHeapMemory(offHeap);
  if (asyncEventQueueId != null) {
    StringTokenizer tokenizer = new StringTokenizer(asyncEventQueueId, ",");
    while (tokenizer.hasMoreTokens()) {
      String asyncId = tokenizer.nextToken();
      fact.addAsyncEventQueueId(asyncId);
    }
  }
  Region r = cache.createRegionFactory(fact.create()).create(regionName);
  assertNotNull(r);
}
 
Example 3
Source File: ParameterParser.java    From OpenAs2App with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Set parameters from a string, like "msg.sender.as2_id=ME,msg.headers.content-type=application/X12"
 *
 * @param encodedParams string to parse
 * @throws InvalidParameterException - error in the parameter format string
 */
public void setParameters(String encodedParams) throws InvalidParameterException {
    StringTokenizer params = new StringTokenizer(encodedParams, "=,", false);
    String key;
    String value;

    while (params.hasMoreTokens()) {
        key = params.nextToken().trim();

        if (!params.hasMoreTokens()) {
            throw new InvalidParameterException("Invalid value for encoded param \"" + encodedParams + "\"", this, key, null);
        }

        value = params.nextToken();
        setParameter(key, value);
    }
}
 
Example 4
Source File: SourceMapper.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
SourceMapper(String sourcepath) {
    /*
     * sourcepath can also arrive from the command line
     * as a String.  (via "-sourcepath")
     *
     * Using File.pathSeparator as delimiter below is OK
     * because we are on the same machine as the command
     * line originiated.
     */
    StringTokenizer st = new StringTokenizer(sourcepath,
                                             File.pathSeparator);
    List<String> dirList = new ArrayList<String>();
    while (st.hasMoreTokens()) {
        String s = st.nextToken();
        //XXX remove .jar and .zip files; we want only directories on
        //the source path. (Bug ID 4186582)
        if ( ! (s.endsWith(".jar") ||
                s.endsWith(".zip"))) {
            dirList.add(s);
        }
    }
    dirs = dirList.toArray(new String[0]);
}
 
Example 5
Source File: FileObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Retrieve file or folder relative to a current folder, with a given relative path.
* <em>Note</em> that neither file nor folder is created on disk. This method isn't final since revision 1.93.
* Since 7.45 common implementations of this method 
* accept also ".." which is interpreted as a reference to parent.
* 
* @param relativePath is just basename of the file or (since 4.16) the relative path delimited by '/'
* @return the object representing this file or <CODE>null</CODE> if the file
*   or folder does not exist
* @exception IllegalArgumentException if <code>this</code> is not a folder
*/
public FileObject getFileObject(String relativePath) {
    if (relativePath.startsWith("/") && !relativePath.startsWith("//")) {
        relativePath = relativePath.substring(1);
    }

    FileObject myObj = this;
    StringTokenizer st = new StringTokenizer(relativePath, "/");
    
    if(relativePath.startsWith("//")) {
        // if it is UNC absolute path, start with //ComputerName/sharedFolder
        myObj = myObj.getFileObject("//"+st.nextToken()+"/"+st.nextToken(), null);
    }
    while ((myObj != null) && st.hasMoreTokens()) {
        String nameExt = st.nextToken();
        if (nameExt.equals("..")) { // NOI18N
            myObj = myObj.getParent();
        } else {
            if (!nameExt.equals(".")) {
                myObj = myObj.getFileObject(nameExt, null);
            }
        }
    }

    return myObj;
}
 
Example 6
Source File: ClassLoaderBuilder.java    From ModTheSpire with MIT License 6 votes vote down vote up
/**
 * Add the contents of the classpath.
 */
public void addClassPath()
{
    String path = null;

    try
    {
        path = System.getProperty ("java.class.path");
    }

    catch (Exception ex)
    {
        path= "";
        log.error ("Unable to get class path", ex);
    }

    if (path != null)
    {
        StringTokenizer tok = new StringTokenizer (path,
                                                   File.pathSeparator);

        while (tok.hasMoreTokens())
            add (new File (tok.nextToken()));
    }
}
 
Example 7
Source File: Stylesheet.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Store extension URIs
 */
private void extensionURI(String prefixes, SymbolTable stable) {
    if (prefixes != null) {
        StringTokenizer tokens = new StringTokenizer(prefixes);
        while (tokens.hasMoreTokens()) {
            final String prefix = tokens.nextToken();
            final String uri = lookupNamespace(prefix);
            if (uri != null) {
                _extensions.put(uri, prefix);
            }
        }
    }
}
 
Example 8
Source File: Utils.java    From Raccoon with Apache License 2.0 5 votes vote down vote up
/**
    * Parses key-value response into map.
    */
   public static Map<String, String> parseResponse(String response) {

Map<String, String> keyValueMap = new HashMap<String, String>();
StringTokenizer st = new StringTokenizer(response, "\n\r");

while (st.hasMoreTokens()) {
    String[] keyValue = st.nextToken().split("=");
    keyValueMap.put(keyValue[0], keyValue[1]);
}

return keyValueMap;
   }
 
Example 9
Source File: parseParameters.java    From KEEL with GNU General Public License v3.0 5 votes vote down vote up
/**
 * We read the input data-set files and all the possible input files
 * @param line StringTokenizer It is the line containing the input files.
 */
private void readInputFiles(StringTokenizer line){
    String new_line = line.nextToken(); //We read the input data line
    StringTokenizer data = new StringTokenizer(new_line, " = \" ");
    data.nextToken(); //inputFile
    transactionsFile = data.nextToken();
    while(data.hasMoreTokens()){
        inputFiles.add(data.nextToken());
    }
}
 
Example 10
Source File: CLDRLocaleProviderAdapter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Set<String> createLanguageTagSet(String category) {
    ResourceBundle rb = ResourceBundle.getBundle("sun.util.cldr.CLDRLocaleDataMetaInfo", Locale.ROOT);
    String supportedLocaleString = rb.getString(category);
    Set<String> tagset = new HashSet<>();
    StringTokenizer tokens = new StringTokenizer(supportedLocaleString);
    while (tokens.hasMoreTokens()) {
        tagset.add(tokens.nextToken());
    }
    return tagset;
}
 
Example 11
Source File: WARCWordDistribution.java    From dkpro-c4corpus with Apache License 2.0 5 votes vote down vote up
@Override
protected void map(LongWritable key, WARCWritable value, Context context)
        throws IOException, InterruptedException
{
    WARCRecord warcRecord = value.getRecord();
    String content = new String(warcRecord.getContent(), "utf-8");
    String cleanContent = content.toLowerCase().replaceAll(tokens, " ");
    StringTokenizer itr = new StringTokenizer(cleanContent);
    while (itr.hasMoreTokens()) {
        word.set(itr.nextToken().trim());
        context.write(word, one);
    }
}
 
Example 12
Source File: NmasResponseSet.java    From ldapchai with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Locale parseLocaleString( final String localeString )
{
    if ( localeString == null )
    {
        return new Locale( "" );
    }

    final StringTokenizer st = new StringTokenizer( localeString, "_" );

    if ( !st.hasMoreTokens() )
    {
        return new Locale( "" );
    }

    final String language = st.nextToken();
    if ( !st.hasMoreTokens() )
    {
        return new Locale( language );
    }

    final String country = st.nextToken();
    if ( !st.hasMoreTokens() )
    {
        return new Locale( language, country );
    }

    final String variant = st.nextToken( "" );
    return new Locale( language, country, variant );
}
 
Example 13
Source File: PySelection.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @return whether the current selection is on the ClassName or Function name context
 * (just after the 'class' or 'def' tokens)
 */
public int isRightAfterDeclarationInLine() {
    try {
        String contents = getLineContentsToCursor();
        StringTokenizer strTok = new StringTokenizer(contents);
        if (strTok.hasMoreTokens()) {
            String tok = strTok.nextToken();
            int decl = DECLARATION_NONE;
            if (tok.equals("class")) {
                decl = DECLARATION_CLASS;
            } else if (tok.equals("def")) {
                decl = DECLARATION_METHOD;
            }
            if (decl != DECLARATION_NONE) {

                //ok, we're in a class or def line... so, if we find a '(' or ':', we're not in the declaration...
                //(otherwise, we're in it)
                while (strTok.hasMoreTokens()) {
                    tok = strTok.nextToken();
                    if (tok.indexOf('(') != -1 || tok.indexOf(':') != -1) {
                        return DECLARATION_NONE;
                    }
                }
                return decl;
            }
        }
    } catch (BadLocationException e) {
    }
    return DECLARATION_NONE;
}
 
Example 14
Source File: JsgfGrammarIdentifier.java    From JVoiceXML with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * A JSGF grammar must have a self identifying header
 * <code>#JSGF V1.0</code>.
 */
@Override
public GrammarType identify(final GrammarDocument grammar) {
    /* make sure grammar is neither null nor empty */
    if (grammar == null) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("grammar is null or empty");
        }
        return null;
    }
    if (!grammar.isAscii()) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("can only handle ascii grammars");
        }
        return null;
    }
    final String document = grammar.getTextContent();
    if (document.startsWith(JSGF_HEDAER)) {
        return GrammarType.JSGF;
    }
    /*
     * cut grammar in pieces. Delimiter is ; followed by a
     * newline immediately
     */
    final StringTokenizer tok = new StringTokenizer(document, ";");
    if (!tok.hasMoreTokens()) {
        return null;
    }

    final String header = tok.nextToken();
    if (header.startsWith(JSGF_HEDAER)) {
        return GrammarType.JSGF;
    }
    // TODO Evaluate encoding and version.
    return null;
}
 
Example 15
Source File: parseParameters.java    From KEEL with GNU General Public License v3.0 5 votes vote down vote up
/**
 * We read the input data-set files and all the possible input files
 * @param line StringTokenizer It is the line containing the input files.
 */
private void readInputFiles(StringTokenizer line){
    String new_line = line.nextToken(); //We read the input data line
    StringTokenizer data = new StringTokenizer(new_line, " = \" ");
    data.nextToken(); //inputFile
    trainingFile = data.nextToken();
    validationFile = data.nextToken();
    testFile = data.nextToken();
    while(data.hasMoreTokens()){
        inputFiles.add(data.nextToken());
    }
}
 
Example 16
Source File: PigContext.java    From spork with Apache License 2.0 5 votes vote down vote up
public static void initializeImportList(String importListCommandLineProperties)
{
    StringTokenizer tokenizer = new StringTokenizer(importListCommandLineProperties, ":");
    int pos = 1; // Leave "" as the first import
    ArrayList<String> importList = getPackageImportList();
    while (tokenizer.hasMoreTokens())
    {
        String importItem = tokenizer.nextToken();
        if (!importItem.endsWith("."))
            importItem += ".";
        importList.add(pos, importItem);
        pos++;
    }
}
 
Example 17
Source File: TzdbZoneRulesCompiler.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Parses a Rule line.
 *
 * @param st  the tokenizer, not null
 * @param mdt  the object to parse into, not null
 */
private void parseMonthDayTime(StringTokenizer st, TZDBMonthDayTime mdt) {
    mdt.month = parseMonth(st.nextToken());
    if (st.hasMoreTokens()) {
        String dayRule = st.nextToken();
        if (dayRule.startsWith("last")) {
            mdt.dayOfMonth = -1;
            mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(4));
            mdt.adjustForwards = false;
        } else {
            int index = dayRule.indexOf(">=");
            if (index > 0) {
                mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(0, index));
                dayRule = dayRule.substring(index + 2);
            } else {
                index = dayRule.indexOf("<=");
                if (index > 0) {
                    mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(0, index));
                    mdt.adjustForwards = false;
                    dayRule = dayRule.substring(index + 2);
                }
            }
            mdt.dayOfMonth = Integer.parseInt(dayRule);
        }
        if (st.hasMoreTokens()) {
            String timeStr = st.nextToken();
            int timeOfDaySecs = parseSecs(timeStr);
            LocalTime time = deduplicate(LocalTime.ofSecondOfDay(Jdk8Methods.floorMod(timeOfDaySecs, 86400)));
            mdt.time = time;
            mdt.adjustDays = Jdk8Methods.floorDiv(timeOfDaySecs, 86400);
            mdt.timeDefinition = parseTimeDefinition(timeStr.charAt(timeStr.length() - 1));
        }
    }
}
 
Example 18
Source File: StringUtils.java    From Canova with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a collection of strings.
 * @param str comma seperated string values
 * @return an <code>ArrayList</code> of string values
 */
public static Collection<String> getStringCollection(String str){
    List<String> values = new ArrayList<String>();
    if (str == null)
        return values;
    StringTokenizer tokenizer = new StringTokenizer (str,",");
    values = new ArrayList<String>();
    while (tokenizer.hasMoreTokens()) {
        values.add(tokenizer.nextToken());
    }
    return values;
}
 
Example 19
Source File: parseParameters.java    From KEEL with GNU General Public License v3.0 5 votes vote down vote up
/**
 * We read the input data-set files and all the possible input files
 * @param line StringTokenizer It is the line containing the input files.
 */
private void readInputFiles(StringTokenizer line){
    String new_line = line.nextToken(); //We read the input data line
    StringTokenizer data = new StringTokenizer(new_line, " = \" ");
    data.nextToken(); //inputFile
    trainingFile = data.nextToken();
    validationFile = data.nextToken();
    testFile = data.nextToken();
    while(data.hasMoreTokens()){
        inputFiles.add(data.nextToken());
    }
}
 
Example 20
Source File: BioSet.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Randomizes the values of the passed in attributes.
 *
 * @param randomizeStr .-delimited list of attributes to randomize.
 * 						(AGE.HT.WT.EYES.HAIR.SKIN are the possible values.)
 * @param pc The Player Character
 */
public void randomize(final String randomizeStr, final PlayerCharacter pc)
{
	if ((pc == null) || (pc.getRace() == null))
	{
		return;
	}

	final List<String> ranList = new ArrayList<>();
	final StringTokenizer lineTok = new StringTokenizer(randomizeStr, ".", false);

	while (lineTok.hasMoreTokens())
	{
		final String aString = lineTok.nextToken();

		if (aString.startsWith("AGECAT"))
		{
			generateAge(Integer.parseInt(aString.substring(6)), false, pc);
		}
		else
		{
			ranList.add(aString);
		}
	}

	if (ranList.contains("AGE"))
	{
		generateAge(0, true, pc);
	}

	if (ranList.contains("HT") || ranList.contains("WT"))
	{
		generateHeightWeight(pc);
	}

	if (ranList.contains("EYES"))
	{
		pc.setEyeColor(generateBioValue("EYES", pc));
	}

	if (ranList.contains("HAIR"))
	{
		pc.setPCAttribute(PCStringKey.HAIRCOLOR, generateBioValue("HAIR", pc));
	}

	if (ranList.contains("SKIN"))
	{
		pc.setPCAttribute(PCStringKey.SKINCOLOR, generateBioValue("SKINTONE", pc));
	}
}