当前位置: 首页>>代码示例>>Java>>正文


Java StringTokenizer.countTokens方法代码示例

本文整理汇总了Java中java.util.StringTokenizer.countTokens方法的典型用法代码示例。如果您正苦于以下问题:Java StringTokenizer.countTokens方法的具体用法?Java StringTokenizer.countTokens怎么用?Java StringTokenizer.countTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.StringTokenizer的用法示例。


在下文中一共展示了StringTokenizer.countTokens方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LoadLineReader

import java.util.StringTokenizer; //导入方法依赖的package包/类
public LoadLineReader(String fileLine) {

		assert(fileLine!=null);
		StringTokenizer st = new StringTokenizer(fileLine);
	
		transactionRatios = new double[st.countTokens()-2];
	
		timeInSec = Long.parseLong(st.nextToken());
		ratePerSec = Long.parseLong(st.nextToken());
		if (ratePerSec < 1) {
			ratePerSec = 1;
		}
	
		for(int i =0; i< transactionRatios.length;i++)
			transactionRatios[i]=Double.parseDouble(st.nextToken());
		
	}
 
开发者ID:faclc4,项目名称:HTAPBench,代码行数:18,代码来源:LoadLineReader.java

示例2: parseMimeTypes

import java.util.StringTokenizer; //导入方法依赖的package包/类
private String[] parseMimeTypes(String val) {
    int pos = val.indexOf(' ');
    //int lastPrintable;
    if (pos < 0) {
        // Maybe report/log this problem?
        //  "Last printable character not defined for encoding " +
        //  mimeName + " (" + val + ")" ...
        return new String[] { val };
        //lastPrintable = 0x00FF;
    }
    //lastPrintable =
    //    Integer.decode(val.substring(pos).trim()).intValue();
    StringTokenizer st =
            new StringTokenizer(val.substring(0, pos), ",");
    String[] values = new String[st.countTokens()];
    for (int i=0; st.hasMoreTokens(); i++) {
        values[i] = st.nextToken();
    }
    return values;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Encodings.java

示例3: extractSubmenuActions

import java.util.StringTokenizer; //导入方法依赖的package包/类
/**
 * This extracts those actions in the <code>submenuActions</code> collection whose text is qualified and returns
 * a map of these actions, keyed by submenu text.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected Map<String, Collection<IAction>> extractSubmenuActions ( Collection<IAction> createActions )
{
    Map<String, Collection<IAction>> createSubmenuActions = new LinkedHashMap<String, Collection<IAction>> ();
    if ( createActions != null )
    {
        for ( Iterator<IAction> actions = createActions.iterator (); actions.hasNext (); )
        {
            IAction action = actions.next ();
            StringTokenizer st = new StringTokenizer ( action.getText (), "|" ); //$NON-NLS-1$
            if ( st.countTokens () == 2 )
            {
                String text = st.nextToken ().trim ();
                Collection<IAction> submenuActions = createSubmenuActions.get ( text );
                if ( submenuActions == null )
                {
                    createSubmenuActions.put ( text, submenuActions = new ArrayList<IAction> () );
                }
                action.setText ( st.nextToken ().trim () );
                submenuActions.add ( action );
                actions.remove ();
            }
        }
    }
    return createSubmenuActions;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:33,代码来源:DetailViewActionBarContributor.java

示例4: parseNumberArray

import java.util.StringTokenizer; //导入方法依赖的package包/类
public static double[] parseNumberArray(String s) {
	s = s.trim();
	// if string has brackets, remove them
	if ((s.startsWith("[") && s.endsWith("]")) || (s.startsWith("(") && s.endsWith(")"))) {
		s = s.substring(1, s.length() - 1);
	}
	// now we expect num , num, num
	StringTokenizer st = new StringTokenizer(s, ";");

	// try to parse numbers and set the new value
	try {
		double[] d = new double[st.countTokens()];
		for (int i = 0; i < d.length; ++i) {
			d[i] = Double.parseDouble(st.nextToken());
		}
		return d;
	} catch (NumberFormatException ex) {
		throw new IllegalArgumentException(ex);
	}
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:21,代码来源:Location.java

示例5: getXSIType

import java.util.StringTokenizer; //导入方法依赖的package包/类
/**
 * Gets the XSI type for a given element if it has one.
 * 
 * @param e the element
 * 
 * @return the type or null
 */
public static QName getXSIType(Element e) {
    if (hasXSIType(e)) {
        Attr attribute = e.getAttributeNodeNS(XMLConstants.XSI_NS, "type");
        String attributeValue = attribute.getTextContent().trim();
        StringTokenizer tokenizer = new StringTokenizer(attributeValue, ":");
        String prefix = null;
        String localPart;
        if (tokenizer.countTokens() > 1) {
            prefix = tokenizer.nextToken();
            localPart = tokenizer.nextToken();
        } else {
            localPart = tokenizer.nextToken();
        }

        return constructQName(e.lookupNamespaceURI(prefix), localPart, prefix);
    }

    return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:XMLHelper.java

示例6: getInetAddressArray

import java.util.StringTokenizer; //导入方法依赖的package包/类
/**
 * Retrieve an array of <tt>InetAddress</tt> created from a property
 * value containting a <tt>delim</tt> separated list of hostnames and/or
 * ipaddresses.
 */

public static InetAddress[] getInetAddressArray( String key, String delim, InetAddress[] def ) {
    String p = getProperty( key );
    if( p != null ) {
        StringTokenizer tok = new StringTokenizer( p, delim );
        int len = tok.countTokens();
        InetAddress[] arr = new InetAddress[len];
        for( int i = 0; i < len; i++ ) {
            String addr = tok.nextToken();
            try {
                arr[i] = InetAddress.getByName( addr );
            } catch( UnknownHostException uhe ) {
                if( log.level > 0 ) {
                    log.println( addr );
                    uhe.printStackTrace( log );
                }
                return def;
            }
        }
        return arr;
    }
    return def;
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:29,代码来源:Config.java

示例7: parseRegistrationMessage

import java.util.StringTokenizer; //导入方法依赖的package包/类
public void parseRegistrationMessage(String msg){
StringTokenizer  st = new StringTokenizer(msg);
String  token;
int c=0;
while(st.hasMoreTokens()){
    token =st.nextToken();
    if(token.equals("DependsOn")){
	nDepends = st.countTokens();
	if(nDepends>0){
	    dependsOn = new String[nDepends];
	    while (st.hasMoreTokens()){
		dependsOn[c] = st.nextToken();
		c++;
	    }
	
	}

    }
}
   }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:21,代码来源:RUBIOSRegistrationHandler.java

示例8: getCommand

import java.util.StringTokenizer; //导入方法依赖的package包/类
public String[] getCommand(String appId, String fPath) {
    Elements apps = _root.getChildElements("app");
    //fPath = fPath.replaceAll("\\\\", "\\\\\\\\");        
    for (int i = 0; i < apps.size(); i++)
        if (apps.get(i).getAttribute("id").getValue().equals(appId)) {
            Element app = apps.get(i);
            String command = app.getAttribute("command").getValue();
            String exec = app.getAttribute("findPath").getValue() + "/" + app.getAttribute("exec").getValue();
            StringTokenizer st = new StringTokenizer(command);
            String[] cmdarray = new String[st.countTokens()+1];
            cmdarray[0] = exec;
            for (int j = 1; st.hasMoreTokens(); j++) {
                String tk = st.nextToken();
                if (tk.equals("$1"))
                    cmdarray[j] = fPath;
                else
                    cmdarray[j] = tk;
            }
            return cmdarray;
        }
    return null;
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:23,代码来源:AppList.java

示例9: getKeyValue

import java.util.StringTokenizer; //导入方法依赖的package包/类
public Optional<List<String>> getKeyValue(String keyValue) {
    StringTokenizer st = new StringTokenizer(keyValue, "=");
    if (st.countTokens() != 2) {
        log.warn("Invalid format in {} (expected key=value)", keyValue);
        return empty();
    }
    return Optional.of(asList(st.nextToken(), st.nextToken()));
}
 
开发者ID:bonigarcia,项目名称:selenium-jupiter,代码行数:9,代码来源:AnnotationsReader.java

示例10: overrideAttributesAndScope

import java.util.StringTokenizer; //导入方法依赖的package包/类
private SearchControls overrideAttributesAndScope(SearchControls cons) {
    SearchControls urlCons;

    if ((urlScope != null) || (urlAttrs != null)) {
        urlCons = new SearchControls(cons.getSearchScope(),
                                    cons.getCountLimit(),
                                    cons.getTimeLimit(),
                                    cons.getReturningAttributes(),
                                    cons.getReturningObjFlag(),
                                    cons.getDerefLinkFlag());

        if (urlScope != null) {
            if (urlScope.equals("base")) {
                urlCons.setSearchScope(SearchControls.OBJECT_SCOPE);
            } else if (urlScope.equals("one")) {
                urlCons.setSearchScope(SearchControls.ONELEVEL_SCOPE);
            } else if (urlScope.equals("sub")) {
                urlCons.setSearchScope(SearchControls.SUBTREE_SCOPE);
            }
        }

        if (urlAttrs != null) {
            StringTokenizer tokens = new StringTokenizer(urlAttrs, ",");
            int count = tokens.countTokens();
            String[] attrs = new String[count];
            for (int i = 0; i < count; i ++) {
                attrs[i] = tokens.nextToken();
            }
            urlCons.setReturningAttributes(attrs);
        }

        return urlCons;

    } else {
        return cons;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:LdapReferralContext.java

示例11: retrieveData

import java.util.StringTokenizer; //导入方法依赖的package包/类
/**
 * simply retrieve data from a file
 *
 * @param FileName
 * @param arry
 * @throws java.lang.Exception
 * @return
 */
static public boolean retrieveData(String fileName, List<String[]> arry, String delimiter) throws Exception {
    BufferedReader br = new BufferedReader(new FileReader(fileName));
    String line = null;
    String delmilit = "\t\" \"\n";
    if (delimiter != null) {
        delmilit = delimiter;        //usually some files donot start with data but with breif annoation, so we need filter the latter.

    }
    int colNum = -1;
    String[] row = null;
    StringBuilder tmpStr = new StringBuilder();
    while ((line = br.readLine()) != null) {
        if (line.trim().length() == 0) {
            continue;
        }
        StringTokenizer tokenizer = new StringTokenizer(line, delmilit);
        if (colNum < 0) {
            colNum = tokenizer.countTokens();
        }
        row = new String[colNum];
        for (int i = 0; i < colNum; i++) {
            //sometimes tokenizer.nextToken() can not release memory
            row[i] = tmpStr.append(tokenizer.nextToken().trim()).toString();
            tmpStr.delete(0, tmpStr.length());
        }
        arry.add(row);
    }
    br.close();
    return true;
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:39,代码来源:LocalFile.java

示例12: onBypassFeedback

import java.util.StringTokenizer; //导入方法依赖的package包/类
@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
	if (command.startsWith("FishSkillList"))
	{
		player.setSkillLearningClassId(player.getClassId());
		showSkillList(player);
	}

	StringTokenizer st = new StringTokenizer(command, " ");
       String command2 = st.nextToken();

	if (command2.equalsIgnoreCase("Buy"))
       {
           if (st.countTokens() < 1) return;
           int val = Integer.parseInt(st.nextToken());
           showBuyWindow(player, val);
       }
       else if (command2.equalsIgnoreCase("Sell"))
       {
       	showSellWindow(player);
       }
	else
	{
		super.onBypassFeedback(player, command);
	}
}
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:28,代码来源:L2FishermanInstance.java

示例13: openFile

import java.util.StringTokenizer; //导入方法依赖的package包/类
/** Open file in open project
 *  @param treeSubPath e.g. "Source Packages|test","sample1" */
public void openFile(String treeSubPackagePathToFile, String fileName) {
    // debug info, to be removed
    this.treeSubPackagePathToFile = treeSubPackagePathToFile;
    ProjectsTabOperator pto = new ProjectsTabOperator();
    pto.invoke();
    ProjectRootNode prn = pto.getProjectRootNode(projectName);
    prn.select();
    
    // fix of issue #51191
    // each of nodes is checked by calling method waitForChildNode 
    // before they are actually opened
    StringTokenizer st = new StringTokenizer(treeSubPackagePathToFile, 
            treeSeparator+"");
    String token = "";
    String oldtoken = "";
    // if there are more then one tokens process each of them
    if (st.countTokens()>1) {
        token = st.nextToken();
        String fullpath = token;
        while (st.hasMoreTokens()) {            
            token = st.nextToken();
            waitForChildNode(fullpath, token);
            fullpath += treeSeparator+token;
        }
    } 
    // last node
    waitForChildNode(treeSubPackagePathToFile, fileName);
    // end of fix of issue #51191
    
    Node node = new Node(prn,treeSubPackagePathToFile+treeSeparator+fileName);
    node.performPopupAction("Open");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:JavaTestCase.java

示例14: getGenericParameterTypeList

import java.util.StringTokenizer; //导入方法依赖的package包/类
/**
 * Convert a parameter like "Map&lt;Integer, URL&gt;" into an array,
 * something like [Integer, URL].
 * @param paramName The parameter declaration string
 * @return The array of generic types as strings
 */
private String[] getGenericParameterTypeList(String paramName)
{
    int openGeneric = paramName.indexOf('<');
    if (openGeneric == -1)
    {
        log.debug("No < in paramter declaration: " + paramName);
        return new String[0];
    }

    int closeGeneric = paramName.lastIndexOf('>');
    if (closeGeneric == -1)
    {
        log.error("Missing > in generic declaration: " + paramName);
        return new String[0];
    }

    String generics = paramName.substring(openGeneric + 1, closeGeneric);
    StringTokenizer st = new StringTokenizer(generics, ",");
    String[] types = new String[st.countTokens()];
    int i = 0;
    while (st.hasMoreTokens())
    {
        types[i++] = st.nextToken();
    }

    return types;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:34,代码来源:SignatureParser.java

示例15: tokenizeName

import java.util.StringTokenizer; //导入方法依赖的package包/类
/**
 * Tokenizes the composite name along colons, as well as {@link NameCodec#decode(String) demangles} and interns
 * the tokens. The first two tokens are not demangled as they are supposed to be the naming scheme and the name of
 * the operation which can be expected to consist of just alphabetical characters.
 * @param name the composite name consisting of colon-separated, possibly mangled tokens.
 * @return an array of tokens
 */
public static String[] tokenizeName(final String name) {
    final StringTokenizer tok = new StringTokenizer(name, CallSiteDescriptor.TOKEN_DELIMITER);
    final String[] tokens = new String[tok.countTokens()];
    for(int i = 0; i < tokens.length; ++i) {
        String token = tok.nextToken();
        if(i > 1) {
            token = NameCodec.decode(token);
        }
        tokens[i] = token.intern();
    }
    return tokens;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:CallSiteDescriptorFactory.java


注:本文中的java.util.StringTokenizer.countTokens方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。