List of usage examples for java.util StringTokenizer StringTokenizer
public StringTokenizer(String str, String delim)
From source file:fr.openwide.talendalfresco.alfresco.util.ContentDataUtil.java
/** * [talendalfresco] In comparison to ContentData.createContentProperty(), * if there is no mimetype it guesses it using the mimetypeService, therefore * not exploding if no mimetype.//from w w w .j av a 2 s .c om * * Construct a content property from a string * * @param contentPropertyStr the string representing the content details * @return Returns a bean version of the string */ public static ContentData createContentPropertyWithGuessedMimetype(String contentPropertyStr, MimetypeService mimetypeService) { String contentUrl = null; String mimetype = null; long size = 0L; String encoding = null; Locale locale = null; // now parse the string StringTokenizer tokenizer = new StringTokenizer(contentPropertyStr, "|"); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (token.startsWith("contentUrl=")) { contentUrl = token.substring(11); if (contentUrl.length() == 0) { contentUrl = null; } } else if (token.startsWith("mimetype=")) { mimetype = token.substring(9); if (mimetype.length() == 0) { mimetype = null; } } else if (token.startsWith("size=")) { String sizeStr = token.substring(5); if (sizeStr.length() > 0) { size = Long.parseLong(sizeStr); } } else if (token.startsWith("encoding=")) { encoding = token.substring(9); if (encoding.length() == 0) { encoding = null; } } else if (token.startsWith("locale=")) { String localeStr = token.substring(7); if (localeStr.length() > 0) { locale = I18NUtil.parseLocale(localeStr); } } } // [talendalfresco] if no mimetype, let's guess it if (mimetype == null) { mimetype = mimetypeService.guessMimetype(contentUrl); } ContentData property = new ContentData(contentUrl, mimetype, size, encoding, locale); // done return property; }
From source file:com.vmware.example.lucene.loader.InstrumentLineMapper.java
@Override public Instrument mapLine(String line, int lineNumber) throws Exception { StringTokenizer lineTokenizer = new StringTokenizer(line, "\t"); Instrument instr = new Instrument(lineTokenizer.nextToken(), lineTokenizer.nextToken()); return instr; }
From source file:Main.java
/** * Convert a full XML name to its generic name. This is done by checking if * each part of the name is complex (if it consists of a generic name plus a * specific name). If so, then the specific part is removed. Example of a * complex name : model.infrastructure.node-edge.spdata Result of * getGenericName : model.infrastructure.node.spdata * * @param name The XML name//from ww w.java 2 s . com * @param removeArrays Wether array elements have to be removed from the * name. * @return The result */ public static String getGenericName(String fullName, boolean removeArrays) { StringTokenizer s = new StringTokenizer(fullName, "."); String result = "", tmp; int dashIndex; while (s.hasMoreTokens()) { tmp = s.nextToken(); if (removeArrays && (("array").equals(tmp) || ("element").equals(tmp))) { continue; } if (result.length() > 0) { result += "."; } if ((dashIndex = tmp.indexOf('-')) == -1) { result += tmp; } else { result += tmp.substring(0, dashIndex); } } return result; }
From source file:net.grinder.util.VersionNumber.java
/** * Parses a string like "1.0.2" into the version number. * * @param num parameter string// w w w . j a v a 2s .c o m */ public VersionNumber(String num) { StringTokenizer tokens = new StringTokenizer(num, ".-_"); this.digits = new int[tokens.countTokens()]; if (this.digits.length < 2) { throw new IllegalArgumentException("Failed to parse " + num + " as version number"); } int i = 0; while (tokens.hasMoreTokens()) { String token = tokens.nextToken().toLowerCase(); if (token.equals("*")) { this.digits[i++] = 1000; } else if (StringUtils.startsWithIgnoreCase(token, "snapshot")) { this.digits[i - 1]--; //noinspection UnusedAssignment this.digits[i++] = 1000; break; } else { if (NumberUtils.isNumber(token)) { this.digits[i++] = Integer.parseInt(token); } } } }
From source file:Main.java
public static List parseTokenList(String tokenList) { List result = new ArrayList(); StringTokenizer tokenizer = new StringTokenizer(tokenList, " "); while (tokenizer.hasMoreTokens()) { result.add(tokenizer.nextToken()); }/*from w w w. j a v a 2 s. c o m*/ return result; }
From source file:Main.java
public static List<String> parseTokenList(String tokenList) { List<String> result = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(tokenList, " "); while (tokenizer.hasMoreTokens()) { result.add(tokenizer.nextToken()); }//from w ww . ja v a2 s . c om return result; }
From source file:com.sonatype.nexus.perftest.maven.CsvLogParser.java
@JsonCreator public CsvLogParser(@JsonProperty("logfile") File logfile) throws IOException { ArrayList<String> paths = new ArrayList<>(); try (BufferedReader br = new BufferedReader( new InputStreamReader(new GZIPInputStream(new FileInputStream(logfile))))) { String str;// w w w . j a va 2 s . c o m while ((str = br.readLine()) != null) { StringTokenizer st = new StringTokenizer(str, ","); paths.add(st.nextToken()); // full path } } this.paths = Collections.unmodifiableList(paths); }
From source file:com.vmware.example.lucene.loader.InstrumentPriceLineMapper.java
@Override public InstrumentPrice mapLine(String line, int lineNumber) throws Exception { StringTokenizer lineTokenizer = new StringTokenizer(line, ","); InstrumentPrice price = new InstrumentPrice(); price.setSymbol(lineTokenizer.nextToken()); price.setDate(formatter.parse(lineTokenizer.nextToken())); price.setHigh(Double.parseDouble(lineTokenizer.nextToken())); price.setLow(Double.parseDouble(lineTokenizer.nextToken())); price.setOpen(Double.parseDouble(lineTokenizer.nextToken())); price.setClose(Double.parseDouble(lineTokenizer.nextToken())); price.setVolume(Long.parseLong(lineTokenizer.nextToken())); return price; }
From source file:org.wso2.carbon.clustering.azure.domain.NetworkInterfaceProperties.java
public String getIPAddress() { StringTokenizer st = new StringTokenizer(getIpConfigurations().get(0).toString(), ","); String ip = null;/*w w w. j a v a2 s .co m*/ for (int i = 0; i < 5; i++) { ip = st.nextToken(); } ip = ip.substring(18); return ip; }
From source file:com.todev.rabbitmqmanagement.data.network.serialization.UserTagsDeserializer.java
@Override public List<User.Tag> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { String serialized = p.getText().trim(); StringTokenizer tokenizer = new StringTokenizer(serialized, ","); List<User.Tag> result = new ArrayList<>(); User.Tag tag = User.Tag.NONE;/*w w w . j a v a 2 s .co m*/ while (tokenizer.hasMoreElements()) { String token = tokenizer.nextToken(); try { tag = User.Tag.valueOf(token.toUpperCase()); } catch (IllegalArgumentException e) { // Leave none type as default. } if (!result.contains(tag)) { result.add(tag); } } return result; }