List of usage examples for java.lang Integer intValue
@HotSpotIntrinsicCandidate public int intValue()
From source file:com.meetup.memcached.NativeHandler.java
protected static Float decodeFloat(byte[] b) throws Exception { Integer l = decodeInteger(b); return Float.valueOf(Float.intBitsToFloat(l.intValue())); }
From source file:com.googlecode.psiprobe.Utils.java
public static int toInt(Integer num, int defaultValue) { return num == null ? defaultValue : num.intValue(); }
From source file:edu.utah.further.core.api.collections.ArrayUtil.java
/** * @param set// ww w . j a v a 2 s .co m * @return */ public static double[] toDoubleArray(final SortedSet<Integer> set) { final int length = set.size(); final double[] doubleArray = new double[length]; int i = 0; for (final Integer element : set) { doubleArray[i] = element.intValue(); i++; } return doubleArray; }
From source file:controllers.AjaxServices.java
private static void setPriceByList(List<StockModel> modelList, Integer contactId) { if (contactId != null && contactId.intValue() > 0) { try {//w w w . j ava2s.c om Contact contact = Contact.findById(contactId); StockPriceList priceList = contact.priceList; if (priceList != null && priceList.isActive) { Date today = new Date(); if (DateUtils.isLessThan(today, priceList.startDate)) return; if (DateUtils.isGreateThan(today, priceList.endDate)) return; for (StockModel stockModel : modelList) { Stock stock = Stock.findById(stockModel.id); if (stock != null) { boolean[] check = new boolean[12]; for (int i = 0; i < check.length; i++) { check[i] = true; } if (priceList.category != null && !priceList.category.equals(stock.category)) check[0] = false; if (priceList.providerCode != null && !priceList.providerCode.equals(stock.providerCode)) check[1] = false; if (priceList.extraField0 != null && !priceList.extraField0.equals(stock.extraField0)) check[2] = false; if (priceList.extraField1 != null && !priceList.extraField1.equals(stock.extraField1)) check[3] = false; if (priceList.extraField2 != null && !priceList.extraField2.equals(stock.extraField2)) check[4] = false; if (priceList.extraField3 != null && !priceList.extraField3.equals(stock.extraField3)) check[5] = false; if (priceList.extraField4 != null && !priceList.extraField4.equals(stock.extraField4)) check[6] = false; if (priceList.extraField5 != null && !priceList.extraField5.equals(stock.extraField5)) check[7] = false; if (priceList.extraField6 != null && !priceList.extraField6.equals(stock.extraField6)) check[8] = false; if (priceList.extraField7 != null && !priceList.extraField7.equals(stock.extraField7)) check[9] = false; if (priceList.extraField8 != null && !priceList.extraField8.equals(stock.extraField8)) check[10] = false; if (priceList.extraField9 != null && !priceList.extraField9.equals(stock.extraField9)) check[11] = false; boolean isSuitable = true; for (int i = 0; i < check.length; i++) { if (!check[i]) { isSuitable = false; break; } } if (isSuitable) { boolean isSellPrice = (priceList.isSellPrice != null && priceList.isSellPrice); double price = (isSellPrice ? stock.sellPrice : stock.buyPrice); if (EffectDirection.Increase.equals(priceList.effectDirection)) { if (EffectType.Percent.equals(priceList.effectType)) { price = price + ((price * priceList.effect) / 100); } else { price = price + priceList.effect; } } else { if (EffectType.Percent.equals(priceList.effectType)) { price = price - ((price * priceList.effect) / 100); } else { price = price - priceList.effect; } } if (isSellPrice) { stockModel.sellPrice = NumericUtils.round(price); } else { stockModel.buyPrice = NumericUtils.round(price); } } } } } } catch (Exception e) { ; } } }
From source file:jenkins.plugins.logstash.persistence.IndexerDaoFactory.java
/** * Singleton instance accessor.// ww w . ja v a2 s . c o m * * @param type * The type of indexer, not null * @param host * The host name or IP address of the indexer, not null * @param port * The port the indexer listens on * @param key * The subcollection to write to in the indexer, not null * @param username * The user name to authenticate with the indexer, nullable * @param password * The password to authenticate with the indexer, nullable * @return The instance of the appropriate indexer DAO, never null * @throws InstantiationException */ public static synchronized LogstashIndexerDao getInstance(IndexerType type, String host, Integer port, String key, String username, String password) throws InstantiationException { if (!INDEXER_MAP.containsKey(type)) { throw new InstantiationException("[logstash-plugin]: Unknown IndexerType '" + type + "'. Did you forget to configure the plugin?"); } // Prevent NPE port = (port == null ? -1 : port.intValue()); if (shouldRefreshInstance(type, host, port, key, username, password)) { try { Class<?> indexerClass = INDEXER_MAP.get(type); Constructor<?> constructor = indexerClass.getConstructor(String.class, int.class, String.class, String.class, String.class); instance = (AbstractLogstashIndexerDao) constructor.newInstance(host, port, key, username, password); } catch (NoSuchMethodException e) { throw new InstantiationException(ExceptionUtils.getRootCauseMessage(e)); } catch (InvocationTargetException e) { throw new InstantiationException(ExceptionUtils.getRootCauseMessage(e)); } catch (IllegalAccessException e) { throw new InstantiationException(ExceptionUtils.getRootCauseMessage(e)); } } return instance; }
From source file:com.aurel.track.admin.customize.treeConfig.field.FieldBL.java
/** * Whether the field is a custom select field * @param fieldID//from w ww . j a va 2 s. c o m * @return */ public static boolean isCustomSelect(Integer fieldID) { if (fieldID != null) { IFieldTypeRT fieldTypeRT = null; if (fieldID.intValue() > 0) { //not a pseudo field fieldTypeRT = FieldTypeManager.getFieldTypeRT(fieldID); } if (fieldTypeRT != null && fieldTypeRT.isCustom()) { ICustomFieldTypeRT customFieldTypeRT = (ICustomFieldTypeRT) fieldTypeRT; return customFieldTypeRT.isCustomSelect() && customFieldTypeRT.isLookup(); } } return false; }
From source file:com.datos.vfs.provider.sftp.SftpClientFactory.java
/** * Creates a new connection to the server. * * @param hostname The name of the host to connect to. * @param port The port to use.//from w w w.java2 s . c o m * @param username The user's id. * @param password The user's password. * @param fileSystemOptions The FileSystem options. * @return A Session. * @throws FileSystemException if an error occurs. */ public static Session createConnection(final String hostname, final int port, final char[] username, final char[] password, final FileSystemOptions fileSystemOptions) throws FileSystemException { final JSch jsch = new JSch(); File sshDir = null; // new style - user passed final SftpFileSystemConfigBuilder builder = SftpFileSystemConfigBuilder.getInstance(); final File knownHostsFile = builder.getKnownHosts(fileSystemOptions); final IdentityInfo[] identities = builder.getIdentityInfo(fileSystemOptions); final IdentityRepositoryFactory repositoryFactory = builder.getIdentityRepositoryFactory(fileSystemOptions); sshDir = findSshDir(); setKnownHosts(jsch, sshDir, knownHostsFile); if (repositoryFactory != null) { jsch.setIdentityRepository(repositoryFactory.create(jsch)); } addIdentities(jsch, sshDir, identities); Session session; try { session = jsch.getSession(new String(username), hostname, port); if (password != null) { session.setPassword(new String(password)); } final Integer timeout = builder.getTimeout(fileSystemOptions); if (timeout != null) { session.setTimeout(timeout.intValue()); } final UserInfo userInfo = builder.getUserInfo(fileSystemOptions); if (userInfo != null) { session.setUserInfo(userInfo); } final Properties config = new Properties(); // set StrictHostKeyChecking property final String strictHostKeyChecking = builder.getStrictHostKeyChecking(fileSystemOptions); if (strictHostKeyChecking != null) { config.setProperty("StrictHostKeyChecking", strictHostKeyChecking); } // set PreferredAuthentications property final String preferredAuthentications = builder.getPreferredAuthentications(fileSystemOptions); if (preferredAuthentications != null) { config.setProperty("PreferredAuthentications", preferredAuthentications); } // set compression property final String compression = builder.getCompression(fileSystemOptions); if (compression != null) { config.setProperty("compression.s2c", compression); config.setProperty("compression.c2s", compression); } final String proxyHost = builder.getProxyHost(fileSystemOptions); if (proxyHost != null) { final int proxyPort = builder.getProxyPort(fileSystemOptions); final SftpFileSystemConfigBuilder.ProxyType proxyType = builder.getProxyType(fileSystemOptions); Proxy proxy = null; if (SftpFileSystemConfigBuilder.PROXY_HTTP.equals(proxyType)) { proxy = createProxyHTTP(proxyHost, proxyPort); } else if (SftpFileSystemConfigBuilder.PROXY_SOCKS5.equals(proxyType)) { proxy = createProxySOCKS5(proxyHost, proxyPort); } else if (SftpFileSystemConfigBuilder.PROXY_STREAM.equals(proxyType)) { proxy = createStreamProxy(proxyHost, proxyPort, fileSystemOptions, builder); } if (proxy != null) { session.setProxy(proxy); } } // set properties for the session if (config.size() > 0) { session.setConfig(config); } session.setDaemonThread(true); session.connect(); } catch (final Exception exc) { throw new FileSystemException("vfs.provider.sftp/connect.error", exc, hostname); } return session; }
From source file:com.prowidesoftware.swift.model.SwiftBlockUser.java
/** * Checks if the block number is valid for a user defined block. * Invalid blocks are blocks null or values 1-5 inclusive, all other values are considered valid. * /*from w w w. jav a 2 s . c o m*/ * @param blockNumber the block number * @return true if the block name and number are valid * * @since 5.0 */ static public Boolean isValidName(Integer blockNumber) { // name and number must be defined if (blockNumber == null) return (Boolean.FALSE); // block number must not be 1-5 if (blockNumber.intValue() != -1) { if (1 <= blockNumber.intValue() && blockNumber.intValue() <= 5) return (Boolean.FALSE); } ; return (Boolean.TRUE); }
From source file:forge.deck.generation.DeckGeneratorBase.java
protected static void increment(Map<String, Integer> map, String key, int delta) { final Integer boxed = map.get(key); map.put(key, boxed == null ? delta : boxed.intValue() + delta); }
From source file:com.agiletec.plugins.jacms.aps.system.services.content.widget.ContentListHelper.java
protected static String buildCacheKey(String listName, Collection<String> userGroupCodes, RequestContext reqCtx) {//from w w w.j av a 2 s . com IPage page = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE); StringBuilder cacheKey = new StringBuilder(page.getCode()); Widget currentWidget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET); if (null != currentWidget) { cacheKey.append("_").append(currentWidget.getType().getCode()); } Integer frame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME); cacheKey.append("_").append(frame.intValue()); Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG); cacheKey.append("_LANG").append(currentLang.getCode()).append("_"); List<String> groupCodes = new ArrayList<String>(userGroupCodes); if (!groupCodes.contains(Group.FREE_GROUP_NAME)) { groupCodes.add(Group.FREE_GROUP_NAME); } Collections.sort(groupCodes); for (int i = 0; i < groupCodes.size(); i++) { String code = (String) groupCodes.get(i); cacheKey.append("_").append(code); } if (null != currentWidget && null != currentWidget.getConfig()) { List<String> paramKeys = new ArrayList(currentWidget.getConfig().keySet()); Collections.sort(paramKeys); for (int i = 0; i < paramKeys.size(); i++) { if (i == 0) { cacheKey.append("_WIDGETPARAM"); } else { cacheKey.append(","); } String paramkey = (String) paramKeys.get(i); cacheKey.append(paramkey).append("=").append(currentWidget.getConfig().getProperty(paramkey)); } } if (null != listName) { cacheKey.append("_LISTNAME").append(listName); } return cacheKey.toString(); }