当前位置: 首页>>代码示例>>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;未经允许,请勿转载。