List of usage examples for java.lang Integer valueOf
@HotSpotIntrinsicCandidate public static Integer valueOf(int i)
From source file:ch.algotrader.util.HibernateUtil.java
/** * Gets the descriminator value based on the given class. */// w w w . j a v a 2s . c o m public static int getDisriminatorValue(SessionFactory sessionFactory, Class<?> type) { AbstractEntityPersister persister = getEntityPersister(sessionFactory, type); return Integer.valueOf(persister.getDiscriminatorSQLValue()); }
From source file:automaticdatabaseupdate.FileHandler.java
/** * * @param strFilePath - path of given file e.g. "D:\\EGYETEM\\Szakdolgozat\\Mernoki_tervezes\\update files\\sr28upd\\ADD_NUTR.txt" * @param strFileType - type of the given file e.g. AddFood * @param TList - list to fill with data e.g. List<FileFoodStruct> ListFFS *///w w w .ja va2 s .c om public static <T> void readFile(String strFilePath, List<T> TList, String strFileType) { TList.clear(); try { File file = FileUtils.getFile(strFilePath); LineIterator iter = FileUtils.lineIterator(file); while (iter.hasNext()) { String strLine = iter.next(); switch (strFileType) { case "ADD_FOOD": { ArrayList<String> strList = ParseUpdateFile(strLine); FileFoodStruct Object = new FileFoodStruct(Integer.valueOf(strList.get(0)), strList.get(2), strList.get(3), Integer.valueOf(strList.get(8))); TList.add((T) Object); System.out.println(Object.toString()); break; } case "ADD_NUTR": { ArrayList<String> strList = ParseUpdateFile(strLine); FileNutrientStruct Object = new FileNutrientStruct(Integer.valueOf(strList.get(0)), Integer.valueOf(strList.get(1)), Double.valueOf(strList.get(2))); TList.add((T) Object); System.out.println(Object.toString()); break; } case "ADD_WGT": { ArrayList<String> strList = ParseUpdateFile(strLine); FileWeightStruct Object = new FileWeightStruct(Integer.valueOf(strList.get(0)), Double.valueOf(strList.get(2)), strList.get(3), Double.valueOf(strList.get(4))); TList.add((T) Object); System.out.println(Object.toString()); break; } case "CHG_FOOD": { ArrayList<String> strList = ParseUpdateFile(strLine); FileFoodStruct Object = new FileFoodStruct(Integer.valueOf(strList.get(0)), strList.get(2), strList.get(3), Integer.valueOf(strList.get(8))); TList.add((T) Object); System.out.println(Object.toString()); break; } case "CHG_NUTR": { ArrayList<String> strList = ParseUpdateFile(strLine); FileNutrientStruct Object = new FileNutrientStruct(Integer.valueOf(strList.get(0)), Integer.valueOf(strList.get(1)), Double.valueOf(strList.get(2))); TList.add((T) Object); System.out.println(Object.toString()); break; } case "CHG_WGT": { ArrayList<String> strList = ParseUpdateFile(strLine); FileWeightStruct Object = new FileWeightStruct(Integer.valueOf(strList.get(0)), Double.valueOf(strList.get(2)), strList.get(3), Double.valueOf(strList.get(4))); TList.add((T) Object); System.out.println(Object.toString()); break; } case "DEL_FOOD": { ArrayList<String> strList = ParseUpdateFile(strLine); FileFoodStruct Object = new FileFoodStruct(Integer.valueOf(strList.get(0)), strList.get(1)); TList.add((T) Object); System.out.println(Object.toString()); break; } case "DEL_NUTR": { ArrayList<String> strList = ParseUpdateFile(strLine); FileNutrientStruct Object = new FileNutrientStruct(Integer.valueOf(strList.get(0)), Integer.valueOf(strList.get(1))); TList.add((T) Object); System.out.println(Object.toString()); break; } case "DEL_WGT": { ArrayList<String> strList = ParseUpdateFile(strLine); FileWeightStruct Object = new FileWeightStruct(Integer.valueOf(strList.get(0)), Double.valueOf(strList.get(2)), strList.get(3), Double.valueOf(strList.get(4))); TList.add((T) Object); System.out.println(Object.toString()); break; } case "LOG_FILE": { ArrayList<String> strList = ParseLogFile(strLine); TraceMessage Object = new TraceMessage(strList.get(0), strList.get(1)); TList.add((T) Object); break; } } } //System.out.println( "Total line: " + moduleCounter ); iter.close(); } catch (IOException ex) { Logger.getLogger(FileHandler.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.jim.im.utils.ImUtils.java
/** * ??int/* w w w . jav a2s.c o m*/ * * @param sources * @throws ImParamException */ public static Integer[] transferString2Int(String[] sources, String errorMsg) throws ImParamException { Integer[] result = ArrayUtils.isEmpty(sources) ? new Integer[0] : new Integer[sources.length]; try { for (int index = 0; index < result.length; index++) { result[index] = Integer.valueOf(sources[index]); } } catch (NumberFormatException e) { ImParamExceptionAssert.check(false, errorMsg); } return result; }
From source file:de.mpg.imeji.presentation.util.ProxyHelper.java
/** * check if proxy has to get used for given url. * If yes, set ProxyHost in httpClient//from ww w. ja v a 2 s . co m * * @param url url * * @throws Exception */ public static void setProxy(final HttpClient httpClient, final String url) { getProxyProperties(); if (proxyHost != null) { org.apache.commons.httpclient.HostConfiguration hc = httpClient.getHostConfiguration(); if (findUrlInNonProxyHosts(url)) { hc.setProxyHost(null); } else { hc.setProxy(proxyHost, Integer.valueOf(proxyPort)); } } }
From source file:com.catalog.repository.util.DomainUtil.java
public static ApplicationUser getTestApplicationUser() { ApplicationUser applicationUser = new ApplicationUser(); applicationUser.setEmailAddress(RandomStringUtils.randomAlphanumeric(RANDOM_LENGTH)); applicationUser.setFirstName(RandomStringUtils.randomAlphanumeric(RANDOM_LENGTH)); applicationUser.setGender(RandomStringUtils.randomAlphanumeric(RANDOM_LENGTH)); applicationUser.setAge(Integer.valueOf(RandomStringUtils.randomNumeric(RANDOM_LENGTH))); applicationUser.setLastName(RandomStringUtils.randomAlphanumeric(RANDOM_LENGTH)); applicationUser.setPassword(RandomStringUtils.randomAlphanumeric(RANDOM_LENGTH)); return applicationUser; }
From source file:Main.java
public static ArrayList<Integer> getRandomNumbers(int range, int count, Random rnd) { if (count > range) { return null; }//from w ww. j av a2s . co m if (count < 0 || range < 0) { return null; } HashMap<Integer, Integer> used = new HashMap<Integer, Integer>(); ArrayList<Integer> indices = new ArrayList<Integer>(); int n = range; while (indices.size() < count) { Integer r = Integer.valueOf(rnd.nextInt(n)); if (used.containsKey(r)) { indices.add(used.get(r)); } else { indices.add(r); } addToUsed(used, r, n - 1); n--; } return indices; }
From source file:com.qcadoo.model.api.IntegerUtils.java
/** * Converts value, if null returns zero/* w w w. ja v a 2 s. c o m*/ * * @param value * value * * @return value or zero */ public static Integer convertNullToZero(final Object value) { if (value == null) { return 0; } if (value instanceof Integer) { return (Integer) value; } return Integer.valueOf(value.toString()); }
From source file:org.eclipse.lyo.testsuite.server.trsutils.HttpErrorHandler.java
/** * Handle a possible HTTP error response. * //from w w w. j a v a2 s . com * @param response * The HTTP response to handle; must not be <code>null</code> * @throws HttpResponseException * if the response status code maps to an exception class */ public static void responseToException(HttpResponse response) throws HttpResponseException { if (response == null) throw new IllegalArgumentException(Messages.getServerString("http.error.handler.null.argument")); //$NON-NLS-1$ Integer status = Integer.valueOf(response.getStatusLine().getStatusCode()); //Create detail message from response status line and body String reasonPhrase = response.getStatusLine().getReasonPhrase(); StringBuilder message = new StringBuilder(reasonPhrase == null ? "" : reasonPhrase); //$NON-NLS-1$ if (response.getEntity() != null) { try { String body = EntityUtils.toString(response.getEntity(), HTTP.UTF_8); if (body != null && body.length() != 0) { message.append('\n'); message.append(body); } } catch (IOException e) { } // ignore, since the original error needs to be reported } throw new HttpResponseException(status, message.toString()); }
From source file:org.cloudifysource.esc.driver.provisioning.jclouds.ProvisioningUtils.java
public static Set<Integer> delimitedStringToSet(final String componentInstanceIDs) throws NumberFormatException { final String[] delimited = componentInstanceIDs.split(","); final Set<Integer> intSet = new HashSet<Integer>(); for (final String str : delimited) { intSet.add(Integer.valueOf(str)); }/*from ww w . j a v a2 s. co m*/ return intSet; }
From source file:com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision.java
public static DependencyMaterialRevision create(String stringRevision, String pipelineLabel) { String[] strings = stringRevision.split("/"); return DependencyMaterialRevision.create(strings[0], Integer.parseInt(strings[1]), pipelineLabel, strings[2], Integer.valueOf(strings[3])); }