本文整理匯總了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);
}