List of usage examples for java.lang Integer toString
public String toString()
From source file:com.evolveum.midpoint.prism.xml.XsdTypeMapper.java
public static String multiplicityToString(Integer integer) { if (integer == null) { return null; }/*from w w w. j a va 2 s . c o m*/ if (integer < 0) { return MULTIPLICITY_UNBOUNDED; } return integer.toString(); }
From source file:com.aurel.track.util.StringArrayParameterUtils.java
/** * Creates a comma separated string of integer values from a list of Integer * @param lst with Integer values//ww w .j av a2 s .com * @return a comma separated String with integers */ public static String createStringFromIntegerList(List<Integer> lst) { StringBuffer buf = new StringBuffer(); if (lst != null && !lst.isEmpty()) { Iterator<Integer> it = lst.iterator(); while (it.hasNext()) { Integer day = it.next(); buf.append(day.toString()); if (it.hasNext()) { buf.append(","); } } } return buf.toString(); }
From source file:Main.java
public static byte[] documentToByteArray(Document data, Integer indent) throws TransformerException { ByteArrayOutputStream result = new ByteArrayOutputStream(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); if (indent != null) { transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", indent.toString()); }/*ww w. j a v a 2s . co m*/ transformer.transform(new DOMSource(data), new StreamResult(result)); return result.toByteArray(); }
From source file:com.eho.dynamodb.DynamoDBConnection.java
public static UpdateItemOutcome update_resource(String resource) throws Exception { String id;// ww w .j a va2 s . c o m JSONObject json_resource = new JSONObject(resource); //does the resource have a primary key? if (json_resource.has(PRIMARY_KEY))//if it does not have a primary key, create one using uuid id = json_resource.getString(PRIMARY_KEY); else id = UUID.randomUUID().toString(); DynamoDB dynamoDB = new DynamoDB(dynamoDBClient); Table table = dynamoDB.getTable(PATIENT_TABLE); //lets retreive based on the key. if key invalid (not assigned yet) nullis returned. Item retreived_item = table.getItem(PRIMARY_KEY, id); if (retreived_item == null)//if null instantiate it { retreived_item = new Item(); retreived_item.withPrimaryKey(PRIMARY_KEY, id); } Integer new_version = retreived_item.getInt("version") + 1; retreived_item.withInt("version", new_version); String new_version_str = new_version.toString(); UpdateItemSpec updateItemSpec = new UpdateItemSpec().withPrimaryKey(PRIMARY_KEY, id) .withUpdateExpression("SET " + new_version_str + "= :newval") .withValueMap(new ValueMap().withString(":newval", resource)).withReturnValues(ReturnValue.ALL_NEW); return table.updateItem(updateItemSpec); }
From source file:br.com.diegosilva.jsfcomponents.util.Utils.java
public static String padInteger(Integer raw, int padding) { String rawInteger = raw.toString(); StringBuilder paddedInteger = new StringBuilder(); for (int padIndex = rawInteger.length(); padIndex < padding; padIndex++) { paddedInteger.append('0'); }/*from w w w . j ava 2 s .c o m*/ return paddedInteger.append(rawInteger).toString(); }
From source file:com.oDesk.api.oDeskRestClient.java
/** * Generate error as JSONObject/*from w ww . jav a 2 s . c om*/ * * @param code Error code * @param message Error message * @throws JSONException * @return {@link JSONObject} * */ private static JSONObject genError(Integer code, String message) throws JSONException { // TODO: HTTP-Status (404, etc), for now return status line return new JSONObject("{error: {code: \"" + code.toString() + "\", message: \"" + message + "\"}}"); }
From source file:com.github.koraktor.steamcondenser.steam.community.WebApi.java
/** * Fetches data from Steam Web API using the specified interface, method * and version. Additional parameters are supplied via HTTP GET. Data is * returned as a String in the given format. * * @param apiInterface The Web API interface to call, e.g. * <code>ISteamUser</code> * @param format The format to load from the API ("json", "vdf", or "xml") * @param method The Web API method to call, e.g. * <code>GetPlayerSummaries</code> * @param params Additional parameters to supply via HTTP GET * @param version The API method version to use * @return Data is returned as a String in the given format (which may be * "json", "vdf", or "xml")./*from ww w .jav a 2 s . co m*/ * @throws WebApiException In case of any request failure */ public static String load(String format, String apiInterface, String method, int version, Map<String, Object> params) throws WebApiException { String protocol = secure ? "https" : "http"; String url = String.format("%s://api.steampowered.com/%s/%s/v%04d/?", protocol, apiInterface, method, version); if (params == null) { params = new HashMap<String, Object>(); } params.put("format", format); if (apiKey != null) { params.put("key", apiKey); } boolean first = true; for (Map.Entry<String, Object> param : params.entrySet()) { if (first) { first = false; } else { url += '&'; } url += String.format("%s=%s", param.getKey(), param.getValue()); } if (LOG.isLoggable(Level.INFO)) { String debugUrl = (apiKey == null) ? url : url.replace(apiKey, "SECRET"); LOG.info("Querying Steam Web API: " + debugUrl); } String data; try { DefaultHttpClient httpClient = new DefaultHttpClient(); httpClient.getParams().setBooleanParameter(ClientPNames.HANDLE_AUTHENTICATION, false); HttpGet request = new HttpGet(url); HttpResponse response = httpClient.execute(request); Integer statusCode = response.getStatusLine().getStatusCode(); if (!statusCode.toString().startsWith("20")) { if (statusCode == 401) { throw new WebApiException(WebApiException.Cause.UNAUTHORIZED); } throw new WebApiException(WebApiException.Cause.HTTP_ERROR, statusCode, response.getStatusLine().getReasonPhrase()); } data = EntityUtils.toString(response.getEntity()); } catch (WebApiException e) { throw e; } catch (Exception e) { throw new WebApiException("Could not communicate with the Web API.", e); } return data; }
From source file:com.github.koraktor.steamcondenser.community.WebApi.java
/** * Fetches data from Steam Web API using the specified interface, method * and version. Additional parameters are supplied via HTTP GET. Data is * returned as a String in the given format. * * @param apiInterface The Web API interface to call, e.g. * <code>ISteamUser</code> * @param format The format to load from the API ("json", "vdf", or "xml") * @param method The Web API method to call, e.g. * <code>GetPlayerSummaries</code> * @param params Additional parameters to supply via HTTP GET * @param version The API method version to use * @return Data is returned as a String in the given format (which may be * "json", "vdf", or "xml").//from www . j ava 2 s. co m * @throws WebApiException In case of any request failure */ public static String load(String format, String apiInterface, String method, int version, Map<String, Object> params) throws WebApiException { String protocol = secure ? "https" : "http"; String url = String.format("%s://api.steampowered.com/%s/%s/v%04d/?", protocol, apiInterface, method, version); if (params == null) { params = new HashMap<String, Object>(); } params.put("format", format); if (apiKey != null) { params.put("key", apiKey); } boolean first = true; for (Map.Entry<String, Object> param : params.entrySet()) { if (first) { first = false; } else { url += '&'; } url += String.format("%s=%s", param.getKey(), param.getValue()); } if (LOG.isInfoEnabled()) { String debugUrl = (apiKey == null) ? url : url.replace(apiKey, "SECRET"); LOG.info("Querying Steam Web API: " + debugUrl); } String data; try { DefaultHttpClient httpClient = new DefaultHttpClient(); httpClient.getParams().setBooleanParameter(ClientPNames.HANDLE_AUTHENTICATION, false); HttpGet request = new HttpGet(url); HttpResponse response = httpClient.execute(request); Integer statusCode = response.getStatusLine().getStatusCode(); if (!statusCode.toString().startsWith("20")) { if (statusCode == 401) { throw new WebApiException(WebApiException.Cause.UNAUTHORIZED); } throw new WebApiException(WebApiException.Cause.HTTP_ERROR, statusCode, response.getStatusLine().getReasonPhrase()); } data = EntityUtils.toString(response.getEntity()); } catch (WebApiException e) { throw e; } catch (Exception e) { throw new WebApiException("Could not communicate with the Web API.", e); } return data; }
From source file:com.mobileman.projecth.web.util.PatientUtils.java
static String computeAge(Integer birthday) { LocaleService localeService = Services.getLocaleService(); String stringResult = localeService.getYearsUnknown(); Integer result = null; if (birthday != null) { SimpleDateFormat simpleDateformat = new SimpleDateFormat("yyyy"); Integer actualYear = new Integer(simpleDateformat.format(new Date())); result = actualYear - birthday;/*from www. java 2 s. c om*/ stringResult = result.toString() + " " + localeService.getYears(); //Jahre } return stringResult; }
From source file:uk.org.rbc1b.roms.controller.volunteer.VolunteerBadgePdfView.java
/** * Adds a Barcode39 of the id number of a Volunteer to the Badge. * * @param content to be added/* ww w . j av a 2s .c om*/ * @param id volunteer id * @throws DocumentException * @throws IOException */ private static void addBarcode(PdfContentByte contentByte, Integer id) throws IOException, DocumentException { Barcode39 barcode = new Barcode39(); BaseFont baseFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED); barcode.setFont(baseFont); barcode.setSize(6); barcode.setCode(id.toString()); contentByte.setColorFill(Color.BLACK); Image baecodeImg = barcode.createImageWithBarcode(contentByte, null, null); contentByte.addImage(baecodeImg, 75, 0, 0, 35, 338, 344); }