List of usage examples for java.lang Long toString
public String toString()
From source file:com.redhat.rhn.frontend.action.common.test.RhnSetActionTest.java
public static void verifyRhnSetData(Long uid, String setname, int size) throws HibernateException, SQLException { Session session = null;// w ww .j av a 2 s.co m Connection c = null; Statement stmt = null; ResultSet rs = null; try { session = HibernateFactory.getSession(); session.flush(); c = session.connection(); stmt = c.createStatement(); String query = "select * from rhnset where user_id = " + uid.toString(); rs = stmt.executeQuery(query); assertNotNull(rs); int cnt = 0; while (rs.next()) { assertEquals(uid.longValue(), rs.getLong("USER_ID")); assertEquals(setname, rs.getString("LABEL")); cnt++; } assertEquals(size, cnt); } catch (SQLException e) { log.error("Error validating data.", e); throw e; } finally { HibernateHelper.cleanupDB(rs, stmt); } }
From source file:com.cloudera.flume.conf.FlumeBuilder.java
/** * All of factories expect all string arguments. * //w ww .j a va2s . c o m * Numbers are expected to be in decimal format. * * If it is of type KWARG, it returns null * * TODO (jon) move to builders, or allow builders to take Integers/Booleans as * well as Strings */ public static String buildSimpleArg(CommonTree t) throws FlumeSpecException { ASTNODE type = ASTNODE.valueOf(t.getText()); // convert to enum switch (type) { case HEX: String hex = t.getChild(0).getText(); Preconditions.checkArgument(hex.startsWith("0x")); // bad parser if this // happens hex = hex.substring(2); Long i = Long.parseLong(hex, 16); // use base 16 radix return i.toString(); case DEC: return t.getChild(0).getText(); case BOOL: return t.getChild(0).getText(); case OCT: String oct = t.getChild(0).getText(); // bad parser if these happen Preconditions.checkArgument(oct.startsWith("0")); Preconditions.checkArgument(!oct.startsWith("0x")); Long i2 = Long.parseLong(oct, 8); // us base 16 radix return i2.toString(); case FLOAT: return t.getChild(0).getText(); case STRING: String str = t.getChild(0).getText(); Preconditions.checkArgument(str.startsWith("\"") && str.endsWith("\"")); str = str.substring(1, str.length() - 1); return StringEscapeUtils.unescapeJava(str); case KWARG: return null; default: throw new FlumeSpecException("Not a node of literal type: " + t.toStringTree()); } }
From source file:com.weavers.duqhan.util.GoogleBucketFileUploader.java
public static String uploadProductImage(MultipartFile file, Long productId) { InputStream targetStream = null; String imgUrl = "failure"; if (file != null) { try {/*from w ww .j a v a 2 s. co m*/ GoogleBucketFileUploader fileUploader = new GoogleBucketFileUploader(); Storage storage = fileUploader.authentication(); targetStream = file.getInputStream(); if (targetStream != null) { DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS"); DateTime dt = DateTime.now(DateTimeZone.UTC); String dtString = dt.toString(dtf); final String fileName = "img_" + productId.toString() + dtString + ".jpg"; // the inputstream is closed by default, so we don't need to close it here BlobInfo blobInfo = storage.create( BlobInfo.newBuilder(PRODUCT_BUCKET_NAME, fileName).setContentType("image/jpeg") // Modify access list to allow all users with link to read file .setAcl(new ArrayList<>( Arrays.asList(Acl.of(Acl.User.ofAllUsers(), Acl.Role.OWNER)))) .build(), targetStream); // return the public view link // System.out.println("https://storage.googleapis.com/duqhan-users/" + blobInfo.getName()); imgUrl = "https://storage.googleapis.com/duqhan-images/" + blobInfo.getName(); } } catch (IOException ex) { Logger.getLogger(GoogleBucketFileUploader.class.getName()).log(Level.SEVERE, null, ex); } } return imgUrl; }
From source file:com.tweetlanes.android.core.App.java
public static String getAccountDescriptorKey(Long id) { return "account_descriptor_v2" + id.toString(); }
From source file:com.ingby.socbox.bischeck.cli.CacheCli.java
private static String execute(ExecuteJEP parser, String line) throws ParseException { Long startTime = System.currentTimeMillis(); //Parse the input line expression String parsedExpression = CacheEvaluator.parse(line); Long stopParseTime = System.currentTimeMillis() - startTime; Float resultValue = null;//from w w w . j av a2 s . c o m Long startExecuteTime = System.currentTimeMillis(); // Calculate the parsed expression resultValue = parser.execute(parsedExpression); Long stopExecuteTime = System.currentTimeMillis() - startExecuteTime; Long endTime = System.currentTimeMillis() - startTime; // Write the execution time StringBuilder strbu = new StringBuilder(); if (showtime) { strbu.append("[" + stopParseTime.toString() + "/" + stopExecuteTime.toString() + "/" + endTime.toString() + " ms] "); } // Write the parsed expression if (showparse) { strbu.append(parsedExpression); strbu.append(" = "); } // Write the calculated result if (resultValue != null) { strbu.append(new BischeckDecimal(resultValue).toString()); } else { strbu.append("null"); } return strbu.toString(); }
From source file:models.MBox.java
/** * Finds all Addresses which belong to a specific {@link User} given by the User-ID * //from w w w. ja va2 s . c om * @param id * ID of a {@link User} * @return returns all Boxes of a specific {@link User} */ public static List<MBox> allUser(Long id) { return Ebean.find(MBox.class).where().eq("usr_id", id.toString()).findList(); }
From source file:com.facebook.ads.sdk.HotelRoom.java
public static HotelRoom fetchById(Long id, APIContext context) throws APIException { return fetchById(id.toString(), context); }
From source file:ext.msg.model.Message.java
/** * ?id??//from w w w .j a va 2 s .c o m */ public static void deleteMessages(List<Long> s, Long userId) { JPA.em().createNativeQuery("delete from tb_message where id in (:ids) and consumeOnly = :userIdStr") .setParameter("ids", s).setParameter("userIdStr", userId.toString()).executeUpdate(); }
From source file:ca.uhn.fhir.model.primitive.IdDt.java
private static String toPlainStringWithNpeThrowIfNeeded(Long theIdPart) { if (theIdPart == null) { throw new NullPointerException("Long ID can not be null"); }//from w w w. java 2s . co m return theIdPart.toString(); }
From source file:models.MBox.java
/** * Returns a list of all ACTIVE e-mails of the given user * // ww w . j av a2s. c om * @param userId * the user-id * @return a list of e-mails */ public static String getActiveMailsForTxt(Long userId) { List<MBox> allActiveBoxes = Ebean.find(MBox.class).where().eq("usr_id", userId.toString()) .eq("expired", false).findList(); return getBoxListToText(allActiveBoxes); }