本文整理汇总了Java中java.util.StringTokenizer类的典型用法代码示例。如果您正苦于以下问题:Java StringTokenizer类的具体用法?Java StringTokenizer怎么用?Java StringTokenizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringTokenizer类属于java.util包,在下文中一共展示了StringTokenizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processBlockChainCommand
import java.util.StringTokenizer; //导入依赖的package包/类
private void processBlockChainCommand(DslCommand cmd) {
Block parent = world.getBlockByName(cmd.getArgument(0));
int k = 1;
while (cmd.getArgument(k) != null) {
String name = cmd.getArgument(k);
int difficulty = k;
if (name != null) {
StringTokenizer difficultyTokenizer = new StringTokenizer(name,":");
name = difficultyTokenizer.nextToken();
difficulty = difficultyTokenizer.hasMoreTokens()?parseDifficulty(difficultyTokenizer.nextToken(),k):k;
}
Block block = new BlockBuilder().difficulty(difficulty).parent(parent).build();
BlockExecutor executor = new BlockExecutor(ConfigHelper.CONFIG, world.getRepository(),
world.getBlockChain(), world.getBlockChain().getBlockStore(), null);
executor.executeAndFill(block, parent);
world.saveBlock(name, block);
parent = block;
k++;
}
}
示例2: buildPopupMenu
import java.util.StringTokenizer; //导入依赖的package包/类
protected JPopupMenu buildPopupMenu(JTextComponent target) {
JPopupMenu pm = createPopupMenu(target);
EditorUI ui = Utilities.getEditorUI(target);
String settingName = ui == null || ui.hasExtComponent()
? "popup-menu-action-name-list" //NOI18N
: "dialog-popup-menu-action-name-list"; //NOI18N
Preferences prefs = MimeLookup.getLookup(DocumentUtilities.getMimeType(target)).lookup(Preferences.class);
String actionNames = prefs.get(settingName, null);
if (actionNames != null) {
for(StringTokenizer t = new StringTokenizer(actionNames, ","); t.hasMoreTokens(); ) {
String action = t.nextToken().trim();
addAction(target, pm, action);
}
}
return pm;
}
示例3: getSuggestedFilename
import java.util.StringTokenizer; //导入依赖的package包/类
/**
* Returns a valid filename for the given filename. The assumed rules
* are that the name must be 8 characters long (padded on the end with
* spaces) and alphanumeric, starting with a character.
* @see com.webcodepro.applecommander.storage.FormattedDisk#getSuggestedFilename(java.lang.String)
*/
public String getSuggestedFilename(String filename) {
StringTokenizer tokenizer = new StringTokenizer(filename, "."); //$NON-NLS-1$
filename = tokenizer.nextToken(); // grab just the first part of the name..
StringBuffer newName = new StringBuffer();
if (!Character.isLetter(filename.charAt(0))) {
newName.append('A');
}
int i=0;
while (newName.length() < 8 && i<filename.length()) {
char ch = filename.charAt(i);
if (Character.isLetterOrDigit(ch) || ch == '.') {
newName.append(ch);
}
i++;
}
while (newName.length() < 8) newName.append(' ');
return newName.toString().toUpperCase().trim();
}
示例4: getSuggestedFiletype
import java.util.StringTokenizer; //导入依赖的package包/类
/**
* Returns a valid filetype for the given filename. Rules are very
* similar to the filename, but trim to 3 characters.
* @see com.webcodepro.applecommander.storage.FormattedDisk#getSuggestedFiletype(java.lang.String)
*/
public String getSuggestedFiletype(String filetype) {
StringTokenizer tokenizer = new StringTokenizer(filetype, "."); //$NON-NLS-1$
tokenizer.nextToken();
filetype = ""; //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
filetype = tokenizer.nextToken(); // grab just the last part of the name...
}
StringBuffer newType = new StringBuffer();
if (filetype.length() > 0 && !Character.isLetter(filetype.charAt(0))) {
newType.append('A');
}
int i=0;
while (newType.length() < 3 && i<filetype.length()) {
char ch = filetype.charAt(i);
if (Character.isLetterOrDigit(ch) || ch == '.') {
newType.append(ch);
}
i++;
}
while (newType.length() < 3) newType.append(' ');
return newType.toString().toUpperCase().trim();
}
示例5: extractStyle
import java.util.StringTokenizer; //导入依赖的package包/类
/**
* Extract the style value from a Inkscape encoded string
*
* @param style The style string to be decoded
* @param attribute The style attribute to retrieve
* @return The value for the given attribute
*/
static String extractStyle(String style, String attribute) {
if (style == null) {
return "";
}
StringTokenizer tokens = new StringTokenizer(style,";");
while (tokens.hasMoreTokens()) {
String token = tokens.nextToken();
String key = token.substring(0,token.indexOf(':'));
if (key.equals(attribute)) {
return token.substring(token.indexOf(':')+1);
}
}
return "";
}
示例6: main
import java.util.StringTokenizer; //导入依赖的package包/类
public static void main(String ... ags)throws IOException
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
int [][] arr = new int[n][2];
for(int i=0;i<n;i++)
{
StringTokenizer tk = new StringTokenizer(in.readLine());
int val = Integer.parseInt(tk.nextToken()) + Integer.parseInt(tk.nextToken());
arr[i][0] = val;
arr[i][1] = i+1;
}
Arrays.sort(arr, new Comparator<int[]>(){
@Override
public int compare(int[] ob1, int[] ob2)
{
if(ob1[0] != ob2[0])
return ob1[0] - ob2[0];
return ob1[1] - ob2[1];
}
});
for(int[] ob : arr)
System.out.print(ob[1]+" ");
}
示例7: split
import java.util.StringTokenizer; //导入依赖的package包/类
/**
* Splits stringToSplit into a list, using the given delimiter
*
* @param stringToSplit
* the string to split
* @param delimiter
* the string to split on
* @param trim
* should the split strings be whitespace trimmed?
*
* @return the list of strings, split by delimiter
*
* @throws IllegalArgumentException
*/
public static List<String> split(String stringToSplit, String delimiter, boolean trim) {
if (stringToSplit == null) {
return new ArrayList<String>();
}
if (delimiter == null) {
throw new IllegalArgumentException();
}
StringTokenizer tokenizer = new StringTokenizer(stringToSplit, delimiter, false);
List<String> splitTokens = new ArrayList<String>(tokenizer.countTokens());
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
if (trim) {
token = token.trim();
}
splitTokens.add(token);
}
return splitTokens;
}
示例8: prepareCommand
import java.util.StringTokenizer; //导入依赖的package包/类
private String[] prepareCommand(String firstFile, String secondFile) {
StringTokenizer tok = new StringTokenizer(diffcmd);
int tokensCount = tok.countTokens();
String[] cmdarray = new String[tokensCount];
for(int i=0;i<tokensCount;i++) {
String token = tok.nextToken();
if (token.equals("%TESTFILE%")) {
cmdarray[i] = firstFile;
} else if (token.equals("%PASSFILE%")) {
cmdarray[i] = secondFile;
} else {
cmdarray[i] = token;
}
}
return cmdarray;
}
示例9: decodeParameters
import java.util.StringTokenizer; //导入依赖的package包/类
protected Map<String, List<String>> decodeParameters(String queryString) {
Map<String, List<String>> parms = new HashMap<String, List<String>>();
if (queryString != null) {
StringTokenizer st = new StringTokenizer(queryString, "&");
while (st.hasMoreTokens()) {
String e = st.nextToken();
int sep = e.indexOf('=');
try {
String propertyName = (sep >= 0) ? decodePercent(
e.substring(0, sep)).trim() : decodePercent(e)
.trim();
if (!parms.containsKey(propertyName)) {
parms.put(propertyName, new ArrayList<String>());
}
String propertyValue = (sep >= 0) ? decodePercent(e
.substring(sep + 1)) : null;
if (propertyValue != null) {
parms.get(propertyName).add(propertyValue);
}
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
return parms;
}
示例10: findBootJars
import java.util.StringTokenizer; //导入依赖的package包/类
/** Scans path list for something that can be added to classpath.
* @param extensions null or path list
* @param sb buffer to put results to
*/
private static void findBootJars(final String extensions, final StringBuffer sb) {
if (extensions != null) {
for (StringTokenizer st = new StringTokenizer(extensions, File.pathSeparator); st.hasMoreTokens();) {
File dir = new File(st.nextToken());
File[] entries = dir.listFiles();
if (entries != null) {
for (int i = 0; i < entries.length; i++) {
String name = entries[i].getName().toLowerCase(Locale.US);
if (name.endsWith(".zip") || name.endsWith(".jar")) { // NOI18N
if (sb.length() > 0) {
sb.append(File.pathSeparatorChar);
}
sb.append(entries[i].getPath());
}
}
}
}
}
}
示例11: parseDimension
import java.util.StringTokenizer; //导入依赖的package包/类
private static Dimension parseDimension(String s) {
StringTokenizer st = new StringTokenizer(s, ","); // NOI18N
int arr[] = new int[2];
int i = 0;
while (st.hasMoreElements()) {
if (i > 1) {
return null;
}
try {
arr[i] = Integer.parseInt(st.nextToken());
} catch (NumberFormatException nfe) {
LOG.log(Level.WARNING, null, nfe);
return null;
}
i++;
}
if (i != 2) {
return null;
} else {
return new Dimension(arr[0], arr[1]);
}
}
示例12: getNestedPropertyType
import java.util.StringTokenizer; //导入依赖的package包/类
public static Class<?> getNestedPropertyType(Class<?> clazz, String nestedProperty)
throws IllegalArgumentException, SecurityException, IntrospectionException,
NoSuchMethodException {
Class<?> propertyType = null;
StringTokenizer st = new StringTokenizer(nestedProperty, ".", false);
while (st.hasMoreElements() && clazz != null) {
String nam = (String) st.nextElement();
Method readMethod = getReadMethod(clazz, nam);
if (readMethod != null) {
if (st.hasMoreElements()) {
clazz = readMethod.getReturnType();
}
else {
propertyType = readMethod.getReturnType();
}
}
else {
while (st.hasMoreElements()) {
st.nextElement(); // use remaining tokens
}
}
}
return propertyType;
}
示例13: setText
import java.util.StringTokenizer; //导入依赖的package包/类
/**
* Set the text, decoded as pairs of involvee - involvement
*
* @param text
*/
public void setText(String text)
{
PairedTextEncodedStringNullTerminated.ValuePairs value = new PairedTextEncodedStringNullTerminated.ValuePairs();
StringTokenizer stz = new StringTokenizer(text, "\0");
while (stz.hasMoreTokens())
{
String key =stz.nextToken();
if(stz.hasMoreTokens())
{
value.add(key, stz.nextToken());
}
}
setObjectValue(DataTypes.OBJ_TEXT, value);
}
示例14: getNestedProperty
import java.util.StringTokenizer; //导入依赖的package包/类
public static Object getNestedProperty(Object bean, String nestedProperty)
throws IllegalArgumentException, SecurityException, IllegalAccessException,
InvocationTargetException, IntrospectionException, NoSuchMethodException {
Object object = null;
StringTokenizer st = new StringTokenizer(nestedProperty, ".", false);
while (st.hasMoreElements() && bean != null) {
String nam = (String) st.nextElement();
if (st.hasMoreElements()) {
bean = getProperty(bean, nam);
}
else {
object = getProperty(bean, nam);
}
}
return object;
}
示例15: installPlugin
import java.util.StringTokenizer; //导入依赖的package包/类
@Override
public Broker installPlugin(Broker parent) throws Exception {
logger.info("Initialize JWTAuthenticationPlugin");
Set<Principal> groups = new HashSet();
StringTokenizer iter = new StringTokenizer(this.defaultUserGroups, ",");
while (iter.hasMoreTokens()) {
String name = iter.nextToken().trim();
groups.add(new GroupPrincipal(name));
}
JaasAuthenticationPlugin jaasAuthenticationPlugin = new JaasAuthenticationPlugin();
jaasAuthenticationPlugin.setConfiguration(this.jaasConfiguration);
jaasAuthenticationPlugin.setDiscoverLoginConfig(this.discoverLoginConfig);
Broker jaasAuthenticationFallbackBroker = jaasAuthenticationPlugin.installPlugin(parent);
return new JWTAuthenticationBroker(
parent, jaasAuthenticationFallbackBroker, this.defaultUser,
groups, this.masterSecretKey, this.tokenHeader);
}
开发者ID:hishamaborob,项目名称:ActiveMQ-JWT-Authentication-Plugin,代码行数:20,代码来源:JWTAuthenticationPlugin.java