List of usage examples for org.apache.commons.lang3 StringUtils isNumeric
public static boolean isNumeric(final CharSequence cs)
Checks if the CharSequence contains only Unicode digits.
From source file:XMLParser.java
public void StartTools(int type) { try {/*w w w.ja v a 2s .c o m*/ if (type == 0) { try { URL url = new URL("http://api.micetigri.fr/maps/search/p" + BootP + "?page=" + BootPg + "&sort=id&direction=asc"); URLConnection connection = url.openConnection(); connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.29 Safari/537.36"); try (BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(connection.getInputStream()))) { while ((line = bufferedReader.readLine()) != null) { if (line.contains("query: ")) { Object data[] = line.split("\""); Codes = (String) data[1]; } } if (!Codes.equals("")) { try { if (!BootCodes.equals("")) { BootCodes += ";" + Codes; } else { BootCodes += Codes; } this.jTextPane1.setText(BootCodes); System.out.println(new StringBuilder("[List]: ").append(Codes).toString()); if (!this.jCheckBox3.isSelected()) { BootPg++; new java.util.Timer().schedule(new java.util.TimerTask() { @Override public void run() { StartTools(0); } }, BootDelay); } else { this.StartTools(2); } BootPgCount++; } catch (Exception error) { System.out.println(new StringBuilder("[Codes]: ").append(error).toString()); } } else { System.out.println(new StringBuilder("Total (PG): ").append(BootPgCount).toString()); this.StartTools(2); } } } catch (Exception error) { System.out.println(new StringBuilder("[0][Exception]: ").append(error).toString()); } } else if (type == 2) { try { String[] MapCodes = BootCodes.split(";"); String MapCode = ""; try { MapCode = MapCodes[BootID]; } catch (Exception error) { MapCode = ""; } if (StringUtils.isNumeric(MapCode)) { URL url = new URL("http://api.micetigri.fr/maps/xmlnew/" + MapCode); URLConnection connection = url.openConnection(); connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.29 Safari/537.36"); try (BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(connection.getInputStream()))) { while ((line = bufferedReader.readLine()) != null) { if (line.contains("CODE")) { Object data[] = line.split("\""); Code = Integer.valueOf((String) data[1]); } else if (line.contains("CREATOR")) { Object data[] = line.split("\""); Creator = (String) data[1]; } else if (line.contains("XML")) { Object data[] = line.split("\""); xml = decrypt((String) data[1], CRYPT_KEY); } else if (line.contains("PERM")) { Object data[] = line.split("\""); Perm = Integer.valueOf((String) data[1]); } } if (!xml.equals("") && !Creator.equals("")) { BootInfos += (new StringBuilder("Code: '").append(Code).append("'\nCreator: '") .append(Creator).append("'\nPerma: '").append(Perm).append("'\nXML: '") .append(xml).append("'\n\n\n\n").toString()); this.jTextPane1.setText(BootInfos); BootID++; new java.util.Timer().schedule(new java.util.TimerTask() { @Override public void run() { StartTools(2); } }, BootDelay); } } } else { this.jButton1.setText("START"); this.jButton1.setEnabled(true); this.jComboBox1.setEnabled(true); this.jCheckBox1.setEnabled(true); this.jCheckBox2.setEnabled(true); this.jLabel1.setEnabled(true); this.jLabel2.setEnabled(true); this.jCheckBox3.setEnabled(true); if (this.jCheckBox3.isSelected()) { this.jSpinner1.setEnabled(true); } System.out.println(new StringBuilder("Total de mapas: ").append(BootID).toString()); } } catch (Exception error) { System.out.println(new StringBuilder("[1][Exception]: ").append(error).toString()); } } else if (type == 1) { try { URL url = new URL("http://api.micetigri.fr/maps/xmlnew/" + iCode); URLConnection connection = url.openConnection(); connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.29 Safari/537.36"); try (BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(connection.getInputStream()))) { while ((line = bufferedReader.readLine()) != null) { if (line.contains("CODE")) { Object data[] = line.split("\""); Code = Integer.valueOf((String) data[1]); } else if (line.contains("CREATOR")) { Object data[] = line.split("\""); Creator = (String) data[1]; } else if (line.contains("XML")) { Object data[] = line.split("\""); xml = decrypt((String) data[1], CRYPT_KEY); } else if (line.contains("PERM")) { Object data[] = line.split("\""); Perm = Integer.valueOf((String) data[1]); } } if (!xml.equals("") && !Creator.equals("")) { this.jTextPane1.setText(new StringBuilder("Code: '").append(Code) .append("'\nCreator: '").append(Creator).append("'\nPerma: '").append(Perm) .append("'\nXML: '").append(xml).append("'\n").toString()); } else { this.jTextPane1.setText("xml not found !"); } } this.jButton1.setEnabled(true); this.jLabel3.setEnabled(true); this.jTextField1.setEnabled(true); this.jCheckBox1.setEnabled(true); this.jCheckBox2.setEnabled(false); this.jButton1.setText("START"); } catch (Exception error) { System.out.println(new StringBuilder("[1][Exception]: ").append(error).toString()); } } } catch (Exception error) { System.out.println(new StringBuilder("[ALL][IOException]: ").append(error).toString()); } }
From source file:computer_store.GUI.java
private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyReleased if (jTextField1.hasFocus()) { if (StringUtils.isNumeric(jTextField1.getText())) { int qty = Integer.parseInt(jTextField1.getText()); if (qty == 1) jTextField2.setText(/*from w w w . j a va 2s.c o m*/ "" + df.format(handler.getSystemSellPrice((String) jComboBox1.getSelectedItem()))); else if ((qty > 1) && (qty <= 11)) jTextField2.setText( "" + df.format(handler.getSystemSellPrice((String) jComboBox1.getSelectedItem()) * qty * (1 - (0.02 * (qty - 1))))); else jTextField2.setText("" + df .format(handler.getSystemSellPrice((String) jComboBox1.getSelectedItem()) * qty * 0.8)); } else jTextField2.setText("invalid number"); } }
From source file:com.hortonworks.streamline.streams.security.service.SecurityCatalogService.java
private void validateRole(Role role) { Utils.requireNonEmpty(role.getName(), "Role name"); if (StringUtils.isNumeric(role.getName())) { throw new IllegalArgumentException("Role name cannot be numeric"); }/*from ww w . j a va 2 s .co m*/ StorageUtils.ensureUnique(role, this::listRoles, QueryParam.params(User.NAME, role.getName())); }
From source file:com.hortonworks.streamline.streams.security.service.SecurityCatalogService.java
private void validateUser(User user) { Utils.requireNonEmpty(user.getName(), "User name"); if (StringUtils.isNumeric(user.getName())) { throw new IllegalArgumentException("User name cannot be numeric"); }//from w w w.j av a 2 s.c om StorageUtils.ensureUnique(user, this::listUsers, QueryParam.params(User.NAME, user.getName())); }
From source file:gtu.jpa.hibernate.Rcdf002eDBUI.java
private JButton getJButton1x() { if (porcessDoAllBtn == null) { porcessDoAllBtn = new JButton(); porcessDoAllBtn.setText("\u6392\u7a0b\u57f7\u884c"); porcessDoAllBtn.setPreferredSize(new java.awt.Dimension(80, 54)); porcessDoAllBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { String dateTime = processDoAllText.getText(); Validate.notBlank(dateTime, ""); Validate.isTrue(StringUtils.isNumeric(dateTime), ""); Validate.isTrue(StringUtils.isNumeric(dateTime), ""); Validate.isTrue(dateTime.length() == 14, "14"); SimpleDateFormat sdf = new SimpleDateFormat(); sdf.applyPattern("yyyyMMddHHmmss"); Date newDate = sdf.parse(dateTime); Validate.isTrue(newDate.after(new Date()), "??"); setTitle(DateFormatUtils.format(newDate, "yyyy/MM/dd HH:mm:ss") + "?..."); Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { oneClickDoAll(); }//from ww w.ja v a2s . c om }, newDate); } catch (Exception ex) { JCommonUtil.handleException(ex); setTitle("......" + ex.getMessage()); } } }); } return porcessDoAllBtn; }
From source file:forge.game.spellability.TargetRestrictions.java
public void calculateStillToDivide(String toDistribute, Card source, SpellAbility sa) { // Recalculate this value just in case it's variable if (!this.dividedAsYouChoose) { return;/*from w w w.jav a2 s . c o m*/ } if (StringUtils.isNumeric(toDistribute)) { this.setStillToDivide(Integer.parseInt(toDistribute)); } else if (source == null) { return; // such calls come from AbilityFactory.readTarget - at this moment we don't yet know X or any other variables } else if (source.getSVar(toDistribute).equals("xPaid")) { this.setStillToDivide(source.getXManaCostPaid()); } else { this.setStillToDivide(AbilityUtils.calculateAmount(source, toDistribute, sa)); } }
From source file:ems.util.DataHandler.java
public static void getReport(String... params) { String sqlQuery = ""; Statement s = null;/*from www .j a v a 2 s .c o m*/ ResultSet rs = null; Connection con = null; try { String paramss[] = params; String reportType = paramss[0]; log.info("reportType|" + reportType + " ----> params|" + Arrays.toString(paramss)); switch (reportType) { case "1": sqlQuery = String.format(Q_S_AGE_WISE, paramss[1], paramss[2], paramss[3]); break; case "2": sqlQuery = String.format(Q_S_ALPHABETIC_WISE, paramss[1]); break; case "3": sqlQuery = String.format(Q_S_AREA_WISE, paramss[1]); break; case "4": sqlQuery = String.format(Q_S_BIRTHDAY_WISE, paramss[1], paramss[2]); break; case "5": sqlQuery = String.format(Q_S_BIRTHDAY_DAY_WISE, paramss[1], paramss[2]); break; case "6": sqlQuery = Q_S_BOOTH_WISE; break; case "7": sqlQuery = String.format(Q_S_COMMUNITY_WISE, paramss[1]); break; case "8": sqlQuery = String.format(Q_S_COLOR_CODE_BOOTH_WISE, paramss[1], paramss[2], paramss[2]); break; case "9": sqlQuery = String.format(Q_S_COLOR_CODE_WISE, paramss[2], paramss[2]); break; case "10": sqlQuery = String.format(Q_S_MOBILE_WISE, paramss[1]); break; case "11": sqlQuery = String.format(Q_S_SECTION_WISE, paramss[1]); break; case "12": sqlQuery = String.format(Q_S_SURNAME_WISE, paramss[1]); break; case "13": sqlQuery = String.format(Q_S_WITHOUT_ID_CARD_WISE, paramss[1]); break; case "a": sqlQuery = String.format(Q_S_NAME_WISE, paramss[1], paramss[2]); break; case "b": sqlQuery = String.format(Q_S_ID_WISE, paramss[1]); break; case "c": sqlQuery = String.format(Q_S_SR_WISE, paramss[1]); break; case "ELECTION_HISTORY": sqlQuery = String.format(Q_S_ELECTION_HISTORY, paramss[1]); break; case "STATUS_UPDATE": switch (paramss[1]) { case "101": sqlQuery = Q_S_SURNAME_STATUS; break; case "102": sqlQuery = Q_S_COMMUNITY_STATUS; break; } break; } con = getConnection(); log.info("sqlQuery: " + sqlQuery); s = con.createStatement(); rs = s.executeQuery(sqlQuery); if (reportType.equals("STATUS_UPDATE")) { statusUpdateTableData.clear(); } else if (reportType.equals("ELECTION_HISTORY")) { electionHistoryTableData.clear(); } else if (StringUtils.isNumeric(reportType)) { reportTableData.clear(); } else { voterTableData.clear(); } while (rs.next()) { if (reportType.equals("ELECTION_HISTORY")) { MyModelSimpleStringProperty entry = new MyModelSimpleStringProperty(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), "", "", "", "", "", "", "", "", "", "", "", ""); electionHistoryTableData.add(entry); } else { if (StringUtils.isNumeric(reportType) || reportType.equals("STATUS_UPDATE")) { switch (reportType) { case "3": case "6": case "7": case "8": case "9": case "11": case "12": MyModelSimpleStringProperty entry = new MyModelSimpleStringProperty(rs.getString(1), rs.getString(2), "", "", "", "", "", "", "", "", "", "", "", "", "", ""); reportTableData.add(entry); break; case "STATUS_UPDATE": entry = new MyModelSimpleStringProperty(rs.getString(1), rs.getString(2), "", "", "", "", "", "", "", "", "", "", "", "", "", ""); statusUpdateTableData.add(entry); break; default: entry = new MyModelSimpleStringProperty(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8), rs.getString(9), rs.getString(10), rs.getString(11), "", "", "", "", ""); reportTableData.add(entry); } } else { MyModelSimpleStringProperty entry = new MyModelSimpleStringProperty(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8), rs.getString(9), rs.getString(10), rs.getString(11), "", "", "", "", ""); voterTableData.add(entry); } } } } catch (Exception e) { log.error("getReportException: " + e.getMessage()); } finally { try { if (rs != null) { rs.close(); } if (s != null) { s.close(); } if (con != null) { con.close(); } } catch (Exception ex) { log.error("getReport: " + ex.getMessage()); } } }
From source file:com.globalsight.webservices.Ambassador4Falcon.java
/** * <p>/*w w w . j ava2s . c o m*/ * Return job ID, jobName, description, creationDate, lang, Matches, 95-99%, * 85-94%, 75-84%, noMatch, repetitions, inContextMatches, MT, total, * MTConfidenceScore, filePath, fileName for specified jobs. This is similar * with "Detailed Word Counts By Job" report. * </p> * <p> * Falcon connector will use this API to read and price MT'd words, so it * can quote MT projects. Currently, the Falcon connector assumes for MT * projects all new words are MT'd words. * </p> * * @param p_accessToken * -- login user's token * @param p_jobIds * -- jobIds in array. * @param includeMTData * -- flag to decide if include MT'd word counts. * @return String in JSON. A sample is like: * [{"total":236,"85-94%":0,"jobId":39,"filePath":"en_US\\39\\global","MTConfidenceScore":100,"inContextMatches":0,"75-84%":0,"95-99%":0,"jobName":"mumt_22759766","lang":"fr_FR","MT":0,"repetitions":0, * "noMatch":0,"projectDescription":"com1","creationDate ":"2013-11-01 11:48:20","fileName":"Welocalize_Company.html","100%Matches":236}, * {"total":236,"85-94%":0,"jobId":39,"filePath":"en_US\\39\\global","MTConfidenceScore":100,"inContextMatches":0,"75-84%":0,"95-99%":0,"jobName":"mumt_22759766","lang":"de_DE","MT":0,"repetitions":0, * "noMatch":236,"projectDescription":"com1","creationDate ":"2013-11-01 11:48:20","fileName":"Welocalize_Company.html","100%Matches":0}, * {"total":236,"85-94%":13,"jobId":38,"filePath":"en_US\\38\\global","MTConfidenceScore":100,"inContextMatches":53,"75-84%":13,"95-99%":30,"jobName":"mty_826004265","lang":"fr_FR","MT":0,"repetitions":0, * "noMatch":52,"projectDescription":"Template","creationDate ":"2013-11-01 11:41:14","fileName":"Welocalize_Company.html","100%Matches":75}] * * @throws WebServiceException * */ public String getDetailedWordcounts(String p_accessToken, String[] p_jobIds, Boolean p_includeMTData) throws WebServiceException { checkAccess(p_accessToken, GET_DETAILED_WORD_COUNTS); String returnStr = checkPermissionReturnStr(p_accessToken, Permission.REPORTS_DELL_FILE_LIST); if (StringUtil.isNotEmpty(returnStr)) return returnStr; String json = ""; WebServicesLog.Start activityStart = null; try { Map<Object, Object> activityArgs = new HashMap<Object, Object>(); activityArgs.put("jobIds", p_jobIds); activityArgs.put("includeMTData", p_includeMTData); activityStart = WebServicesLog.start(Ambassador4Falcon.class, "getDetailedWordcounts(accessToken, jobIds, includeMTData)", activityArgs); if (StringUtil.isEmpty(p_accessToken) || p_jobIds.length < 1) { return makeErrorJson(GET_DETAILED_WORD_COUNTS, "Invaild jobIds parameter."); } User curUser = getUser(getUsernameFromSession(p_accessToken)); Company company = getCompanyByName(curUser.getCompanyName()); JSONArray array = new JSONArray(); for (String jobIdstr : p_jobIds) { if (!StringUtils.isNumeric(jobIdstr)) continue; long jobId = Long.valueOf(jobIdstr); Job job = ServerProxy.getJobHandler().getJobById(jobId); if (job != null) { // If job is not from current user's company, ignore. if (company.getId() != 1 && company.getId() != job.getCompanyId()) { continue; } int threshold = job.getLeverageMatchThreshold(); String jobname = job.getJobName(); String pDesc = getProjectDesc(job); String createDate = dateFormat.format(job.getCreateDate()); for (Workflow p_workflow : job.getWorkflows()) { int mtConfidenceScore = p_workflow.getMtConfidenceScore(); String lang = p_workflow.getTargetLocale().toString(); for (TargetPage tg : p_workflow.getTargetPages()) { JSONObject jsonObj = new JSONObject(); jsonObj.put("jobId", jobId); jsonObj.put("jobName", jobname); setFilePathName(tg, jsonObj); jsonObj.put("projectDescription", pDesc); jsonObj.put("creationDate", createDate); jsonObj.put("lang", lang); try { addWordCountForJson(tg, jsonObj, threshold, mtConfidenceScore, p_includeMTData); } catch (Exception e) { e.printStackTrace(); } array.put(jsonObj); } } } } json = array.toString(); } catch (Exception e) { return makeErrorJson(GET_DETAILED_WORD_COUNTS, "Cannot get Wordcounts correctly. " + e.getMessage()); } finally { if (activityStart != null) { activityStart.end(); } } return json; }
From source file:ml.shifu.shifu.core.dtrain.nn.NNMaster.java
@SuppressWarnings("unchecked") @Override/*from w w w .j a va 2 s.c om*/ public void init(MasterContext<NNParams, NNParams> context) { Properties props = context.getProps(); try { SourceType sourceType = SourceType .valueOf(props.getProperty(CommonConstants.MODELSET_SOURCE_TYPE, SourceType.HDFS.toString())); this.modelConfig = CommonUtils.loadModelConfig(props.getProperty(CommonConstants.SHIFU_MODEL_CONFIG), sourceType); this.columnConfigList = CommonUtils .loadColumnConfigList(props.getProperty(CommonConstants.SHIFU_COLUMN_CONFIG), sourceType); } catch (IOException e) { throw new RuntimeException(e); } int trainerId = Integer.valueOf(context.getProps().getProperty(CommonConstants.SHIFU_TRAINER_ID, "0")); GridSearch gs = new GridSearch(modelConfig.getTrain().getParams(), modelConfig.getTrain().getGridConfigFileContent()); validParams = this.modelConfig.getTrain().getParams(); if (gs.hasHyperParam()) { validParams = gs.getParams(trainerId); LOG.info("Start grid search master with params: {}", validParams); } Boolean enabledEarlyStop = DTrainUtils.getBoolean(validParams, CommonConstants.ENABLE_EARLY_STOP, Boolean.FALSE); if (enabledEarlyStop) { Double validTolerance = DTrainUtils.getDouble(validParams, CommonConstants.VALIDATION_TOLERANCE, null); if (validTolerance == null) { LOG.info("Early Stop is enabled. use WindowEarlyStop"); // windowSize default 20, user should could adjust it this.earlyStopStrategy = new WindowEarlyStop(context, this.modelConfig, DTrainUtils .getInt(context.getProps(), CommonConstants.SHIFU_TRAIN_EARLYSTOP_WINDOW_SIZE, 20)); } else { LOG.info("Early Stop is enabled. use ConvergeAndValiToleranceEarlyStop"); Double threshold = this.modelConfig.getTrain().getConvergenceThreshold(); this.earlyStopStrategy = new ConvergeAndValidToleranceEarlyStop( threshold == null ? Double.MIN_VALUE : threshold.doubleValue(), validTolerance); } } Object pObject = validParams.get(CommonConstants.PROPAGATION); this.propagation = pObject == null ? "Q" : (String) pObject; this.rawLearningRate = Double.valueOf(validParams.get(CommonConstants.LEARNING_RATE).toString()); Object dropoutRateObj = validParams.get(CommonConstants.DROPOUT_RATE); if (dropoutRateObj != null) { this.dropoutRate = Double.valueOf(dropoutRateObj.toString()); } LOG.info("'dropoutRate' in master is : {}", this.dropoutRate); Object learningDecayO = validParams.get(CommonConstants.LEARNING_DECAY); if (learningDecayO != null) { this.learningDecay = Double.valueOf(learningDecayO.toString()); } LOG.info("'learningDecay' in master is :{}", learningDecay); Object momentumO = validParams.get("Momentum"); if (momentumO != null) { this.momentum = Double.valueOf(momentumO.toString()); } LOG.info("'momentum' in master is :{}", momentum); Object adamBeta1O = validParams.get("AdamBeta1"); if (adamBeta1O != null) { this.adamBeta1 = Double.valueOf(adamBeta1O.toString()); } LOG.info("'adamBeta1' in master is :{}", adamBeta1); Object adamBeta2O = validParams.get("AdamBeta2"); if (adamBeta2O != null) { this.adamBeta2 = Double.valueOf(adamBeta2O.toString()); } LOG.info("'adamBeta2' in master is :{}", adamBeta2); this.wgtInit = "default"; Object wgtInitObj = validParams.get(CommonConstants.WEIGHT_INITIALIZER); if (wgtInitObj != null) { this.wgtInit = wgtInitObj.toString(); } this.isContinuousEnabled = Boolean.TRUE.toString() .equalsIgnoreCase(context.getProps().getProperty(CommonConstants.CONTINUOUS_TRAINING)); Object rconstant = validParams.get(CommonConstants.REGULARIZED_CONSTANT); this.regularizedConstant = NumberFormatUtils.getDouble(rconstant == null ? "" : rconstant.toString(), 0d); // We do not update weight in fixed layers so that we could fine tune other layers of NN Object fixedLayers2O = validParams.get(CommonConstants.FIXED_LAYERS); if (fixedLayers2O != null) { this.fixedLayers = (List<Integer>) fixedLayers2O; } LOG.info("Fixed layers in master is :{}", this.fixedLayers.toString()); Object fixedBiasObj = validParams.getOrDefault(CommonConstants.FIXED_BIAS, true); this.fixedBias = (Boolean) fixedBiasObj; Object hiddenLayerNumObj = validParams.get(CommonConstants.NUM_HIDDEN_LAYERS); if (hiddenLayerNumObj != null && StringUtils.isNumeric(hiddenLayerNumObj.toString())) { this.hiddenLayerNum = Integer.valueOf(hiddenLayerNumObj.toString()); } LOG.info("hiddenLayerNum in master is :{}", this.hiddenLayerNum); // check if variables are set final selected int[] inputOutputIndex = DTrainUtils.getNumericAndCategoricalInputAndOutputCounts(this.columnConfigList); this.isAfterVarSelect = (inputOutputIndex[3] == 1); // cache all feature list for sampling features this.allFeatures = NormalUtils.getAllFeatureList(columnConfigList, isAfterVarSelect); String subsetStr = context.getProps().getProperty(CommonConstants.SHIFU_NN_FEATURE_SUBSET); if (StringUtils.isBlank(subsetStr)) { this.subFeatures = this.allFeatures; } else { String[] splits = subsetStr.split(","); this.subFeatures = new ArrayList<Integer>(splits.length); for (String split : splits) { this.subFeatures.add(Integer.parseInt(split)); } } // recover master states here is globalNNParams // not init but not first iteration, first recover from last master result set from guagua if (!context.isFirstIteration()) { NNParams params = context.getMasterResult(); if (params != null && params.getWeights() != null) { this.globalNNParams.setWeights(params.getWeights()); } else { // else read from checkpoint params = initOrRecoverParams(context); this.globalNNParams.setWeights(params.getWeights()); } } }
From source file:io.stallion.users.UserController.java
public UserValetResult cookieStringToUser(String cookie) { String[] parts = cookie.split("&", 2); if (parts.length < 2) { return null; }// w ww . j a va 2 s . c o m if (!StringUtils.isNumeric(parts[0])) { Log.warn("Invalid user id found in cookie: {0}", parts[0]); return null; } Long id = Long.parseLong(parts[0]); String encryptedJson = parts[1]; T user = forId(id); if (user == null) { return null; } String json = Encrypter.decryptString(user.getEncryptionSecret(), encryptedJson); SessionInfo info = JSON.parse(json, SessionInfo.class); if (info.getExp() < mils()) { return null; } if (!info.getSec().equals(user.getSecret())) { return null; } UserValetResult result = new UserValetResult().setUser(user); if (!empty(info.getVid())) { T valet = forId(info.getVid()); if (valet == null) { return null; } result.setValet(valet); } result.setSessionKey(info.getSsec()); return result; }