本文整理汇总了Java中java.io.StreamTokenizer.lineno方法的典型用法代码示例。如果您正苦于以下问题:Java StreamTokenizer.lineno方法的具体用法?Java StreamTokenizer.lineno怎么用?Java StreamTokenizer.lineno使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.StreamTokenizer
的用法示例。
在下文中一共展示了StreamTokenizer.lineno方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseBenchArgs
import java.io.StreamTokenizer; //导入方法依赖的package包/类
String[] parseBenchArgs(StreamTokenizer tokens)
throws IOException, ConfigFormatException
{
Vector vec = new Vector();
for (;;) {
switch (tokens.ttype) {
case StreamTokenizer.TT_EOF:
case StreamTokenizer.TT_EOL:
return (String[]) vec.toArray(new String[vec.size()]);
case StreamTokenizer.TT_WORD:
case '"':
vec.add(tokens.sval);
tokens.nextToken();
break;
default:
throw new ConfigFormatException("unrecognized arg token " +
"on line " + tokens.lineno());
}
}
}
示例2: parseBenchWeight
import java.io.StreamTokenizer; //导入方法依赖的package包/类
float parseBenchWeight(StreamTokenizer tokens)
throws IOException, ConfigFormatException
{
float weight;
switch (tokens.ttype) {
case StreamTokenizer.TT_WORD:
case '"':
try {
weight = Float.parseFloat(tokens.sval);
} catch (NumberFormatException e) {
throw new ConfigFormatException("illegal weight value \"" +
tokens.sval + "\" on line " + tokens.lineno());
}
tokens.nextToken();
return weight;
default:
throw new ConfigFormatException("missing weight value on line "
+ tokens.lineno());
}
}
示例3: parseBenchName
import java.io.StreamTokenizer; //导入方法依赖的package包/类
String parseBenchName(StreamTokenizer tokens)
throws IOException, ConfigFormatException
{
String name;
switch (tokens.ttype) {
case StreamTokenizer.TT_WORD:
case '"':
name = tokens.sval;
tokens.nextToken();
return name;
default:
throw new ConfigFormatException("missing benchmark name on " +
"line " + tokens.lineno());
}
}
示例4: parseBenchClass
import java.io.StreamTokenizer; //导入方法依赖的package包/类
Benchmark parseBenchClass(StreamTokenizer tokens)
throws IOException, ConfigFormatException
{
Benchmark bench;
switch (tokens.ttype) {
case StreamTokenizer.TT_WORD:
case '"':
try {
Class cls = Class.forName(tokens.sval);
bench = (Benchmark) cls.newInstance();
} catch (Exception e) {
throw new ConfigFormatException("unable to instantiate " +
"benchmark \"" + tokens.sval + "\" on line " +
tokens.lineno());
}
tokens.nextToken();
return bench;
default:
throw new ConfigFormatException("missing benchmark class " +
"name on line " + tokens.lineno());
}
}
示例5: parseMaterialStream
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/**
* Parses a map of appearances parsed from the given stream.
*/
private static Map<String, Appearance> parseMaterialStream(Reader reader, URL baseUrl, Boolean useCaches)
throws IOException
{
Map<String, Appearance> appearances = new HashMap<String, Appearance>();
Appearance currentAppearance = null;
StreamTokenizer tokenizer = createTokenizer(reader);
while (tokenizer.nextToken() != StreamTokenizer.TT_EOF)
{
switch (tokenizer.ttype)
{
case StreamTokenizer.TT_WORD:
currentAppearance = parseMaterialLine(tokenizer, appearances, currentAppearance, baseUrl,
useCaches);
break;
case StreamTokenizer.TT_EOL:
break;
default:
throw new IncorrectFormatException(
"Unexpected token " + tokenizer.sval + " at row " + tokenizer.lineno());
}
}
return appearances;
}
示例6: parseInteger
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/**
* Returns the integer contained in the next token.
*/
private static int parseInteger(StreamTokenizer tokenizer) throws IOException
{
if (tokenizer.nextToken() != StreamTokenizer.TT_WORD)
{
throw new IncorrectFormatException("Expected an integer at line " + tokenizer.lineno());
}
else
{
try
{
return Integer.parseInt(tokenizer.sval);
}
catch (NumberFormatException ex)
{
throw new IncorrectFormatException(
"Found " + tokenizer.sval + " instead of an integer at line " + tokenizer.lineno());
}
}
}
示例7: getNextToken
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/** Delivers the next token and checks for an unexpected end of line or file. */
public static void getNextToken(StreamTokenizer tokenizer) throws IOException {
if (tokenizer.nextToken() == StreamTokenizer.TT_EOL) {
throw new IOException("unexpected end of line " + tokenizer.lineno());
}
if (tokenizer.ttype == StreamTokenizer.TT_EOF) {
throw new IOException("unexpected end of file in line " + tokenizer.lineno());
} else if (tokenizer.ttype == '\'' || tokenizer.ttype == '"') {
tokenizer.ttype = StreamTokenizer.TT_WORD;
} else if (tokenizer.ttype == StreamTokenizer.TT_WORD && tokenizer.sval.equals("?")) {
tokenizer.ttype = '?';
}
}
示例8: getNextToken
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/**
* Gets next token, checking for a premature and of line.
*
* @throws IllegalStateException if it finds a premature end of line
*/
private void getNextToken(StreamTokenizer tokenizer) throws IOException, ParseException {
if (tokenizer.nextToken() == StreamTokenizer.TT_EOL) {
throw new ParseException("premature end of line", tokenizer.lineno());
}
if (tokenizer.ttype == StreamTokenizer.TT_EOF) {
throw new ParseException(PREMATURE_END_OF_FILE, tokenizer.lineno());
} else if ((tokenizer.ttype == '\'') || (tokenizer.ttype == '"')) {
tokenizer.ttype = StreamTokenizer.TT_WORD;
} else if ((tokenizer.ttype == StreamTokenizer.TT_WORD) && (tokenizer.sval.equals("?"))) {
tokenizer.ttype = '?';
}
}
示例9: parse
import java.io.StreamTokenizer; //导入方法依赖的package包/类
@Override
public ParserState parse(StreamTokenizer st) throws IOException, ParseException
{
int token = st.ttype;
while (!endOfLineOrFile(token))
{
//token 1: key
st.nextToken();
if (!endOfLineOrFile(token))
{
String key = st.sval;
//token 2: value
token = st.nextToken();
if (endOfLineOrFile(token))
{
throw new ParseException("Expected a value for metadata key: " + key, st.lineno());
}
String value = st.sval;
this.getParser().getExpectedResults().addMetadata(key, value);
//token 3: EOL or ,
token = st.nextToken();
if (!endOfLineOrFile(token) && token != (int) ',')
{
throw new ParseException("Expected EOL or EOF or a comma on line " + st.lineno(), st.lineno());
}
}
}
return this.getParser().getBeginningOfLineState();
}
示例10: parseAttributes
import java.io.StreamTokenizer; //导入方法依赖的package包/类
private void parseAttributes(StreamTokenizer st) throws IOException, ParseException
{
int token = st.nextToken();
boolean wantAttribute = true;
while (token != StreamTokenizer.TT_EOL)
{
if (wantAttribute)
{
if (token != StreamTokenizer.TT_WORD && token != QUOTE_TOKEN)
{
throw new ParseException("expected an column name on line " + st.lineno(), st.lineno());
}
this.getParser().getExpectedTable().addColumnHeader(st.sval);
}
else
{
if (token != ',')
{
throw new ParseException("Expected a comma on line " + st.lineno(), st.lineno());
}
}
wantAttribute = !wantAttribute;
token = st.nextToken();
}
if (wantAttribute)
{
throw new ParseException("extra comma at the end of line " + st.lineno(), st.lineno());
}
}
示例11: parse
import java.io.StreamTokenizer; //导入方法依赖的package包/类
@Override
public ParserState parse(StreamTokenizer st) throws IOException, ParseException
{
int token = st.ttype;
if (token != StreamTokenizer.TT_WORD || !st.sval.equals(ExpectedResultsParser.SECTION_IDENTIFIER))
{
throw new ParseException("expected line " + st.lineno() + " to begin with Section", st.lineno());
}
token = st.nextToken();
if (token != StreamTokenizer.TT_WORD && token != '"')
{
throw new ParseException("expected a section name on line " + st.lineno(), st.lineno());
}
String testName = st.sval;
token = st.nextToken();
String tableName = null;
if (token == StreamTokenizer.TT_WORD || token == '"')
{
tableName = st.sval;
token = st.nextToken();
}
this.getParser().startNewSection(testName, tableName);
if (token != StreamTokenizer.TT_EOL)
{
throw new ParseException("invalid data after the class name on line " + st.lineno(), st.lineno());
}
return this.getParser().getHeaderState();
}
示例12: parse
import java.io.StreamTokenizer; //导入方法依赖的package包/类
@Override
public ParserState parse(StreamTokenizer st) throws IOException, ParseException
{
if (this.sectionName == null)
{
throw new ParseException("no section name found before line " + st.lineno(), st.lineno());
}
// parse the data
int currentAttribute = 0;
int token = st.ttype;
boolean wantData = true;
List<Object> rowValue = FastList.newList();
while (token != StreamTokenizer.TT_EOL && token != StreamTokenizer.TT_EOF)
{
if (wantData)
{
this.getParser().getExpectedTable().parseData(st, currentAttribute, rowValue);
currentAttribute++;
}
else
{
if (token != ',')
{
throw new ParseException("Expected a comma on line " + st.lineno(), st.lineno());
}
}
wantData = !wantData;
token = st.nextToken();
}
if (Iterate.notEmpty(rowValue))
{
this.getParser().getExpectedTable().addRowToList(rowValue);
}
return this.getParser().getBeginningOfLineState();
}
示例13: parseData
import java.io.StreamTokenizer; //导入方法依赖的package包/类
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);
}
}
示例14: parse
import java.io.StreamTokenizer; //导入方法依赖的package包/类
public ParserState parse(StreamTokenizer st) throws IOException, ParseException
{
int token = st.ttype;
if (token != StreamTokenizer.TT_WORD || !st.sval.equals(AbstractMithraDataFileParser.CLASS_IDENTIFIER))
{
throw new ParseException("expected line " + st.lineno() + " to begin with class", st.lineno());
}
token = st.nextToken();
if (token != StreamTokenizer.TT_WORD)
{
throw new ParseException("expected a class name on line "+st.lineno(), st.lineno());
}
this.getParser().addNewMithraParsedData();
String className = st.sval;
try
{
this.getParser().getCurrentParsedData().setParsedClassName(className);
}
catch (Exception e)
{
ParseException parseException = new ParseException("no such class (or finder): "+className+" on line "+st.lineno(), st.lineno());
parseException.initCause(e);
throw parseException;
}
this.getParser().getDataReaderState().setClass(className, st.lineno());
token = st.nextToken();
if (token != StreamTokenizer.TT_EOL)
{
throw new ParseException("invalid data after the class name on line "+st.lineno(), st.lineno());
}
return this.getParser().getAttributeReaderState();
}
示例15: parseData
import java.io.StreamTokenizer; //导入方法依赖的package包/类
public void parseData(StreamTokenizer st, int attributeNumber, Object currentData) throws ParseException
{
if (attributeNumber >= this.attributes.size())
{
throw new ParseException("extra data on line "+st.lineno(),st.lineno());
}
Attribute attribute = this.attributes.get(attributeNumber);
int token = st.ttype;
switch (token)
{
case StreamTokenizer.TT_NUMBER:
attribute.parseNumberAndSet(st.nval, currentData, st.lineno());
break;
case StreamTokenizer.TT_WORD:
String word = st.sval;
attribute.parseWordAndSet(word, currentData, st.lineno());
break;
case '"':
attribute.parseStringAndSet(st.sval, currentData, st.lineno(), simpleDateFormat);
break;
case StreamTokenizer.TT_EOL:
throw new RuntimeException("should never get here");
case StreamTokenizer.TT_EOF:
throw new ParseException("Unexpected end of file", st.lineno());
default:
char ch = (char)st.ttype;
throw new ParseException("unexpected character "+ch+" on line "+st.lineno()+" attribute count "+attributeNumber, st.lineno());
}
}