StringTokenizer countTokens - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for StringTokenizer countTokens method.

This code example shows how to use the following methods:countTokens, nextToken
         errorCode = ERR_PROTOCOL_INCORRECT;
         errorMessage = "Identd server closed connection.";
         return; 
      } 
 
      StringTokenizer st = new StringTokenizer(response,":");
      if(st.countTokens() < 3){
         errorCode = ERR_PROTOCOL_INCORRECT;
         errorMessage = "Can't parse server response.";
         return; 
      } 
 
      st.nextToken(); //Discard first token, it's basically what we have send
      String command = st.nextToken().trim().toUpperCase();
 
      if(command.equals("USERID") && st.countTokens() >= 2){
        successful = true;
        hostType = st.nextToken().trim();
        userName = st.nextToken("").substring(1);//Get all that is left
      }else if(command.equals("ERROR")){

7
CodeRank
This code example shows how to use the following methods:countTokens, nextToken
     * @param value The value to be parsed 
     * @throws IllegalArgumentException If the passed <code>value</code> cannot be 
     *                                  represented as an {@link IncrementValue} 
     */ 
    public IncrementValue(String value) {
        StringTokenizer tokenizer = new StringTokenizer(value, INCREMENT_SEPARATOR);
        int numberOfTokens = tokenizer.countTokens();
        if (numberOfTokens != 2) {
            throw MESSAGES.invalidIncrementValue(value);
        } 
 
        this.start = tokenizer.nextToken().trim();
        this.interval = tokenizer.nextToken().trim();
    } 
 
    /** 
     * Returns the start of this {@link IncrementValue} 
     * 
     * @return 
     */ 
8
CodeRank
This code example shows how to use the following methods:countTokens, hasMoreTokens, nextToken
    private int minLevel = 4;
    private int maxNumberOfLogs = -1;
 
    public LogOptions(String commandLine)
    { 
        StringTokenizer st = new StringTokenizer(commandLine);
        readOptions(st);
    } 
 
    private void readOptions(StringTokenizer st)
    { 
        if (st.countTokens() > 1)
        { 
            st.nextToken();
            String firstOption = st.nextToken();
            checkOption(firstOption);
 
            if (st.hasMoreTokens())
            { 
                checkOption(st.nextToken());

6
CodeRank
This code example shows how to use the following methods:countTokens, nextToken
    public static GLatLngBounds parse(String value)
    { 
        StringTokenizer tokenizer;
        try 
        { 
            tokenizer = new StringTokenizer(value, "(, )");
        } 
        catch (NullPointerException e)
        { 
            return null; 
        } 
        if (tokenizer.countTokens() != 4)
        { 
            return null; 
        } 
 
        GLatLng sw = new GLatLng(Float.valueOf(tokenizer.nextToken()), Float.valueOf(tokenizer.nextToken()));
        GLatLng ne = new GLatLng(Float.valueOf(tokenizer.nextToken()), Float.valueOf(tokenizer.nextToken()));
        return new GLatLngBounds(sw, ne);
    } 

6
CodeRank
This code example shows how to use the following methods:countTokens, nextToken
        String id = elem.getAttribute("id");
 
        if (null == id || "".equals(id)) {
            String names = elem.getAttribute("name");
            if (null != names) {
                StringTokenizer st = new StringTokenizer(names, ",");
                if (st.countTokens() > 0) {
                    id = st.nextToken();
                } 
            } 
        } 
        return id;
    } 
     
    public MutableBeanMetadata createBeanMetadata(Element element, ParserContext context, Class<?> runtimeClass) {
        MutableBeanMetadata answer = context.createMetadata(MutableBeanMetadata.class);
        answer.setRuntimeClass(runtimeClass);
        answer.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
        answer.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
        // set the Bean scope to be prototype, so we can get a new instance per looking up 
6
CodeRank
This code example shows how to use the following methods:countTokens, nextToken
			   //no rows empty cursor 
			   return; 
			} 
 
			final String street = cur.getString(cur.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredPostal.FORMATTED_ADDRESS));
			StringTokenizer token=new StringTokenizer(street, ",");
			boolean latlong=false;
			String latitude=null;
			String longitude=null;
			if(token.countTokens()==2){
				String temp=token.nextToken();
				if(temp.startsWith("loc:")){
					temp=temp.substring(4);
				} 
				 if (temp.trim().matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")) {  
			            latitude=temp.trim();
			        }  
				 temp=token.nextToken();
				 if(temp.trim().matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")){
					 longitude= temp.trim();

6
CodeRank
This code example shows how to use the following methods:countTokens, nextToken
        column_ = null;
        alias_ = null;
        form_ = FORM_COLUMN;
        form_ = i;
        strform_ = new String(s);
        StringTokenizer stringtokenizer = new StringTokenizer(s, ".");
        switch(stringtokenizer.countTokens())
        { 
        case 1: // '\001' 
            if(i == FORM_TABLE)
                table_ = new String(stringtokenizer.nextToken());
            else 
                column_ = new String(stringtokenizer.nextToken());
            break; 
 
        case 2: // '\002' 
            if(i == FORM_TABLE)
            { 
                schema_ = new String(stringtokenizer.nextToken());
                table_ = new String(stringtokenizer.nextToken());

6
CodeRank
This code example shows how to use the following methods:countTokens, hasMoreTokens, nextToken
        return "install bundle(s)."; 
    } 
 
    public void execute(String s, PrintStream out, PrintStream err)
    { 
        StringTokenizer st = new StringTokenizer(s, " ");
 
        // Ignore the command name. 
        st.nextToken();
 
        // There should be at least one URL. 
        if (st.countTokens() >= 1)
        { 
            StringBuffer sb = new StringBuffer();
            while (st.hasMoreTokens())
            { 
                String location = st.nextToken().trim();
                Bundle bundle = install(location, out, err);
                if (bundle != null)
                { 

6
CodeRank
This code example shows how to use the following methods:countTokens, nextToken
        String initialSize = optionFor(name);
        if (initialSize == null) {
            initialSize = IsisContext.getConfiguration().getString(name);
        } 
        if (initialSize != null) {
            final StringTokenizer st = new StringTokenizer(initialSize, "x");
            if (st.countTokens() == 2) {
                int width = 0;
                int height = 0;
                width = Integer.valueOf(st.nextToken().trim()).intValue();
                height = Integer.valueOf(st.nextToken().trim()).intValue();
                return new Size(width, height);
            } else { 
                throw new IsisConfigurationException("Size not specified correctly in " + name + ": " + initialSize);
            } 
        } 
        return defaultSize;
    } 
 
    public static void saveSizeOption(final String name, final Size size) {
6
CodeRank
This code example shows how to use the following methods:countTokens, nextToken
     * 
     * @param weightRangeString the value range string 
     * @return an <code>FontWeightRange</code> object holding the value ranges 
     */ 
    public static FontWeightRange valueOf(String weightRangeString) {
        StringTokenizer rangeToken = new StringTokenizer(weightRangeString, "..");
        FontWeightRange weightRange = null;
        if (rangeToken.countTokens() == 2) {
            String weightString = rangeToken.nextToken().trim();
            try { 
                int start = Integer.parseInt(weightString);
                if (start % 100 != 0) {
                    log.error("font-weight start range is not a multiple of 100"); 
                } 
                int end = Integer.parseInt(rangeToken.nextToken());
                if (end % 100 != 0) {
                    log.error("font-weight end range is not a multiple of 100"); 
                } 
                if (start <= end) {
                    weightRange = new FontWeightRange(start, end);
6
CodeRank

Related StringTokenizer countTokens Questions & Answers:

countTokens Method Overview
Calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.
See Code Examples for other Java 8 StringTokenizer Methods: