List of usage examples for java.util StringTokenizer StringTokenizer
public StringTokenizer(String str, String delim)
From source file:org.openvpms.component.business.domain.im.security.ArchetypeAwareGrantedAuthority.java
/** * Construct an instance given the string representation of the * authority//from w w w . j av a2 s . co m * * @param str a stringified version of the authority */ public ArchetypeAwareGrantedAuthority(String str) { StringTokenizer tokens = new StringTokenizer(str, ":"); if (tokens.countTokens() != 3) { throw new GrantedAuthorityException(GrantedAuthorityException.ErrorCode.InvalidGrantAuthorityFormat, new Object[] { str }); } // the first token must be the prefix if (!tokens.nextToken().equals(prefix)) { throw new GrantedAuthorityException(GrantedAuthorityException.ErrorCode.InvalidPrefix); } // the second token is the service and the method. The service // cannot have any wildcards but the method can. StringTokenizer temp = new StringTokenizer(tokens.nextToken(), "."); if (temp.countTokens() != 2) { throw new GrantedAuthorityException(GrantedAuthorityException.ErrorCode.InvalidServiceMethodFormat, new Object[] { temp }); } serviceName = temp.nextToken(); method = temp.nextToken(); archetypeShortName = tokens.nextToken(); // store the original str this.authority = str; }
From source file:com.glaf.oa.paymentplan.web.springmvc.PaymentplanController.java
@ResponseBody @RequestMapping("/delete") public void delete(HttpServletRequest request, ModelMap modelMap) { Long planid = RequestUtils.getLong(request, "planid"); String planids = request.getParameter("planids"); if (StringUtils.isNotEmpty(planids)) { StringTokenizer token = new StringTokenizer(planids, ","); while (token.hasMoreTokens()) { String x = token.nextToken(); if (StringUtils.isNotEmpty(x)) { Paymentplan paymentplan = paymentplanService.getPaymentplan(Long.valueOf(x)); /**/*ww w . ja va2 s. c om*/ * */ if (paymentplan != null) { paymentplanService.deleteById((paymentplan.getPlanid())); } } } } else if (planid != null) { Paymentplan paymentplan = paymentplanService.getPaymentplan(Long.valueOf(planid)); /** * */ if (paymentplan != null) { paymentplanService.deleteById((paymentplan.getPlanid())); } } }
From source file:br.com.anteros.sms.modem.IPModemDriver.java
protected IPModemDriver(ModemGateway myGateway, String deviceParms) { super(myGateway, deviceParms); StringTokenizer tokens = new StringTokenizer(deviceParms, ":"); this.ipAddress = tokens.nextToken(); this.ipPort = Integer.parseInt(tokens.nextToken()); this.tc = null; }
From source file:com.glaf.oa.travelfee.web.springmvc.TravelfeeController.java
@ResponseBody @RequestMapping("/delete") public void delete(HttpServletRequest request, ModelMap modelMap) { Long feeid = RequestUtils.getLong(request, "feeid"); String feeids = request.getParameter("feeids"); if (StringUtils.isNotEmpty(feeids)) { StringTokenizer token = new StringTokenizer(feeids, ","); while (token.hasMoreTokens()) { String x = token.nextToken(); if (StringUtils.isNotEmpty(x)) { Travelfee travelfee = travelfeeService.getTravelfee(Long.valueOf(x)); /**// ww w . j a va2s . com * */ if (travelfee != null) { // travelfee.setDeleteFlag(1); travelfeeService.deleteById(Long.valueOf(x)); } } } } else if (feeid != null) { Travelfee travelfee = travelfeeService.getTravelfee(Long.valueOf(feeid)); /** * */ if (travelfee != null) { // travelfee.setDeleteFlag(1); travelfeeService.deleteById(feeid); } } }
From source file:ClassPath.java
private static final void getPathComponents(String path, List list) { if (path != null) { StringTokenizer tok = new StringTokenizer(path, File.pathSeparator); while (tok.hasMoreTokens()) { String name = tok.nextToken(); File file = new File(name); if (file.exists()) { list.add(name);/*w w w. java 2s.c o m*/ } } } }
From source file:org.inbio.ait.model.SystemUser.java
@Override public GrantedAuthority[] getAuthorities() { StringTokenizer st = new StringTokenizer(this.getRoles(), ROLE_DELIMITER); GrantedAuthorityImpl[] grantedAuthorityImplArray = new GrantedAuthorityImpl[st.countTokens()]; for (int i = 0; st.hasMoreElements(); i++) grantedAuthorityImplArray[i] = new GrantedAuthorityImpl(st.nextToken()); return grantedAuthorityImplArray; }
From source file:Email.CommonsEmail.java
/** * funo para enviar email/*from w w w .ja v a 2 s . c om*/ * * @param titulo * @param msgEmail * @param emailDestinatarios * @return */ public boolean enviarEmail(String titulo, String msgEmail, String emailDestinatarios) { boolean enviado = false; String para = emailDestinatarios.toLowerCase().trim(); String subject = titulo.trim(); String msg = msgEmail.trim(); try { StringTokenizer stPara = new StringTokenizer(para, ";"); while (stPara.hasMoreTokens()) { if (!stPara.toString().trim().equals("")) { HtmlEmail email = new HtmlEmail(); /*o servidor SMTP para envio do e-mail*/ email.setHostName(emailConfig.getHostname()); email.setSmtpPort(emailConfig.getPorta()); email.setSSLOnConnect(emailConfig.getSsl()); email.setStartTLSEnabled(emailConfig.getTsl()); /*remetente*/ email.setFrom(emailConfig.getEmail(), emailConfig.getNome()); email.setAuthentication(emailConfig.getUsuario(), emailConfig.getSenha()); /* ---------------------------------------------------------- */ //destinatrio //email.addTo(emailDestinatario, nomeDestinatario); email.addTo(stPara.nextToken().trim()); // assunto do e-mail email.setSubject(subject); //conteudo do e-mail //configura a mensagem para o formato HTML email.setHtmlMsg(msg); // configure uma mensagem alternativa caso o servidor no suporte HTML email.setTextMsg("Seu servidor de e-mail no suporta mensagem HTML"); // envia email email.send(); enviado = true; } } } catch (EmailException ex) { enviado = false; Logger.getLogger(CommonsEmail.class.getName()).log(Level.SEVERE, null, ex); } return enviado; }
From source file:de.iteratec.iteraplan.db.SqlScriptExecutor.java
public static List<String> readSqlScript(InputStream in) { InputStream setupSqlInputStream = in; String sqlString = null;/*from ww w. j a v a2 s .co m*/ try { sqlString = IOUtils.toString(setupSqlInputStream); } catch (IOException fnfe) { LOGGER.error("unable to read data."); } finally { if (setupSqlInputStream != null) { try { setupSqlInputStream.close(); } catch (IOException e) { LOGGER.error("Cannot close stream for setupSqlFile", e); } } } List<String> sqlStatements = Lists.newArrayList(); StringTokenizer tokenizer = new StringTokenizer(sqlString, ";"); while (tokenizer.hasMoreTokens()) { String nextToken = tokenizer.nextToken(); sqlStatements.add(nextToken); } return sqlStatements; }
From source file:eu.ggnet.dwoss.util.gen.NameGenerator.java
public NameGenerator() throws RuntimeException { R = new Random(); businessEntities = new ArrayList<>(); namesFemaleFirst = new ArrayList<>(); namesMaleFirst = new ArrayList<>(); namesLast = new ArrayList<>(); streets = new ArrayList<>(); towns = new ArrayList<>(); Map<String, List<String>> sources = new HashMap<>(); sources.put("de_businesses.txt", businessEntities); sources.put("de_names_female_first.txt", namesFemaleFirst); sources.put("de_names_male_first.txt", namesMaleFirst); sources.put("de_names_last.txt", namesLast); sources.put("de_streets.txt", streets); sources.put("de_towns.txt", towns); for (String resource : sources.keySet()) { // load txt files. try (InputStream in = this.getClass().getResourceAsStream(resource)) { String all = IOUtils.toString(in, "UTF-8"); List<String> data = sources.get(resource); for (StringTokenizer st = new StringTokenizer(all, "\n"); st.hasMoreTokens();) { String s = st.nextToken(); data.add(s);/*from ww w. j a v a 2s. c o m*/ } } catch (IOException e) { throw new RuntimeException(e); } } }
From source file:com.cburch.logisim.util.LocaleManager.java
private static HashMap<Character, String> fetchReplaceAccents() { HashMap<Character, String> ret = null; String val; try {/* w w w. j av a 2 s . co m*/ val = LocaleString.getUtilLocaleManager().locale.getString("accentReplacements"); } catch (MissingResourceException e) { return null; } StringTokenizer toks = new StringTokenizer(val, "/"); while (toks.hasMoreTokens()) { String tok = toks.nextToken().trim(); char c = '\0'; String s = null; if (tok.length() == 1) { c = tok.charAt(0); s = ""; } else if (tok.length() >= 2 && tok.charAt(1) == ' ') { c = tok.charAt(0); s = tok.substring(2).trim(); } if (s != null) { if (ret == null) ret = new HashMap<Character, String>(); ret.put(new Character(c), s); } } return ret; }