當前位置: 首頁>>代碼示例>>Java>>正文


Java StreamTokenizer.TT_NUMBER屬性代碼示例

本文整理匯總了Java中java.io.StreamTokenizer.TT_NUMBER屬性的典型用法代碼示例。如果您正苦於以下問題:Java StreamTokenizer.TT_NUMBER屬性的具體用法?Java StreamTokenizer.TT_NUMBER怎麽用?Java StreamTokenizer.TT_NUMBER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.io.StreamTokenizer的用法示例。


在下文中一共展示了StreamTokenizer.TT_NUMBER屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toMessage

public String toMessage() {
    switch(ttype) {
    case StreamTokenizer.TT_EOL:
        return "\"EOL\"";
    case StreamTokenizer.TT_EOF:
        return "\"EOF\"";
    case StreamTokenizer.TT_NUMBER:
        return "NUMBER";
    case StreamTokenizer.TT_WORD:
        if (sval == null) {
            return "IDENTIFIER";
        } else {
            return "IDENTIFIER " + sval;
        }
    default:
        if (ttype == (int)'"') {
            String msg = "QUOTED STRING";
            if (sval != null)
                msg = msg + " \"" + sval + "\"";
            return msg;
        } else {
            return "CHARACTER \'" + (char)ttype + "\'";
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:Token.java

示例2: next

Token next() throws IOException {
  int type = tok.nextToken();
  switch (type) {
    case StreamTokenizer.TT_EOF:
    case StreamTokenizer.TT_EOL:
      return null;
    case StreamTokenizer.TT_NUMBER:
      return new NumToken(tok.nval);
    case StreamTokenizer.TT_WORD:
      return new StrToken(TType.IDENT, tok.sval);
    case '"':
      return new StrToken(TType.QUOT, tok.sval);
    default:
      switch (type) {
        case ',':
          return new Token(TType.COMMA);
        case '(':
          return new Token(TType.LPAREN);
        case ')':
          return new Token(TType.RPAREN);
        default:
          throw new IOException("Unexpected: " + type);
      }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:Parser.java

示例3: setJobTemplateCommand

private static void setJobTemplateCommand(JobTemplate jt, String line) throws IOException, DrmaaException {
	Reader r = new StringReader(line);
	StreamTokenizer tokenizer = new StreamTokenizer(r);
	tokenizer.quoteChar('"');
	tokenizer.quoteChar('\'');
	String cmd = null;
	List<String> args = new ArrayList<String>();
	for (int tok = tokenizer.nextToken(); tok != StreamTokenizer.TT_EOF; tok = tokenizer.nextToken()) {
		if (tok == StreamTokenizer.TT_WORD || tok == StreamTokenizer.TT_NUMBER) {
			if (cmd == null) {
				cmd = tokenizer.sval;
			}
			else {
				args.add(tokenizer.sval);
			}
		}
	}
	jt.setRemoteCommand(cmd);
	jt.setArgs(args);
}
 
開發者ID:Bibliome,項目名稱:bibliome-java-utils,代碼行數:20,代碼來源:FileJobSpecificationBuilder.java

示例4: parse

@Function(effects=IMMUTABLE, onNullInput=RETURNS_NULL)
public static ComplexScalar parse(String input, String typeName)
		throws SQLException {
	try {
		StreamTokenizer tz = new StreamTokenizer(new StringReader(input));
		if (tz.nextToken() == '('
				&& tz.nextToken() == StreamTokenizer.TT_NUMBER) {
			double x = tz.nval;
			if (tz.nextToken() == ','
					&& tz.nextToken() == StreamTokenizer.TT_NUMBER) {
				double y = tz.nval;
				if (tz.nextToken() == ')') {
					s_logger.info(typeName + " from string");
					return new ComplexScalar(x, y, typeName);
				}
			}
		}
		throw new SQLException("Unable to parse complex from string \""
				+ input + '"');
	} catch (IOException e) {
		throw new SQLException(e.getMessage());
	}
}
 
開發者ID:greenplum-db,項目名稱:pljava,代碼行數:23,代碼來源:ComplexScalar.java

示例5: getIntOrCP

/**
 * Read an int or codepoint - codepoint is given as a string
 */
private int getIntOrCP() throws IOException
{
    int val = tkn.nextToken();
    if (val == StreamTokenizer.TT_NUMBER)
    {
        return new Double(tkn.nval).intValue();
    }
    else if (val == StreamTokenizer.TT_WORD)
    {
        return decodeCP(tkn.sval);
    }
    else
    {
        fail("Expecting number, got " + tkn.sval + " on line "
                           + tkn.lineno());
        System.exit(1);
    }
    return 0;
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:22,代碼來源:TestProto.java

示例6: getIntOrCP

/**
 * Read an int or codepoint - codepoint is given as a string
 */
private int getIntOrCP() throws IOException
{
	int val = tkn.nextToken();
	if (val == StreamTokenizer.TT_NUMBER)
	{
		return new Double(tkn.nval).intValue();
	}
	else if (val == StreamTokenizer.TT_WORD)
	{
		return decodeCP(tkn.sval);
	}
	else
	{
		fail("Expecting number, got " + tkn.sval + " on line "
						   + tkn.lineno());
		System.exit(1);
	}
	return 0;
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:22,代碼來源:TestProto.java

示例7: parse

@Override
public ComputedAttributeParserState parse(StreamTokenizer st) throws IOException, ParseException
{
    ComputedAttributeParserState nextState = null;
    while(nextState == null && st.ttype != StreamTokenizer.TT_EOF)
    {
        int nextToken = st.nextToken();
        if (nextToken != StreamTokenizer.TT_EOL && nextToken != StreamTokenizer.TT_EOF)
        {
            switch(nextToken)
            {
                case '(':
                    nextState = new ExpressionBeginState(this.getParser());
                    break;
                case StreamTokenizer.TT_NUMBER:
                    throw new ParseException("unexpected number "+st.nval+" in expression "+this.getParser().getFormula()+" in "+this.getParser().getDiagnosticMessage());
                case StreamTokenizer.TT_WORD:
                    throw new ParseException("unexpected word "+st.sval+" in expression "+this.getParser().getFormula()+" in "+this.getParser().getDiagnosticMessage());
                default:
                    char ch = (char)st.ttype;
                    throw createUnexpectedCharacterException(ch, "(");
            }
        }
    }
    return nextState;
}
 
開發者ID:goldmansachs,項目名稱:reladomo,代碼行數:26,代碼來源:FunctionParameterBeginExpressionState.java

示例8: toString

public String toString() {
    StringBuilder sb = new StringBuilder();
    switch(ttype) {
    case StreamTokenizer.TT_EOL:
        sb.append("ttype=TT_EOL");
        break;
    case StreamTokenizer.TT_EOF:
        sb.append("ttype=TT_EOF");
        break;
    case StreamTokenizer.TT_NUMBER:
        sb.append("ttype=TT_NUM,").append("nval="+nval);
        break;
    case StreamTokenizer.TT_WORD:
        if (sval == null) {
            sb.append("ttype=TT_WORD:IDENTIFIER");
        } else {
            sb.append("ttype=TT_WORD:").append("sval="+sval);
        }
        break;
    default:
        if (ttype == (int)'"') {
            sb.append("ttype=TT_STRING:").append("sval="+sval);
        } else {
            sb.append("ttype=TT_CHAR:").append((char)ttype);
        }
        break;
    }
    return sb.toString();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:29,代碼來源:Token.java

示例9: parseData

public void parseData(StreamTokenizer st, int currentNumber, List<Object> rowValue) throws ParseException
{
    if (currentNumber >= this.headers.size())
    {
        throw new ParseException("extra data on line " + st.lineno(), st.lineno());
    }
    if (st.ttype == StreamTokenizer.TT_NUMBER)
    {
        rowValue.add(st.nval);
    }
    else
    {
        rowValue.add(st.sval);
    }
}
 
開發者ID:goldmansachs,項目名稱:tablasco,代碼行數:15,代碼來源:ExpectedTable.java

示例10: parseError

/**
 * Throws a formatted ParseException for the current token.
 * 
 * @param expected a description of what was expected
 * @throws ParseException
 * @throws com.vividsolutions.jts.util.AssertionFailedException if an
 *         invalid token is encountered
 */
private void parseError(String expected) throws ParseException {
    // throws Asserts for tokens that should never be seen
    if (tokenizer.ttype == StreamTokenizer.TT_NUMBER)
        Assert.shouldNeverReachHere("Unexpected NUMBER token");
    if (tokenizer.ttype == StreamTokenizer.TT_EOL)
        Assert.shouldNeverReachHere("Unexpected EOL token");

    String tokenStr = tokenString();
    throw new ParseException("Expected " + expected + " but found "
            + tokenStr);
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:19,代碼來源:EWKTReader.java

示例11: read

/** 	
* Read data from a MIX file.
* <p>	
* @return MixFileData a vector of MixTrackData elements
* @exception IOException is thrown if there is an error
 	* in the data.
*/
    public MixFileData read() throws IOException {
       String line;
       String mediaFileName = null;
       double times[] = { 0.0, 0.0 };

       MixFileData  v = new MixFileData();
       int token;
       int tokencnt;
       int linecnt = 0;

       while ((token = st.nextToken()) != StreamTokenizer.TT_EOF) {
           tokencnt = 0;
           while (token != StreamTokenizer.TT_EOL) {
                switch (token) {
                    case StreamTokenizer.TT_WORD:
                        if (tokencnt != 0) {
                            throw new IOException("Read error at line " + linecnt);
                        }
                        mediaFileName = st.sval;
                         break;
                    case StreamTokenizer.TT_NUMBER:
                        if (tokencnt < 1) {
                            throw new IOException("Read error at line " + linecnt);
                        }
                        times[tokencnt - 1] = st.nval;
                        break;
                 }
                 tokencnt++;

                 token = st.nextToken();
           }
           v.addTrackData(new MixTrackData(mediaFileName, times[0], times[1]));
           linecnt++;
       }
       fr.close();
       return v;
   }
 
開發者ID:champtar,項目名稱:fmj-sourceforge-mirror,代碼行數:44,代碼來源:MixFile.java

示例12: doCalc

protected void doCalc() throws IOException {
    int iType;
    double tmp;

    while ((iType = tf.nextToken()) != StreamTokenizer.TT_EOF) {
        switch(iType) {
        case StreamTokenizer.TT_NUMBER: // Found a number, push value to stack
            push(tf.nval);
            break;
        case StreamTokenizer.TT_WORD:
            // Found a variable, save its name. Not used here.
            variable = tf.sval;
            break;
        case '+':
            // + operator is commutative.
            push(pop() + pop());
            break;
        case '-':
            // - operator: order matters.
            tmp = pop();
            push(pop() - tmp);
            break;
        case '*':
            // Multiply is commutative
            push(pop() * pop());
            break;
        case '/':
            // Handle division carefully: order matters!
            tmp = pop();
            push(pop() / tmp);
            break;
        case '=':
            out.println(peek());
            break;
        default:
            out.println("What's this? iType = " + iType);
        }
    }
}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:39,代碼來源:SimpleCalcStreamTok.java

示例13: processFile

/**
 * Process a command file
 *
 * @param  filename
 * @exception     IOException, DRDAProtocolException     error reading file or protocol
 */
private void processFile(String filename)
    throws IOException, DRDAProtocolException
{
    String prev_filename = current_filename;
    current_filename = filename;
       String hostName=getHostName();
    BufferedReader fr;
    try {
        fr = new BufferedReader(new InputStreamReader(new FileInputStream(filename),"UTF-8"));
    } catch (FileNotFoundException fnfe) {
        // if useprocess=false & we're running in a suite, 
        // the location is different, try it
        String userdir =  System.getProperty("user.dir");
        String sep =  System.getProperty("file.separator");
        fr = new BufferedReader (new InputStreamReader(new FileInputStream(userdir + sep + filename),"UTF-8"));
    }
    tkn = new StreamTokenizer(fr);
    int val;
    while ( (val = tkn.nextToken()) != StreamTokenizer.TT_EOF)
    {
        switch(val)
        {
            case StreamTokenizer.TT_NUMBER:
                break;
            case StreamTokenizer.TT_WORD:
                processCommand();
                break;
            case StreamTokenizer.TT_EOL:
                break;
        }
    }
    current_filename = prev_filename;
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:39,代碼來源:TestProto.java

示例14: getString

/**
 * Read a string from the command file
 *
 * @return string found in file
 * @exception     IOException     error reading file
 */
private String getString() throws IOException
{
    int val = tkn.nextToken();
    if (val == StreamTokenizer.TT_NUMBER)
    {
        System.err.println("Expecting word, got " + tkn.nval + " on line " + tkn.lineno());
        System.exit(1);
    }
    return tkn.sval;
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:16,代碼來源:TestProto.java

示例15: parseBuiltInPredicate

private static Expr parseBuiltInPredicate(String lhs, StreamTokenizer scan) throws DatalogException {
    try {
        String operator;
        scan.nextToken();
        if(scan.ttype == StreamTokenizer.TT_WORD) {
            // At some point I was going to have "eq" and "ne" for string comparisons, but it wasn't a good idea.
            operator = scan.sval;
        } else {
            operator = Character.toString((char)scan.ttype);
            scan.nextToken();
            if(scan.ttype == '=' || scan.ttype == '>') {
                operator = operator + Character.toString((char)scan.ttype);
            } else {
                scan.pushBack();
            }
        }

        if(!validOperators.contains(operator)) {
            throw new DatalogException("Invalid operator '" + operator + "'");
        }

        String rhs = null;
        scan.nextToken();
        if(scan.ttype == StreamTokenizer.TT_WORD) {
            rhs = scan.sval;
        } else if(scan.ttype == '"' || scan.ttype == '\'') {
            rhs = scan.sval;
        } else if(scan.ttype == StreamTokenizer.TT_NUMBER) {
            rhs = numberToString(scan.nval);
        } else {
            throw new DatalogException("[line " + scan.lineno() + "] Right hand side of expression expected");
        }

        return new Expr(operator, lhs, rhs);

    } catch (IOException e) {
        throw new DatalogException(e);
    }
}
 
開發者ID:wernsey,項目名稱:Jatalog,代碼行數:39,代碼來源:Parser.java


注:本文中的java.io.StreamTokenizer.TT_NUMBER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。