本文整理汇总了Java中java.io.StreamTokenizer.slashSlashComments方法的典型用法代码示例。如果您正苦于以下问题:Java StreamTokenizer.slashSlashComments方法的具体用法?Java StreamTokenizer.slashSlashComments怎么用?Java StreamTokenizer.slashSlashComments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.StreamTokenizer
的用法示例。
在下文中一共展示了StreamTokenizer.slashSlashComments方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JaasConfig
import java.io.StreamTokenizer; //导入方法依赖的package包/类
public JaasConfig(String loginContextName, String jaasConfigParams) {
StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(jaasConfigParams));
tokenizer.slashSlashComments(true);
tokenizer.slashStarComments(true);
tokenizer.wordChars('-', '-');
tokenizer.wordChars('_', '_');
tokenizer.wordChars('$', '$');
try {
configEntries = new ArrayList<>();
while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
configEntries.add(parseAppConfigurationEntry(tokenizer));
}
if (configEntries.isEmpty())
throw new IllegalArgumentException("Login module not specified in JAAS config");
this.loginContextName = loginContextName;
} catch (IOException e) {
throw new KafkaException("Unexpected exception while parsing JAAS config");
}
}
示例2: parse
import java.io.StreamTokenizer; //导入方法依赖的package包/类
private Void parse(Reader reader) throws ParseException, IOException
{
StreamTokenizer st = new StreamTokenizer(reader);
st.eolIsSignificant(true);
st.wordChars((int) '_', (int) '_');
st.parseNumbers();
st.quoteChar((int) '"');
// These calls caused comments to be discarded
st.slashSlashComments(true);
st.slashStarComments(true);
// Parse the file
ParserState currentState = this.getBeginningOfLineState();
while (currentState != null)
{
currentState = currentState.parse(st);
}
return null;
}
示例3: readConfig
import java.io.StreamTokenizer; //导入方法依赖的package包/类
private void readConfig(Reader reader, HashMap newConfig)
throws IOException {
if (!(reader instanceof BufferedReader))
reader = new BufferedReader(reader);
st = new StreamTokenizer(reader);
st.quoteChar('"');
st.wordChars('$', '$');
st.wordChars('_', '_');
st.wordChars('-', '-');
st.lowerCaseMode(false);
st.slashSlashComments(true);
st.slashStarComments(true);
st.eolIsSignificant(true);
lookahead = nextToken();
while (lookahead != StreamTokenizer.TT_EOF) {
parseLoginEntry(newConfig);
}
}
示例4: setSyntax
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/**
* This method sets the syntax of the StreamTokenizer. i.e. set the
* whitespace, comment and delimit chars.
*
*/
protected void setSyntax(StreamTokenizer tk) {
tk.resetSyntax();
tk.eolIsSignificant(false);
tk.slashStarComments(true);
tk.slashSlashComments(true);
tk.whitespaceChars(0, ' ');
tk.wordChars(' ' + 1, '\u00ff');
tk.ordinaryChar('[');
tk.ordinaryChar(']');
tk.ordinaryChar('{');
tk.ordinaryChar('}');
tk.ordinaryChar('-');
tk.ordinaryChar('>');
tk.ordinaryChar('/');
tk.ordinaryChar('*');
tk.quoteChar('"');
tk.whitespaceChars(';', ';');
tk.ordinaryChar('=');
}
示例5: SimpleCalcStreamTok
import java.io.StreamTokenizer; //导入方法依赖的package包/类
/** Construct from an existing Reader */
public SimpleCalcStreamTok(Reader rdr) throws IOException {
tf = new StreamTokenizer(rdr);
// Control the input character set:
tf.slashSlashComments(true); // treat "//" as comments
tf.ordinaryChar('-'); // used for subtraction
tf.ordinaryChar('/'); // used for division
s = new Stack();
}
示例6: normalize
import java.io.StreamTokenizer; //导入方法依赖的package包/类
public static String normalize(String sql, boolean removeComments) {
if (removeComments)
sql = sql.replace("--", "//");
StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(sql));
tokenizer.resetSyntax();
tokenizer.wordChars('A', 'Z');
tokenizer.wordChars('a', 'z');
tokenizer.wordChars('0', '9');
tokenizer.wordChars('_', '_');
tokenizer.whitespaceChars(' ', ' ');
tokenizer.whitespaceChars('\n', '\n');
tokenizer.whitespaceChars('\r', '\r');
tokenizer.whitespaceChars('\t', '\t');
tokenizer.quoteChar('\'');
tokenizer.quoteChar('"');
if (removeComments) {
tokenizer.slashStarComments(true);
tokenizer.slashSlashComments(true);
}
StringBuilder builder = new StringBuilder();
int lastTtype = StreamTokenizer.TT_EOF;
try {
while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
int ttype = tokenizer.ttype;
if (builder.length() > 0 // insert space if this is not the beginning of the string
&& ttype != ')' && ttype != ',' && lastTtype != '(' // no space for brackets and lists
&& lastTtype != '.' && ttype != '.' // no space around '.'
&& !(lastTtype == '/' && ttype =='*') // preserve /* if it has not been filtered out
&& !(lastTtype == '-' && ttype =='-') // preserve -- if it has not been filtered out
&& !(lastTtype == '*' && ttype =='/')) // preserve */ if it has not been filtered out
builder.append(' ');
switch (ttype) {
case StreamTokenizer.TT_WORD: builder.append(tokenizer.sval); break;
case StreamTokenizer.TT_NUMBER: builder.append(renderNumber(tokenizer)); break;
case '"': builder.append('"').append(tokenizer.sval).append('"'); break;
case '\'': builder.append('\'').append(tokenizer.sval).append('\''); break;
default: builder.append((char) ttype);
}
lastTtype = ttype;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return builder.toString();
}
示例7: configureTokenizer
import java.io.StreamTokenizer; //导入方法依赖的package包/类
private static void configureTokenizer(StreamTokenizer tokenizer) {
tokenizer.wordChars('_', '_');
tokenizer.slashSlashComments(true);
tokenizer.slashStarComments(true);
}