List of usage examples for java.util StringTokenizer countTokens
public int countTokens()
From source file:nl.vu.psy.rite.Rite.java
private Rite() { version = Rite.class.getPackage().getImplementationVersion(); StringTokenizer st = null; if (version != null) { st = new StringTokenizer(version, "_"); } else {// w ww.j av a 2s . c o m st = new StringTokenizer(""); version = "undetermined"; } System.out.println(); System.out.println("+-++-++-++-+"); System.out.print("|R||i||t||e|"); if (version != null && st.countTokens() >= 2) { System.out.print(" version: " + st.nextToken() + " build " + st.nextToken() + "\n"); } else { System.out.print(" version: " + version + "\n"); } System.out.println("+-++-++-++-+"); System.out.println(); properties = new Properties(); try { properties.load(new FileInputStream(new File(PROPERTIES))); } catch (Exception e1) { // Absorb System.out.println( "Could not read properties files. Assuming programmed default values for client settings."); } identifier = getProperty(PropertyKeys.ID); System.out.println("Rite identifier: " + identifier); startDate = new Date(); long appLife = Long.parseLong(getProperty(PropertyKeys.LIFETIME)); endDate = new Date(startDate.getTime() + appLife); System.out.println("Application start time: " + TimeStamp.dateToString(startDate)); System.out.println("Configured application end time: " + TimeStamp.dateToString(endDate)); System.out.println("Setting up file cache..."); // TODO make file cache optional // Set up file cache try { fileCache = new FileCache(getProperty(PropertyKeys.RELIC)); } catch (RiteException e) { System.out.println("Could not set up file cache: " + e.getMessage()); run = false; } // Initialize info struct System.out.println("Initializing client info..."); ClientInfo info = new ClientInfo(); info.setClientId(identifier); try { InetAddress addr = InetAddress.getLocalHost(); String host = addr.getHostName(); info.setClientHost(host); } catch (UnknownHostException e) { info.setClientHost("Unknown: " + e.getMessage()); } info.setClientStart(startDate); info.setWorkingDirectory(new File(System.getProperty("user.dir"))); System.out.println("Configuring host connection..."); rh = null; try { boolean listfiles = Boolean.parseBoolean(getProperty(PropertyKeys.LISTFILES)); rh = new Host(getProperty(PropertyKeys.HOST), info, listfiles); } catch (RiteException e) { System.out.println("Could not connect to the rite host: " + e.getMessage()); run = false; } // Set up recipecooker recipeTimer = new Timer("recipeTimer", false); recipeCooker = new RecipeCooker(); long tickRate = Long.parseLong(getProperty(PropertyKeys.TICK)); recipeTimer.scheduleAtFixedRate(recipeCooker, 1000, tickRate); }
From source file:org.rapidandroid.activity.FormReviewer.java
private void doCsvDirectBednetsInjection() { String rawMessageText = ""; try {//from w w w . jav a2 s . c om InputStream is = this.getAssets().open("testdata/rawdata.csv"); int size = is.available(); // Read the entire asset into a local byte buffer. byte[] buffer = new byte[size]; is.read(buffer); is.close(); // Convert the buffer into a Java string. String text = new String(buffer); rawMessageText = text; } catch (IOException e) { // Should never happen! throw new RuntimeException(e); } StringReader sr = new StringReader(rawMessageText); BufferedReader bufRdr = new BufferedReader(sr); String line = null; // int row = 0; // int col = 0; Vector<String[]> lines = new Vector<String[]>(); // read each line of text file try { while ((line = bufRdr.readLine()) != null) { StringTokenizer st = new StringTokenizer(line, ","); int tokCount = st.countTokens(); String[] tokenizedLine = new String[tokCount]; int toki = 0; while (st.hasMoreTokens()) { tokenizedLine[toki] = st.nextToken(); toki++; } lines.add(tokenizedLine); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { sr.close(); bufRdr.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } int len = lines.size(); for (int i = 0; i < len; i++) { String[] csvline = lines.get(i); String datestr = csvline[0]; Date dateval = new Date(); try { dateval = Message.SQLDateFormatter.parse(datestr); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } String sender = csvline[1]; String text = csvline[2]; Monitor monitor = MessageTranslator.GetMonitorAndInsertIfNew(this, sender); ContentValues messageValues = new ContentValues(); messageValues.put(RapidSmsDBConstants.Message.MESSAGE, text); messageValues.put(RapidSmsDBConstants.Message.MONITOR, monitor.getID()); messageValues.put(RapidSmsDBConstants.Message.TIME, Message.SQLDateFormatter.format(dateval)); messageValues.put(RapidSmsDBConstants.Message.RECEIVE_TIME, Message.SQLDateFormatter.format(dateval)); messageValues.put(RapidSmsDBConstants.Message.IS_OUTGOING, false); Uri msgUri = null; msgUri = this.getContentResolver().insert(RapidSmsDBConstants.Message.CONTENT_URI, messageValues); Vector<IParseResult> results = ParsingService.ParseMessage(mForm, text); ParsedDataTranslator.InsertFormData(this, mForm, Integer.valueOf(msgUri.getPathSegments().get(1)).intValue(), results); } }
From source file:gov.nih.nci.caintegrator.application.gpvisualizer.CaIntegratorRunVisualizer.java
protected String[] doCommandLineSubstitutions() throws IOException { // do input argument substitution in command line String commandLine = (String) params.get(RunVisualizerConstants.COMMAND_LINE); HashMap hmDownloadables = downloadInputURLs(); StringTokenizer stCmd = new StringTokenizer(commandLine, " "); ArrayList cmdArray = new ArrayList(stCmd.countTokens()); int c = 0;/* w w w. j a v a 2 s.com*/ while (stCmd.hasMoreTokens()) { cmdArray.add(stCmd.nextToken()); } // replace variables in the command line from System.properties and the // params HashMap for (c = 0; c < cmdArray.size(); c++) { String cmd = (String) cmdArray.get(c); cmd = variableSubstitution(cmd, hmDownloadables); cmdArray.set(c, cmd); // if there is nothing in a slot after substitutions, delete the // slot entirely if (cmd.length() == 0) { cmdArray.remove(c); c--; } } cmdArray.trimToSize(); return (String[]) cmdArray.toArray(new String[0]); }
From source file:egovframework.oe1.cms.sys.service.impl.EgovOe1ConsentManageServiceImpl.java
/** * ? - ?/*ww w . j av a 2s . c o m*/ * @param submitVO * ?? * @return ? * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#actionSanctionDrafting(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public String actionSanctionDrafting(EgovOe1SanctionSubmitVO submitVO) throws Exception { String drftSn = egovIdGnrService.getNextStringId(); log.debug(this.getClass() + " actionSanctionDrafting() submitVO : " + submitVO.toString()); String currentDate = EgovDateUtil.getCurrentDateAsString() + EgovDateUtil.getCurrentHourAsString() + EgovDateUtil.getCurrentMinuteAsString() + EgovDateUtil.getCurrentSecondAsString(); submitVO.setDrftDt(currentDate); submitVO.setDrftSn(drftSn); consentManageDAO.insertSanctionDraftWriting(submitVO); // ? Table? log.debug(this.getClass() + submitVO.getSanctnRouteId()); StringTokenizer stRouteId = new StringTokenizer(submitVO.getSanctnRouteId(), "|"); int routeIdCnt = stRouteId.countTokens(); String receiver[] = new String[routeIdCnt]; for (int i = 0; stRouteId.hasMoreTokens(); i++) receiver[i] = stRouteId.nextToken(); StringTokenizer stRouteSeCode = new StringTokenizer(submitVO.getSanctnRouteSeCode(), "|"); int routeSeCodeCnt = stRouteSeCode.countTokens(); String aprvlGb[] = new String[routeSeCodeCnt]; for (int i = 0; stRouteSeCode.hasMoreTokens(); i++) aprvlGb[i] = stRouteSeCode.nextToken(); log.debug(this.getClass() + " routeIdCnt is " + routeIdCnt); boolean firstConfirm = false; for (int i = 0; i < routeIdCnt; i++) { EgovOe1SanctionConsentVO sanctionConsentVO = new EgovOe1SanctionConsentVO(); sanctionConsentVO.setDrftSn(drftSn); sanctionConsentVO.setConfmOrdr(i + 1); if (aprvlGb[i].equals("1")) { // sanctionConsentVO.setDrftDt(currentDate); // sanctionConsentVO.setConfmDt(currentDate); // ? sanctionConsentVO.setConfmOpinion(submitVO.getDrftOpinion()); sanctionConsentVO.setSanctnTrgtYn("N"); } else if (aprvlGb[i].equals("2")) { if (!firstConfirm) { firstConfirm = true; sanctionConsentVO.setDrftDt(currentDate); sanctionConsentVO.setSanctnTrgtYn("Y"); } else { sanctionConsentVO.setDrftDt(""); sanctionConsentVO.setSanctnTrgtYn("N"); } sanctionConsentVO.setConfmDt(""); sanctionConsentVO.setConfmOpinion(""); } else { sanctionConsentVO.setDrftDt(""); sanctionConsentVO.setConfmDt(""); sanctionConsentVO.setConfmOpinion(""); sanctionConsentVO.setSanctnTrgtYn("N"); } sanctionConsentVO.setConfmResultCode(""); sanctionConsentVO.setConfmer(receiver[i]); sanctionConsentVO.setConfmSeCode(aprvlGb[i]); sanctionConsentVO.setConfmComptYn("N"); sanctionConsentVO.setDeleteYn("N"); sanctionConsentVO.setAtchFileId(""); consentManageDAO.insertSanctionConsent(sanctionConsentVO); } // Callback Method try { /* * ApplicationContext ctx = new * ClassPathXmlApplicationContext(new * String[] * {"egovframework/spring/context-*.xml"}); */ ApplicationContext ctx = getApplicationContext(); EgovOe1ConsentCallbackService callbackService = (EgovOe1ConsentCallbackService) ctx .getBean(submitVO.getJobClass()); callbackService.draftingConsent(submitVO); } catch (ClassNotFoundException e) { log.error(this.getClass() + " Callback - ? ? : " + e.toString()); } catch (Exception e) { log.info(this.getClass() + " Callback : " + e.toString()); } return String.valueOf(drftSn); }
From source file:cz.fi.muni.xkremser.editor.server.config.EditorConfiguration.java
/** * Gets the user access patterns./*w w w . j ava2 s .c om*/ * * @return the user access patterns */ public String[] getUserAccessPatterns() { String property = getConfiguration().getString(ServerConstants.ACCESS_USER_PATTERNS, ServerConstants.ACCESS_USER_PATTERNS_DEFAULT); StringTokenizer st = new StringTokenizer(property, ServerConstants.ACCESS_PATTERN_SEPARATOR, false); String[] returnVal = new String[st.countTokens()]; int i = 0; while (st.hasMoreTokens()) { returnVal[i++] = st.nextToken(); } return returnVal; }
From source file:cz.fi.muni.xkremser.editor.server.config.EditorConfiguration.java
/** * Gets the admin access patterns.//from w w w . j a v a 2s.c om * * @return the admin access patterns */ public String[] getAdminAccessPatterns() { String property = getConfiguration().getString(ServerConstants.ACCESS_ADMIN_PATTERNS, ServerConstants.ACCESS_ADMIN_PATTERNS_DEFAULT); StringTokenizer st = new StringTokenizer(property, ServerConstants.ACCESS_PATTERN_SEPARATOR, false); String[] returnVal = new String[st.countTokens()]; int i = 0; while (st.hasMoreTokens()) { returnVal[i++] = st.nextToken(); } return returnVal; }
From source file:egovframework.oe1.cms.sys.service.impl.EgovOe1ConsentManageServiceImpl.java
/** * ? - /*from w w w. ja v a2s . c o m*/ * @param submitVO * ?? * @return ? * @throws Exception * @see egovframework.mgt.cmm.consent.service.EgovConsentManageService#actionSanctionDraftingUpdt(egovframework.mgt.cmm.consent.service.SanctionSubmitVO) */ public String actionSanctionDraftingUpdt(EgovOe1SanctionSubmitVO submitVO) throws Exception { String currentDate = EgovDateUtil.getCurrentDateAsString() + EgovDateUtil.getCurrentHourAsString() + EgovDateUtil.getCurrentMinuteAsString() + EgovDateUtil.getCurrentSecondAsString(); submitVO.setDrftDt(currentDate); int resultUpdateSanctionDraftWriting = consentManageDAO.updateSanctionDraftWriting(submitVO); int resultdeleteSanctionConsent = consentManageDAO.deleteSanctionConsent(submitVO.getDrftSn()); log.debug(this.getClass() + " resultUpdateSanctionDraftWriting : " + resultUpdateSanctionDraftWriting); log.debug(this.getClass() + " resultdeleteSanctionConsent : " + resultdeleteSanctionConsent); // ? Table? log.debug(this.getClass() + " submitVO.getSanctnRouteId() : " + submitVO.getSanctnRouteId()); StringTokenizer stRouteId = new StringTokenizer(submitVO.getSanctnRouteId(), "|"); int routeIdCnt = stRouteId.countTokens(); String receiver[] = new String[routeIdCnt]; for (int i = 0; stRouteId.hasMoreTokens(); i++) receiver[i] = stRouteId.nextToken(); StringTokenizer stRouteSeCode = new StringTokenizer(submitVO.getSanctnRouteSeCode(), "|"); int routeSeCodeCnt = stRouteSeCode.countTokens(); String aprvlGb[] = new String[routeSeCodeCnt]; for (int i = 0; stRouteSeCode.hasMoreTokens(); i++) aprvlGb[i] = stRouteSeCode.nextToken(); log.debug(this.getClass() + " routeIdCnt : " + routeIdCnt); boolean firstConfirm = false; for (int i = 0; i < routeIdCnt; i++) { EgovOe1SanctionConsentVO sanctionConsentVO = new EgovOe1SanctionConsentVO(); sanctionConsentVO.setDrftSn(submitVO.getDrftSn()); sanctionConsentVO.setConfmOrdr(i + 1); if (aprvlGb[i].equals("1")) { // sanctionConsentVO.setDrftDt(currentDate); // sanctionConsentVO.setConfmDt(currentDate); // ? sanctionConsentVO.setConfmOpinion(submitVO.getDrftOpinion()); sanctionConsentVO.setSanctnTrgtYn("N"); } else if (aprvlGb[i].equals("2")) { if (!firstConfirm) { firstConfirm = true; sanctionConsentVO.setDrftDt(currentDate); sanctionConsentVO.setSanctnTrgtYn("Y"); } else { sanctionConsentVO.setDrftDt(""); sanctionConsentVO.setSanctnTrgtYn("N"); } sanctionConsentVO.setConfmDt(""); sanctionConsentVO.setConfmOpinion(""); } else { sanctionConsentVO.setDrftDt(""); sanctionConsentVO.setConfmDt(""); sanctionConsentVO.setConfmOpinion(""); sanctionConsentVO.setSanctnTrgtYn("N"); } sanctionConsentVO.setConfmResultCode(""); sanctionConsentVO.setConfmer(receiver[i]); sanctionConsentVO.setConfmSeCode(aprvlGb[i]); sanctionConsentVO.setConfmComptYn("N"); sanctionConsentVO.setDeleteYn("N"); sanctionConsentVO.setAtchFileId(""); consentManageDAO.insertSanctionConsent(sanctionConsentVO); } // Callback Method try { /* * EgovConsentCallbackService * callbackService = * (EgovConsentCallbackService) * EgovObjectUtil * .instantiate(submitVO.getJobClass()); */ ApplicationContext ctx = getApplicationContext(); EgovOe1ConsentCallbackService callbackService = (EgovOe1ConsentCallbackService) ctx .getBean(submitVO.getJobClass()); callbackService.draftingConsent(submitVO); } catch (ClassNotFoundException e) { log.error(this.getClass() + " Callback - ? ? : " + e.toString()); } catch (Exception e) { log.info(this.getClass() + " Callback : " + e.toString()); } return String.valueOf(submitVO.getDrftSn()); }
From source file:com.stratelia.webactiv.agenda.servlets.AgendaRequestRouter.java
/** * This method has to be implemented by the component request router it has to compute a * destination page//from ww w.ja v a2 s. c om * * * @param function The entering request function (ex : "Main.jsp") * @param scc The component Session Controller, build and initialised. * @param request The entering request. The request router need it to get parameters * @return The complete destination URL for a forward (ex : * "/almanach/jsp/almanach.jsp?flag=user") */ public String getDestination(String function, AgendaSessionController scc, HttpRequest request) { SilverTrace.info("agenda", "AgendaRequestRouter.getDestination()", "root.MSG_GEN_ENTER_METHOD"); String destination = ""; try { if (function.startsWith("Main") || function.startsWith(("agenda.jsp"))) { scc.viewByDay(); scc.setAgendaUserDetail(scc.getAgendaUserDetail()); setCommonAttributes(request, scc); destination = "/agenda/jsp/agenda.jsp"; } else if (function.startsWith("ViewByYear")) { scc.viewByYear(); scc.setAgendaUserDetail(scc.getAgendaUserDetail()); setCommonAttributes(request, scc); destination = "/agenda/jsp/agenda.jsp"; } else if (function.startsWith("ViewByMonth")) { scc.setAgendaUserDetail(scc.getAgendaUserDetail()); scc.viewByMonth(); setCommonAttributes(request, scc); destination = "/agenda/jsp/agenda.jsp"; } else if (function.startsWith("ViewByWeek")) { scc.setAgendaUserDetail(scc.getAgendaUserDetail()); scc.viewByWeek(); setCommonAttributes(request, scc); destination = "/agenda/jsp/agenda.jsp"; } else if (function.startsWith("NextYear")) { scc.setAgendaUserDetail(scc.getAgendaUserDetail()); scc.nextYear(); destination = getDestination("ToChooseWorkingDays", scc, request); } else if (function.startsWith("PreviousYear")) { scc.setAgendaUserDetail(scc.getAgendaUserDetail()); scc.previousYear(); destination = getDestination("ToChooseWorkingDays", scc, request); } else if (function.startsWith("ViewByDay")) { scc.setAgendaUserDetail(scc.getAgendaUserDetail()); scc.viewByDay(); setCommonAttributes(request, scc); destination = "/agenda/jsp/agenda.jsp"; } else if (function.startsWith("SelectDay")) { String day = request.getParameter("Day"); if (StringUtil.isDefined(day)) { Date date = DateUtil.stringToDate(day, scc.getLanguage()); if (!scc.isHolidayDate(date)) { scc.selectDay(day); } } setCommonAttributes(request, scc); destination = "/agenda/jsp/agenda.jsp"; } else if (function.startsWith("searchResult")) { destination = "/agenda/jsp/journal.jsp?Action=Update&JournalId=" + request.getParameter("Id"); } else if (function.startsWith("diffusion")) { destination = scc.initSelectionPeas(); } else if (function.startsWith("saveMembers")) { // retour du userPanel Collection<Attendee> attendees = scc.getUserSelected(); scc.setCurrentAttendees(attendees); destination = "/agenda/jsp/journal.jsp?Action=DiffusionListOK"; } else if (function.startsWith("ChooseOtherAgenda")) { destination = scc.initUserPanelOtherAgenda(); } else if (function.startsWith("ViewOtherAgenda")) { String id = request.getParameter("Id"); UserDetail selectedUser; if (id != null) { // permalink selectedUser = scc.getUserDetail(id); } else { // userPanel return selectedUser = scc.getSelectedUser(); } // request.setAttribute("userDetail",selectedUser); scc.setAgendaUserDetail(selectedUser); SilverTrace.info("agenda", "AgendaRequestRouter.getDestination()", "root.MSG_GEN_PARAM_VALUE", selectedUser.getDisplayedName()); setCommonAttributes(request, scc); destination = "/agenda/jsp/agenda.jsp"; } else if (function.startsWith("ViewCurrentAgenda")) { SilverTrace.info("agenda", "AgendaRequestRouter.getDestination()", "root.MSG_GEN_PARAM_VALUE", scc.getUserDetail().getDisplayedName()); UserDetail userDetail = scc.getUserDetail(); scc.setAgendaUserDetail(userDetail); setCommonAttributes(request, scc); destination = "/agenda/jsp/agenda.jsp"; } else if (function.startsWith("importCalendar")) { CalendarImportSettings importSettings = scc.getImportSettings(); if (importSettings != null) { request.setAttribute("ImportSettings", importSettings); } destination = "/agenda/jsp/importCalendar.jsp"; } else if (function.startsWith("ImportSettings")) { // get current imports settings for user CalendarImportSettings importSettings = scc.getImportSettings(); if (importSettings != null) { request.setAttribute("ImportSettings", importSettings); } destination = "/agenda/jsp/importSettings.jsp"; } else if (function.startsWith("saveImportSettings") || function.startsWith("updateImportSettings")) { // get updated imports settings for user CalendarImportSettings importSettings = new CalendarImportSettings(); importSettings.setUserId(Integer.parseInt(scc.getUserId())); importSettings.setHostName(request.getParameter("hostName")); importSettings.setSynchroDelay(Integer.parseInt(request.getParameter("synchroDelay"))); importSettings.setSynchroType(Integer.parseInt(request.getParameter("synchroType"))); // store settings if (function.startsWith("saveImportSettings")) { scc.saveUserSettings(importSettings); } else { scc.updateUserSettings(importSettings); } // reload main frame in order to reload hidden frame with import applet // destination = "/agenda/jsp/reloadMainFrame.jsp"; destination = "/agenda/jsp/agenda.jsp"; } else if (function.equals("ToExportIcal")) { destination = "/agenda/jsp/exportIcal.jsp"; } else if (function.equals("ToImportIcal")) { destination = "/agenda/jsp/importIcal.jsp"; } else if (function.equals("ExportIcal")) { String startDate = request.getParameter("StartDate"); String endDate = request.getParameter("EndDate"); String returnCode = scc.exportIcalAgenda(startDate, endDate); request.setAttribute("ExportReturnCode", returnCode); destination = getDestination("ToExportIcal", scc, request); } else if (function.equals("ImportIcal")) { ImportIcalManager.charset = scc.getSettings().getString("defaultCharset"); String returnCode = AgendaSessionController.IMPORT_FAILED; File fileUploaded = processFormUpload(scc, request); if (fileUploaded != null) { returnCode = scc.importIcalAgenda(fileUploaded); fileUploaded.delete(); } request.setAttribute("ImportReturnCode", returnCode); destination = getDestination("ToImportIcal", scc, request); } else if (function.equals("ToSynchroIcal")) { CalendarImportSettings importSettings = scc.getImportSettings(); String urlIcalendar = null; String loginIcalendar = null; String pwdIcalendar = null; String charset = null; if (importSettings != null) { urlIcalendar = importSettings.getUrlIcalendar(); loginIcalendar = importSettings.getLoginIcalendar(); if (StringUtil.isDefined(importSettings.getPwdIcalendar())) { pwdIcalendar = StringUtils.decodePassword(importSettings.getPwdIcalendar()); } charset = importSettings.getCharset(); } request.setAttribute("UrlIcalendar", urlIcalendar); request.setAttribute("LoginIcalendar", loginIcalendar); request.setAttribute("PwdIcalendar", pwdIcalendar); request.setAttribute("Charset", charset); destination = "/agenda/jsp/synchroIcal.jsp"; } else if (function.equals("SynchroIcal")) { ImportIcalManager.charset = scc.getSettings().getString("defaultCharset"); // get updated imports settings for user boolean newSettings = false; boolean authNeeded = false; CalendarImportSettings importSettings = scc.getImportSettings(); if (importSettings == null) { importSettings = new CalendarImportSettings(); newSettings = true; } String remoteUrlIcalendar = request.getParameter("UrlIcalendar"); String remoteLoginIcalendar = request.getParameter("LoginIcalendar"); String remotePwdIcalendar = request.getParameter("PwdIcalendar"); String charset = request.getParameter("Charset"); importSettings.setLoginIcalendar(remoteLoginIcalendar); remotePwdIcalendar = PasswordEncoder.encodePassword(remotePwdIcalendar); importSettings.setPwdIcalendar(remotePwdIcalendar); if (StringUtil.isDefined(remoteLoginIcalendar)) { authNeeded = true; } importSettings.setUrlIcalendar(remoteUrlIcalendar); importSettings.setUserId(Integer.parseInt(scc.getUserId())); importSettings.setHostName(""); if (StringUtil.isDefined(charset)) { importSettings.setCharset(charset); ImportIcalManager.charset = charset; } if (newSettings) { scc.saveUserSettings(importSettings); } else { scc.updateUserSettings(importSettings); } String returnCode; if (authNeeded) { returnCode = scc.synchroIcalAgenda(remoteUrlIcalendar, remoteLoginIcalendar, remotePwdIcalendar); } else { returnCode = scc.synchroIcalAgenda(remoteUrlIcalendar); } request.setAttribute("SynchroReturnCode", returnCode); destination = getDestination("ToSynchroIcal", scc, request); } else if (function.equals("ToChooseWorkingDays")) { scc.viewChooseDays(); Calendar calendar = Calendar.getInstance(); calendar.setTime(scc.getCurrentDay()); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.MONTH, 0); Date beginDate = calendar.getTime(); calendar.set(Calendar.DAY_OF_MONTH, 31); calendar.add(Calendar.MONTH, 11); Date endDate = calendar.getTime(); request.setAttribute("BeginDate", beginDate); request.setAttribute("EndDate", endDate); request.setAttribute("HolidayDates", scc.getHolidaysDates()); destination = "/agenda/jsp/chooseWorkingDays.jsp"; } else if (function.equals("ChangeDateStatus")) { String date = request.getParameter("Date"); String status = request.getParameter("Status"); scc.changeDateStatus(date, status); destination = getDestination("ToChooseWorkingDays", scc, request); } else if (function.equals("ChangeDayOfWeekStatus")) { String year = request.getParameter("Year"); String month = request.getParameter("Month"); String day = request.getParameter("DayOfWeek"); scc.changeDayOfWeekStatus(year, month, day); destination = getDestination("ToChooseWorkingDays", scc, request); } else if (function.equals("UpdateEvent")) { String journalId = request.getParameter("JournalId"); request.setAttribute("JournalId", journalId); destination = "/agenda/jsp/journal.jsp"; } else if (function.equals("ReallyEditCategories")) { String selectedCategories = request.getParameter("selectedCategories"); StringTokenizer st = new StringTokenizer(selectedCategories, ","); String[] categoryIds = new String[st.countTokens()]; Collection<Integer> selectedCategoryIds = new ArrayList<Integer>(); Collection<Category> categories = new ArrayList<Category>(); int i = 0; while (st.hasMoreTokens()) { String categIcal = st.nextToken(); categoryIds[i] = categIcal; selectedCategoryIds.add(Integer.valueOf(categoryIds[i])); Category categ = scc.getCategory(categoryIds[i]); categories.add(categ); i++; } scc.setCurrentCategories(categories); request.setAttribute("FromCategories", "1"); destination = "/agenda/jsp/journal.jsp?Action=CategoryOK"; } else { destination = "/agenda/jsp/" + function; } } catch (Exception exce_all) { request.setAttribute("javax.servlet.jsp.jspException", exce_all); return "/admin/jsp/errorpageMain.jsp"; } return destination; }
From source file:de.crowdcode.kissmda.core.uml.UmlHelper.java
/** * This method takes a string and try's to cut it down into its peaces. The * character given as delimiter will be used to determine the single peaces. * //from w w w. j av a2 s. com * @param thwString * . * @return theList * @since 2.1.0 */ public EList<String> convertStringToList(String theString, String delimiter) { if (delimiter == null || delimiter.equals("")) { delimiter = ","; } StringTokenizer tokenizer = new StringTokenizer(theString, delimiter); EList<String> theList = new UniqueEList<String>(tokenizer.countTokens()); String currentToken = null; while (tokenizer.hasMoreTokens()) { currentToken = tokenizer.nextToken(); if (StringUtils.isNotEmpty(currentToken)) { theList.add(currentToken.trim()); } } return theList; }
From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java
protected List<Double> createValueList(String in) { String vs = in;// w w w. j ava 2s .c o m final String DELIMITERS = ",;\t "; // String[] values = in.split("( *)+,+( *)"); // int count = java.lang.reflect.Array.getLength(values); StringTokenizer st = new StringTokenizer(in, DELIMITERS); int count = st.countTokens(); String[] values = new String[count]; for (int i = 0; i < count; i++) values[i] = st.nextToken(); // System.out.println("count="+count); List<Double> result = new java.util.ArrayList<Double>(); try { for (int i = 0; i < count; i++) { //System.out.println("values["+i+"]=*"+values[i]+"*"); double v; if (values[i] != null && values[i].length() != 0 && !values[i].equals("null")) { v = Double.parseDouble(values[i]); result.add(new Double(v)); } } } catch (NumberFormatException e) { System.out.println("Data format error!"); return null; } return result; }