List of usage examples for java.lang Integer decode
public static Integer decode(String nm) throws NumberFormatException
From source file:org.jbpm.formModeler.core.processing.fieldHandlers.multipleSubform.SubFormSendHandler.java
public void editItem(CommandRequest request, boolean doIt) throws Exception { String[] uids = request.getRequestObject().getParameterValues("child_uid_value"); String uid = ""; if (uids != null) { for (int i = 0; i < uids.length; i++) { if (uids[i] != null && !"".equals(uids[i])) uid = uids[i];//from w ww . j a va 2 s. c om } } String index = request.getParameter(uid + "_index"); String parentFormId = request.getParameter(uid + "_parentFormId"); String parentNamespace = request.getParameter(uid + "_parentNamespace"); String fieldName = request.getParameter(uid + "_field"); String inputName = request.getParameter(uid + "_inputName"); Form form = subformFinderService.getFormById(Long.decode(parentFormId), parentNamespace); Field field = form.getField(fieldName); getFormProcessor().setValues(form, parentNamespace, request.getRequestObject().getParameterMap(), request.getFilesByParamName()); if (doIt) { FormStatusData fsd = getFormProcessor().read(form, parentNamespace); Map[] previousValue = deepCloneOfMapArray((Map[]) fsd.getCurrentValue(fieldName), new HashMap()); helper.setEditFieldPreviousValues(inputName, previousValue); CreateDynamicObjectFieldHandler fieldHandler = (CreateDynamicObjectFieldHandler) getFieldHandlersManager() .getHandler(field.getFieldType()); Form formToEdit = fieldHandler.getEditForm(field, parentNamespace); getFormProcessor().clear(formToEdit, parentNamespace + FormProcessor.NAMESPACE_SEPARATOR + parentFormId + FormProcessor.NAMESPACE_SEPARATOR + fieldName + FormProcessor.CUSTOM_NAMESPACE_SEPARATOR + index); getFormProcessor().clear(formToEdit, parentNamespace + FormProcessor.NAMESPACE_SEPARATOR + parentFormId + FormProcessor.NAMESPACE_SEPARATOR + fieldName); helper.setEditFieldPosition(inputName, Integer.decode(index)); } else { Object previousValue = helper.getEditFieldPreviousValues(inputName); getFormProcessor().modify(form, parentNamespace, fieldName, previousValue); helper.clearExpandedField(inputName); helper.clearEditFieldPositions(inputName); helper.clearEditFieldPreviousValues(inputName); helper.clearPreviewFieldPositions(inputName); } getFormProcessor().clearFieldErrors(form, parentNamespace); }
From source file:com.neophob.sematrix.properties.ApplicationConfigurationHelper.java
/** * Parses the i2c address./*from w w w. j a v a2s .c om*/ * * @return the int */ private int parseI2cAddress() { i2cAddr = new ArrayList<Integer>(); String rawConfig = config.getProperty(ConfigConstant.RAINBOWDUINO_ROW1); if (StringUtils.isNotBlank(rawConfig)) { this.deviceXResolution = 8; this.deviceYResolution = 8; for (String s : rawConfig.split(ConfigConstant.DELIM)) { i2cAddr.add(Integer.decode(s)); devicesInRow1++; } } rawConfig = config.getProperty(ConfigConstant.RAINBOWDUINO_ROW2); if (StringUtils.isNotBlank(rawConfig)) { for (String s : rawConfig.split(ConfigConstant.DELIM)) { i2cAddr.add(Integer.decode(s)); devicesInRow2++; } } return i2cAddr.size(); }
From source file:org.apache.hadoop.fs.swift.http.SwiftRestClient.java
private int getIntOption(Properties props, String key, int def) throws SwiftConfigurationException { String val = props.getProperty(key, Integer.toString(def)); try {/*from ww w . j a v a 2 s . c om*/ return Integer.decode(val); } catch (NumberFormatException e) { throw new SwiftConfigurationException( "Failed to parse (numeric) value" + " of property" + key + " : " + val, e); } }
From source file:ar.com.qbe.siniestros.model.utils.MimeMagic.MagicMatcher.java
/** * test the data against the test byte// w ww . ja va2 s .c o m * * @param data the data we are testing * * @return if we have a match */ private boolean testByte(ByteBuffer data) { log.debug("testByte()"); String test = new String(match.getTest().array()); char comparator = match.getComparator(); long bitmask = match.getBitmask(); String s = test; byte b = data.get(0); b = (byte) (b & bitmask); log.debug("testByte(): decoding '" + test + "' to byte"); int tst = Integer.decode(test).byteValue(); byte t = (byte) (tst & 0xff); log.debug("testByte(): applying bitmask '" + bitmask + "' to '" + tst + "', result is '" + t + "'"); log.debug("testByte(): comparing byte '" + b + "' to '" + t + "'"); switch (comparator) { case '=': return t == b; case '!': return t != b; case '>': return t > b; case '<': return t < b; } return false; }
From source file:us.conxio.hl7.hl7message.HL7Designator.java
private int bracketSeparatedPositionValueOf(String argStr) { int openPosn = argStr.indexOf("["); int retnInt = -3; if (openPosn > 0) { retnInt = Integer.decode(argStr.substring(0, openPosn)); return (retnInt); } else if (openPosn == 0) { retnInt = -3;/*from w w w .j a v a2s.c om*/ } else { retnInt = Integer.decode(argStr); } // if - else if - else return (retnInt); }
From source file:org.openhab.binding.canopen.internal.CANOpenBinding.java
/** * Called by the SCR when the configuration of a binding has been changed through the ConfigAdmin service. * @param configuration Updated configuration properties *//*from w w w . j a va 2 s .c o m*/ public void modified(final Map<String, Object> configuration) { // to override the default refresh interval one has to add a // parameter to openhab.cfg like <bindingName>:refresh=<intervalInMs> String refreshIntervalString = (String) configuration.get("refresh"); refreshInterval = 60000; if (StringUtils.isNotBlank(refreshIntervalString)) { refreshInterval = Long.parseLong(refreshIntervalString); } String sdoResponseTimeoutString = (String) configuration.get("sdo_timeout"); sdoResponseTimeout = 1000; if (StringUtils.isNotBlank(sdoResponseTimeoutString)) { sdoResponseTimeout = Integer.parseInt(sdoResponseTimeoutString); } autoStartNodes.clear(); autoStartAll = false; String autoStartString = (String) configuration.get("auto_start_nodes"); if (StringUtils.isNotBlank(autoStartString)) { String[] nodes = autoStartString.split(","); for (String node : nodes) { if (node.trim().toLowerCase().equals("all")) autoStartAll = true; try { autoStartNodes.add(Integer.decode(node)); } catch (NumberFormatException e) { } } } syncInterfaces.clear(); String syncInterfaceString = (String) configuration.get("sync_master_for"); if (StringUtils.isNotBlank(syncInterfaceString)) { if (syncInterfaceString.contains(",")) syncInterfaces.addAll(Arrays.asList(syncInterfaceString.split("\\s*,\\s*"))); else syncInterfaces.add(syncInterfaceString.trim()); logger.debug("Sync master for: " + syncInterfaces); } syncMaxVal = 0; String syncMaxValString = (String) configuration.get("sync_max_val"); if (StringUtils.isNotBlank(syncMaxValString)) { try { syncMaxVal = Integer.parseInt(syncMaxValString); if (syncMaxVal > 255) syncMaxVal = 255; if (syncMaxVal < 0) syncMaxVal = 0; } catch (NumberFormatException e) { logger.error("Could not parse sync_max_val from string " + syncMaxValString); } } }
From source file:org.soaplab.services.Config.java
/************************************************************************** * Almost the same functionality as {@link #getString getString} * method - see there details about parameters - except that it * expects property value to be an integer. <p> * * If the key is found but its value is not an integer, or if it * is not found at all, it returns the given default value. <p> **************************************************************************/ public static int getInt(String key, int defaultValue, String serviceName, Object owner) { String strValue = getString(key, "" + defaultValue, serviceName, owner); try {/*from www .ja v a 2 s .c o m*/ return Integer.decode(strValue).intValue(); } catch (NumberFormatException e) { return defaultValue; } }
From source file:org.apache.nifi.processors.standard.DistributeLoad.java
@OnScheduled public void createWeightedList(final ProcessContext context) { final Map<Integer, Integer> weightings = new LinkedHashMap<>(); String distStrat = context.getProperty(DISTRIBUTION_STRATEGY).getValue(); if (distStrat.equals(STRATEGY_LOAD_DISTRIBUTION_SERVICE)) { String hostNamesValue = context.getProperty(HOSTNAMES).getValue(); String[] hostNames = hostNamesValue.split("(?:,+|;+|\\s+)"); Set<String> hostNameSet = new HashSet<>(); for (String hostName : hostNames) { if (StringUtils.isNotBlank(hostName)) { hostNameSet.add(hostName); }/*from w w w .j a v a 2 s .c o m*/ } LoadDistributionService svc = context.getProperty(LOAD_DISTRIBUTION_SERVICE_TEMPLATE) .asControllerService(LoadDistributionService.class); myListener = new LoadDistributionListener() { @Override public void update(Map<String, Integer> loadInfo) { for (Relationship rel : relationshipsRef.get()) { String hostname = rel.getDescription(); Integer weight = 1; if (loadInfo.containsKey(hostname)) { weight = loadInfo.get(hostname); } weightings.put(Integer.decode(rel.getName()), weight); } updateWeightedRelationships(weightings); } }; Map<String, Integer> loadInfo = svc.getLoadDistribution(hostNameSet, myListener); for (Relationship rel : relationshipsRef.get()) { String hostname = rel.getDescription(); Integer weight = 1; if (loadInfo.containsKey(hostname)) { weight = loadInfo.get(hostname); } weightings.put(Integer.decode(rel.getName()), weight); } } else { final int numRelationships = context.getProperty(NUM_RELATIONSHIPS).asInteger(); for (int i = 1; i <= numRelationships; i++) { weightings.put(i, 1); } for (final PropertyDescriptor propDesc : context.getProperties().keySet()) { if (!this.properties.contains(propDesc)) { final int relationship = Integer.parseInt(propDesc.getName()); final int weighting = context.getProperty(propDesc).asInteger(); weightings.put(relationship, weighting); } } } updateWeightedRelationships(weightings); }
From source file:org.apache.jmeter.protocol.jdbc.AbstractJDBCTestElement.java
private static int getJdbcType(String jdbcType) throws SQLException { Integer entry = mapJdbcNameToInt.get(jdbcType.toLowerCase(java.util.Locale.ENGLISH)); if (entry == null) { try {/*from w ww. ja va 2 s .co m*/ entry = Integer.decode(jdbcType); } catch (NumberFormatException e) { throw new SQLException("Invalid data type: " + jdbcType); } } return (entry).intValue(); }
From source file:org.kchine.r.server.http.RHttpProxy.java
private static GenericCallbackDevice newGenericCallbackDevice(String url, String sessionId) throws TunnelingException { GetMethod getNewDevice = null;/*from w w w.ja v a 2 s .c o m*/ try { Object result = null; mainHttpClient = new HttpClient(); if (System.getProperty("proxy_host") != null && !System.getProperty("proxy_host").equals("")) { mainHttpClient.getHostConfiguration().setProxy(System.getProperty("proxy_host"), Integer.decode(System.getProperty("proxy_port"))); } getNewDevice = new GetMethod(url + "?method=newgenericcallbackdevice"); try { if (sessionId != null && !sessionId.equals("")) { getNewDevice.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES); getNewDevice.setRequestHeader("Cookie", "JSESSIONID=" + sessionId); } mainHttpClient.executeMethod(getNewDevice); result = new ObjectInputStream(getNewDevice.getResponseBodyAsStream()).readObject(); } catch (ConnectException e) { throw new ConnectionFailedException(); } catch (Exception e) { throw new TunnelingException("", e); } if (result != null && result instanceof TunnelingException) { throw (TunnelingException) result; } String deviceName = (String) result; return (GenericCallbackDevice) RHttpProxy.getDynamicProxy(url, sessionId, deviceName, new Class[] { GenericCallbackDevice.class }, new HttpClient(new MultiThreadedHttpConnectionManager())); } finally { if (getNewDevice != null) { getNewDevice.releaseConnection(); } if (mainHttpClient != null) { } } }