本文整理汇总了Java中java.util.StringTokenizer.hasMoreElements方法的典型用法代码示例。如果您正苦于以下问题:Java StringTokenizer.hasMoreElements方法的具体用法?Java StringTokenizer.hasMoreElements怎么用?Java StringTokenizer.hasMoreElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.StringTokenizer
的用法示例。
在下文中一共展示了StringTokenizer.hasMoreElements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stringToBounds
import java.util.StringTokenizer; //导入方法依赖的package包/类
static Rectangle stringToBounds(final String bounds) throws NumberFormatException {
StringTokenizer st = new StringTokenizer(bounds, " ,"); // NOI18N
int x, y, width, height;
x = y = width = height =0;
for (int i = 0; i < 4; i++) {
if (!st.hasMoreElements()) {
throw new NumberFormatException();
}
switch (i) {
case 0:
x = Integer.parseInt(st.nextToken());
break;
case 1:
y = Integer.parseInt(st.nextToken());
break;
case 2:
width = Integer.parseInt(st.nextToken());
break;
case 3:
height = Integer.parseInt(st.nextToken());
break;
}
}
return new Rectangle(x,y,width,height);
}
示例2: stringToKeys
import java.util.StringTokenizer; //导入方法依赖的package包/类
/** Convert a space-separated list of user-friendly key binding names to a list of Swing key strokes.
* @param s the string with keys
* @return array of key strokes, or <code>null</code> if the string description is not valid
* @see #stringToKey
*/
public static KeyStroke[] stringToKeys(String s) {
StringTokenizer st = new StringTokenizer(s.toUpperCase(Locale.ENGLISH), " "); // NOI18N
ArrayList<KeyStroke> arr = new ArrayList<KeyStroke>();
while (st.hasMoreElements()) {
s = st.nextToken();
KeyStroke k = stringToKey(s);
if (k == null) {
return null;
}
arr.add(k);
}
return arr.toArray(new KeyStroke[arr.size()]);
}
示例3: updateOuners
import java.util.StringTokenizer; //导入方法依赖的package包/类
public void updateOuners() {
List<Qualifier> cls = dataPlugin.getEngine().getQualifiers();
for (int i = cls.size() - 1; i >= 0; i--) {
if (IDEF0Plugin.isFunction(cls.get(i)))
cls.remove(i);
}
Collections.sort(cls, new Comparator<Qualifier>() {
Collator collator = Collator.getInstance();
@Override
public int compare(Qualifier o1, Qualifier o2) {
return collator.compare(o1.getName(), o2.getName());
}
});
cls.remove(dataPlugin.getBaseFunction());
clasificators = cls.toArray(new Qualifier[cls.size()]);
String s = dataPlugin.getProperty(DataPlugin.PROPERTY_OUNERS);
if (s == null)
s = "";
final StringTokenizer st = new StringTokenizer(s, " ");
while (st.hasMoreElements()) {
owners.add(Long.parseLong(st.nextToken()));
}
model.fireTableDataChanged();
}
示例4: extractPathSessionId
import java.util.StringTokenizer; //导入方法依赖的package包/类
protected String extractPathSessionId(String url) {
String sessionId = null;
int iStart = url.indexOf(SESSION_PARAMETER_START);
if (iStart > -1) {
iStart += SESSION_PARAMETER_START.length();
String remainder = url.substring(iStart);
StringTokenizer parser = new StringTokenizer(remainder,
SESSION_PATH_PARAMETER_TAILS);
if (parser.hasMoreElements()) {
sessionId = parser.nextToken();
}
else {
sessionId = url.substring(iStart);
}
}
return sessionId;
}
示例5: setTagsAsString
import java.util.StringTokenizer; //导入方法依赖的package包/类
public void setTagsAsString(String tags) {
// Convert comma separated list into list
StringTokenizer tok = new StringTokenizer(tags, ",");
List<String> list = new ArrayList<String>();
while (tok.hasMoreElements()) {
String tagValue = tok.nextElement().toString().trim();
if (tagValue.length() > 0)
list.add(tagValue.trim());
}
vo.setTags(list);
}
示例6: getRules
import java.util.StringTokenizer; //导入方法依赖的package包/类
/**
* De-tokenize the elements listed in the 'elements' attribute and
* instanciate a set of strip/preserve rules.
*/
public Vector getRules() {
final Vector rules = new Vector();
// Go through each element and instanciate strip/preserve-object
final StringTokenizer list = new StringTokenizer(_elementList);
while (list.hasMoreElements()) {
rules.add(new WhitespaceRule(_action,
list.nextToken(),
_importPrecedence));
}
return rules;
}
示例7: createBlocksFromLines
import java.util.StringTokenizer; //导入方法依赖的package包/类
public void createBlocksFromLines() {
final JTextArea textArea = new JTextArea();
BaseDialog dialog = new BaseDialog(getPanel().getFramework()
.getMainFrame()) {
@Override
protected void onOk() {
if (textArea.getText().trim().length() > 0) {
StringTokenizer st = new StringTokenizer(
textArea.getText(), "\n");
List<String> strings = new ArrayList<String>();
while (st.hasMoreElements()) {
String s = st.nextToken().trim();
if (s.length() > 0)
strings.add(s);
}
startUserTransaction();
createBlocks(strings.toArray(new String[strings.size()]));
commitUserTransaction();
super.onOk();
}
}
};
dialog.setMainPane(new JScrollPane(textArea));
ResourceLoader.setJComponentsText(dialog);
dialog.setBounds(0, 0, 800, 600);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
}
示例8: parseRows
import java.util.StringTokenizer; //导入方法依赖的package包/类
private int[] parseRows(String s) {
String rowText = "";
int i = s.indexOf("rows:");
if (i != -1) {
int j = s.indexOf("columns:");
if (j == -1) {
rowText = s.substring(i + 5);
} else {
rowText = s.substring(i + 5, j);
}
int k = rowText.indexOf('[');
int l = rowText.indexOf(']');
rowText = rowText.substring(k + 1, l);
}
StringTokenizer tokenizer = new StringTokenizer(rowText, ", ");
List<String> rows = new ArrayList<String>();
while (tokenizer.hasMoreElements()) {
rows.add(tokenizer.nextToken());
}
int irows[] = new int[rows.size()];
for (int j = 0; j < irows.length; j++) {
try {
irows[j] = Integer.parseInt(rows.get(j));
} catch (Throwable t) {
return new int[0];
}
}
return irows;
}
示例9: buildSchemaLocationMap
import java.util.StringTokenizer; //导入方法依赖的package包/类
/**
* Build schema location map of schemas used in given <code>schemaLocationAttribute</code> and
* adds them to the given <code>schemaLocationMap</code>.
*
* @see <a href="http://www.w3.org/TR/xmlschema-0/#schemaLocation">XML Schema Part 0: Primer
* Second Edition | 5.6 schemaLocation</a>
*
* @param schemaLocationMap {@link Map} to add schema locations to.
* @param schemaLocation attribute value to build schema location map from.
* @return {@link Map} of schema namespace URIs to location URLs.
* @since GemFire 8.1
*/
static final Map<String, List<String>> buildSchemaLocationMap(
Map<String, List<String>> schemaLocationMap, final String schemaLocation) {
if (null == schemaLocation) {
return schemaLocationMap;
}
if (null == schemaLocation || schemaLocation.isEmpty()) {
// should really ever be null but being safe.
return schemaLocationMap;
}
final StringTokenizer st = new StringTokenizer(schemaLocation, " \n\t\r");
while (st.hasMoreElements()) {
final String ns = st.nextToken();
final String loc = st.nextToken();
List<String> locs = schemaLocationMap.get(ns);
if (null == locs) {
locs = new ArrayList<>();
schemaLocationMap.put(ns, locs);
}
if (!locs.contains(loc)) {
locs.add(loc);
}
}
return schemaLocationMap;
}
示例10: jButton2ActionPerformed
import java.util.StringTokenizer; //导入方法依赖的package包/类
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
jLabel1.setText(jComboBox1.getSelectedItem().toString());
String satir = "[0]|1|[2]|4|3";
StringTokenizer st = new StringTokenizer(satir, "|");
while (st.hasMoreElements()) {
String mytoken1 = st.nextElement().toString();
if(!(mytoken1.contains("[") || mytoken1.contains("]")))
{
System.out.println(mytoken1);
}
// StringTokenizer st2 = new StringTokenizer(mytoken1, " ");
// while (st2.hasMoreElements()) {
// String mytoken2 = st2.nextElement().toString();
// // System.out.println(mytoken2);
// mytoken2 = mytoken2.replace("[", "").replace("]", "");
// System.out.println(mytoken2);
// }
}
}
示例11: ComputePosPolarimots
import java.util.StringTokenizer; //导入方法依赖的package包/类
public int ComputePosPolarimots(String tweet) throws FileNotFoundException, IOException, TreeTaggerException{
int count=0;
String lemme;
StringTokenizer st = new StringTokenizer(tweet, " .,;:'\"|()?!-_/<>‘’“”…«»•&#{[|`^@]}$*%1234567890", false);
while (st.hasMoreElements()){
lemme=st.nextToken();
if(lemme.contains("|")) lemme=lemme.split("|")[0];
if (alPosPolarimots.contains(lemme)) count++;
}
return count;
}
示例12: Negate
import java.util.StringTokenizer; //导入方法依赖的package包/类
public static String Negate(String tweet) throws FileNotFoundException, IOException{
boolean Sepa=false, Nega=false;
String s, tok;
ArrayList<String> Neg = new ArrayList<>();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
//BufferedReader r = new BufferedReader(new InputStreamReader(classLoader.getResourceAsStream("Negations.txt")));
BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream("ressources//Negations.txt")));
while ((s=r.readLine())!=null) Neg.add(s);
r.close();
StringTokenizer st = new StringTokenizer(tweet, " \n .,;:'‘’\"?[]!-_\\/“<>$&®´…«»1234567890", true);
boolean start=false, end=false;
s="";
while (st.hasMoreElements()){
Nega=false;
Sepa=false;
tok=st.nextElement().toString();
if (s.length()>=1 && !s.endsWith(" ")) s+=" ";
for (String n:Neg) if (tok.equals(n)){
start=true;
Nega=true;
}
if (tok.equals(".") || tok.equals(",") || tok.equals(";") || tok.equals("?") || tok.equals("!") || tok.equals(":") || tok.equals("(") || tok.equals(")")){
end=true;
Sepa=true;
}
for (String se:sep) if(se.equals(tok)) Sepa=true;
if (!Sepa) {
s+=tok;
if (start && !end && !Nega) s+="_neg";
}
}
return s;
}
示例13: registerTestLibraryTypeProvider
import java.util.StringTokenizer; //导入方法依赖的package包/类
private static void registerTestLibraryTypeProvider () throws Exception {
StringTokenizer tk = new StringTokenizer("org-netbeans-api-project-libraries/LibraryTypeProviders","/");
FileObject root = FileUtil.getConfigRoot();
while (tk.hasMoreElements()) {
String pathElement = tk.nextToken();
FileObject tmp = root.getFileObject(pathElement);
if (tmp == null) {
tmp = root.createFolder(pathElement);
}
root = tmp;
}
if (root.getChildren().length == 0) {
InstanceDataObject.create (DataFolder.findFolder(root),"TestLibraryTypeProvider",TestLibraryTypeProvider.class);
}
}
示例14: toIntegerList
import java.util.StringTokenizer; //导入方法依赖的package包/类
public static List<Integer> toIntegerList(String str, String regex) {
StringTokenizer t = new StringTokenizer(str, regex);
List<Integer> l = new ArrayList<Integer>();
while (t.hasMoreElements()) {
String s = t.nextToken();
if (isNotBlank(s)) {
l.add(Integer.parseInt(s));
}
}
return l;
}
示例15: addJarsToSkip
import java.util.StringTokenizer; //导入方法依赖的package包/类
private static void addJarsToSkip(String systemPropertyName) {
String jarList = System.getProperty(systemPropertyName);
if (jarList != null) {
StringTokenizer tokenizer = new StringTokenizer(jarList, ",");
while (tokenizer.hasMoreElements()) {
String token = tokenizer.nextToken().trim();
if (token.length() > 0) {
pluggabilityJarsToSkip.add(token);
}
}
}
}