List of usage examples for java.lang Long valueOf
@HotSpotIntrinsicCandidate public static Long valueOf(long l)
From source file:com.rogiel.httpchannel.service.AbstractHttpDownloader.java
protected long getContentLength(HttpResponse response) { final Header contentLengthHeader = response.getFirstHeader("Content-Length"); long contentLength = -1; if (contentLengthHeader != null) { contentLength = Long.valueOf(contentLengthHeader.getValue()); }//from w w w . j a va 2 s. c om return contentLength; }
From source file:com.runwaysdk.business.generation.maven.TransferListener.java
@Override public void transferProgressed(TransferEvent event) { TransferResource resource = event.getResource(); downloads.put(resource, Long.valueOf(event.getTransferredBytes())); StringBuilder buffer = new StringBuilder(64); for (Map.Entry<TransferResource, Long> entry : downloads.entrySet()) { long total = entry.getKey().getContentLength(); long complete = entry.getValue().longValue(); buffer.append(getStatus(complete, total)).append(" "); }/*from w w w . j av a 2 s .c om*/ int pad = lastLength - buffer.length(); lastLength = buffer.length(); pad(buffer, pad); buffer.append('\r'); log.trace(buffer); }
From source file:sample.contact.ContactManagerTests.java
void assertContainsContact(long id, List<Contact> contacts) { for (Contact contact : contacts) { if (contact.getId().equals(Long.valueOf(id))) { return; }/*from w w w . ja v a 2 s. c o m*/ } fail("List of contacts should have contained: " + id); }
From source file:com.csc.fsg.life.biz.copyobject.XgErrorAreaErrorArrayCopyObject.java
/** Default XgErrorAreaErrorArrayCopyObject constructor. Creates this object and initializes all fields and sub-objects with default values. @throws CopyObjectException If there is an initialization problem. **//*www. j a v a2 s. c o m*/ public XgErrorAreaErrorArrayCopyObject() throws CopyObjectException { bytes = new byte[200]; try { setErrorFieldDisplacement(Long.valueOf(0)); setErrorCode(""); setErrorLevel(""); setErrorMessage(""); setMiscDetail(""); } catch (NumberFormatException nfE) { throw new CopyObjectException(nfE.getMessage()); } }
From source file:com.lenovo.tensorhusky.common.utils.ProcessIdFileReader.java
/** * Get the process id from specified file path. Parses each line to find a * valid number and returns the first one found. * * @return Process Id if obtained from path specified else null * @throws IOException// w w w .ja va2s .c om */ public static String getProcessId(Path path, boolean check) throws IOException { if (path == null) { throw new IOException("Trying to access process id from a null path"); } LOG.debug("Accessing pid from pid file " + path); String processId = null; BufferedReader bufReader = null; try { File file = new File(path.toString()); if (file.exists()) { FileInputStream fis = new FileInputStream(file); bufReader = new BufferedReader(new InputStreamReader(fis, "UTF-8")); while (true) { String line = bufReader.readLine(); if (line == null) { break; } String temp = line.trim(); if (!temp.isEmpty()) { if (Shell.WINDOWS) { // On Windows, pid is expected to be a container ID, so // find first // line that parses successfully as a container ID. try { processId = temp; break; } catch (Exception e) { // do nothing } } else { // Otherwise, find first line containing a numeric pid. if (check) { try { Long pid = Long.valueOf(temp); if (pid > 0) { processId = temp; break; } } catch (Exception e) { // do nothing } } else { processId = temp; } } } } } } finally { if (bufReader != null) { bufReader.close(); } } LOG.debug("Got pid " + (processId != null ? processId : "null") + " from path " + path); return processId; }
From source file:com.examples.abelanav2.grpcclient.CacheStore.java
/** * Constructor./* ww w .j av a 2 s .c om*/ * @param pContext the application context. */ public CacheStore(Context pContext) { this.mContext = pContext; mPhotoLists = new HashMap<>(); mPhotoListsNextPage = new HashMap<>(); if (!restore()) { mPhotoLists.put(AbelanaClient.PhotoListType.PHOTO_LIST_LIKES, new ArrayList<PhotoInfo>()); mPhotoLists.put(AbelanaClient.PhotoListType.PHOTO_LIST_STREAM, new ArrayList<PhotoInfo>()); mPhotoLists.put(AbelanaClient.PhotoListType.PHOTO_LIST_MINE, new ArrayList<PhotoInfo>()); mPhotoListsNextPage.put(AbelanaClient.PhotoListType.PHOTO_LIST_LIKES, Long.valueOf(0)); mPhotoListsNextPage.put(AbelanaClient.PhotoListType.PHOTO_LIST_STREAM, Long.valueOf(0)); mPhotoListsNextPage.put(AbelanaClient.PhotoListType.PHOTO_LIST_MINE, Long.valueOf(0)); } }
From source file:com.anite.antelope.modules.actions.security.SelectGroup.java
public void doPerform(RunData data, Context context) { FormTool form = (FormTool) context.get(FormTool.DEFAULT_TOOL_NAME); SecurityTool security = (SecurityTool) context.get(SecurityTool.DEFAULT_TOOL_NAME); if (form.isAllValid()) { GroupManager groupManager;//from w w w.ja v a 2 s .c o m FieldMap fieldMap; Field groupIdField; DynamicGroup group; groupManager = security.getGroupManager(); fieldMap = form.getFields(); groupIdField = (Field) fieldMap.get("groupid"); if (!StringUtils.isEmpty(groupIdField.getValue())) { try { group = (DynamicGroup) groupManager.getGroupById(Long.valueOf(groupIdField.getValue())); context.put("selectedgroup", group); } catch (Exception e) { groupIdField.addMessage("Thats not a group!"); data.setScreenTemplate("security,Groups.vm"); } } else { groupIdField.addMessage("Please select a group!"); data.setScreenTemplate("security,Groups.vm"); } } }
From source file:com.symantec.cpe.config.ConfigHelper.java
/** * Load config from file: implement the function loadConfig, blind to users. */// ww w . j a v a 2 s .c o m private static Config loadConfigFromFile(String propertiesFileName) throws IOException { Config conf = new Config(); try { // Load configs from properties file LOG.debug("Loading properties from " + propertiesFileName); InputStream fileInputStream = new FileInputStream(propertiesFileName); Properties properties = new Properties(); try { properties.load(fileInputStream); } finally { fileInputStream.close(); } for (@SuppressWarnings("rawtypes") Map.Entry me : properties.entrySet()) { try { // Check every property and covert to appropriate data type before // adding it to storm config. If no data type defined keep it as string if (keyTypeMap.containsKey(me.getKey().toString())) { if (Number.class.equals(keyTypeMap.get(me.getKey().toString()))) { conf.put((String) me.getKey(), Long.valueOf(((String) me.getValue()).trim())); } else if (Map.class.equals(keyTypeMap.get(me.getKey().toString()))) { if (me.getValue() != null) { Map<String, Object> map = new HashMap<String, Object>(); String kvPairs[] = StringUtils.split(me.getValue().toString(), properties.getProperty("map.kv.pair.separator", ",")); for (String kvPair : kvPairs) { String kv[] = StringUtils.split(kvPair, properties.getProperty("map.kv.separator", "=")); map.put((String) kv[0], kv[1].trim()); } conf.put((String) me.getKey(), map); } } else if (Boolean.class.equals(keyTypeMap.get((String) me.getKey()))) { conf.put((String) me.getKey(), Boolean.valueOf(((String) me.getValue()).trim())); } } else { conf.put(me.getKey().toString(), me.getValue()); } } catch (NumberFormatException nfe) { LOG.error("Failed while loading properties from file " + propertiesFileName + ". The value '" + me.getValue() + "' for property " + me.getKey() + " is expected to be numeric", nfe); throw nfe; } } } catch (IOException ioe) { LOG.error("Failed while loading properties from file " + propertiesFileName, ioe); throw ioe; } return conf; }
From source file:es.warp.killthedj.track.AvailableTrack.java
public AvailableTrack(JSONObject json) throws JSONTrackParseException { for (String f : MANDATORY_FIELDS) { if (!json.has(f)) throw new JSONTrackParseException("JSON doesn't contain field " + f); }//from w ww . j av a 2s.c o m title = json.optString("title"); album = json.optString("album"); artist = json.optString("artist"); link = json.optString("link"); id = json.optString("id"); votes = json.optString("votes"); vote = json.optString("vote"); status = json.optString("status"); time = new Date(Long.valueOf(json.optString("time")) * 1000); position = json.optString("position"); }
From source file:jp.ambrosoli.http.server.action.IndexAction.java
@Execute(validator = false, urlPattern = "timeout/{to}") public String timeout() { try {/*from w w w . ja v a2 s . com*/ Thread.sleep(Long.valueOf(this.to)); } catch (InterruptedException e) { e.printStackTrace(); } ResponseUtil.getResponse().setStatus(200); return null; }