List of usage examples for java.util UUID nameUUIDFromBytes
public static UUID nameUUIDFromBytes(byte[] name)
From source file:com.comcast.cns.util.Util.java
public static String generateCnsTopicSubscriptionArn(String topicArn, CnsSubscriptionProtocol protocol, String endpoint) throws NoSuchAlgorithmException { MessageDigest m = MessageDigest.getInstance("MD5"); String name = protocol + ":" + endpoint; byte bytes[] = m.digest(name.getBytes()); return topicArn + ":" + UUID.nameUUIDFromBytes(bytes).toString(); }
From source file:com.googlecode.deadalus.games.bomberman.ObjectFactoryTests.java
@Test public void testGenerateUUID() { System.out.println(UUID.nameUUIDFromBytes(Player.class.getName().getBytes(Charset.forName("UTF-8")))); System.out.println(UUID.randomUUID()); System.out.println(Bomb.class.getName()); System.out.println(UUID.nameUUIDFromBytes( "com.googlecode.deadalus.games.bomberman.objects.Bomb".getBytes(Charset.forName("UTF-8")))); System.out.println(UUID.nameUUIDFromBytes( "com.googlecode.deadalus.games.bomberman.objects.Bomb".getBytes(Charset.forName("UTF-8")))); }
From source file:org.eclipse.recommenders.utils.rcp.UUIDHelper.java
private static Optional<String> generateUUIDFromMacAddress() { try {// w w w . j ava 2 s .c om final Enumeration<NetworkInterface> e = getNetworkInterfaces(); for (final NetworkInterface net : iterable(e)) { final byte[] mac = net.getHardwareAddress(); if (ArrayUtils.isEmpty(mac)) { continue; } final String uuid = UUID.nameUUIDFromBytes(mac).toString(); if (Strings.isNullOrEmpty(uuid)) { continue; } return fromNullable(uuid); } } catch (final Exception e) { // this is odd: e.printStackTrace(); } return absent(); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.CustomDatatypeRepresentation.java
public void setDatatypeClassname(String datatypeClass) { this.datatypeClassname = datatypeClass; this.uuid = UUID.nameUUIDFromBytes(datatypeClassname.getBytes()).toString(); }
From source file:org.hawkular.accounts.api.model.BaseEntity.java
/** * @deprecated Use the BaseEntity(UUID) instead. * @param id the ID as String to be parsed as UUID. *///from w w w . j a va 2 s .c o m public BaseEntity(String id) { if (null != id) { if (!UUID_PATTERN.matcher(id).matches()) { // not an UUID, so, let's convert it to UUID this.id = UUID.nameUUIDFromBytes(id.getBytes()); } else { this.id = UUID.fromString(id); } } }
From source file:org.nebulaframework.grid.ID.java
/** * Returns the Identifier for the invoking Grid Member, * which is dependent on the MAC Address and the current * time or random UUID if MAC Address is not * available./*w w w . j a v a 2s . com*/ * * @return UUID Identifier */ public static UUID getId() { String mac = null; try { mac = getMACAddress(); } catch (Exception e) { log.warn("Unalbe to obtain MAC Address", e); } if (mac != null) { // MAC Info available, use it to generate UUID return UUID.nameUUIDFromBytes((mac + (new Date()).getTime()).getBytes()); } else { // MAC Info not available, fallback to Random UUID return UUID.randomUUID(); } }
From source file:eu.loopit.f2011.library.BitmapManager.java
public Bitmap fetchBitmap(String urlString, final Bitmap defaultImage) { UUID uuid = UUID.nameUUIDFromBytes(urlString.getBytes()); if (bitmapMap.containsKey(uuid)) { return bitmapMap.get(uuid); }//www.j a v a2 s . c o m Log.d(TAG, "image url:" + urlString); InputStream is = null; try { is = fetch(uuid); if (is == null) is = fetch(urlString); Bitmap bitmap = BitmapFactory.decodeStream(is); if (bitmap == null && defaultImage == null) { Log.i(TAG, "Could not load: " + urlString); return null; } bitmapMap.put(uuid, bitmap != null ? bitmap : defaultImage); Log.d(TAG, "Got Bitmap: " + urlString); return bitmapMap.get(uuid); } catch (MalformedURLException e) { Log.e(TAG, "fetchBitmap failed", e); return null; } catch (IOException e) { Log.e(TAG, "fetchBitmap failed", e); return null; } finally { if (is != null) { try { is.close(); } catch (IOException e) { Log.e(TAG, "Could not close stream for URL" + urlString, e); } } } }
From source file:net.daporkchop.porkbot.command.minecraft.CommandOfflineUUID.java
@Override @SuppressWarnings("deprecation") public void execute(MessageReceivedEvent evt, String[] args, String message) { if (args.length < 2 || args[1].isEmpty()) { sendErrorMessage(evt.getTextChannel(), "Name isn't given!"); return;//w w w. jav a 2 s. com } String msg = args[1] + "'s offline UUID:\n```\n" + UUID.nameUUIDFromBytes(("OfflinePlayer:" + args[1]).getBytes(Charsets.UTF_8)).toString() + "\n```"; MessageUtils.sendMessage(msg, evt.getTextChannel()); }
From source file:com.feedzai.fos.impl.dummy.DummyManager.java
@Override public UUID trainAndAdd(ModelConfig config, List<Object[]> instances) { try {// w ww . j a va2s .c om logger.trace("config='{}', instances='{}'", mapper.writeValueAsString(config), mapper.writeValueAsString(instances)); } catch (IOException e) { logger.error(e.getMessage(), e); } return UUID.nameUUIDFromBytes(new byte[0]); }
From source file:com.dynatrace.cf.servicebroker.catalog.CatalogFactory.java
@Bean Catalog catalog(@Value("${DYNATRACE_SERVICE_PLANS}") String dynatracePlans) throws Exception { System.out.println("DYNATRACE_SERVICE_PLANS set to: " + dynatracePlans); String serviceId = UUID.nameUUIDFromBytes("Dynatrace_ServiceId_v12".getBytes()).toString(); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); plans = (Map) objectMapper.readValue(dynatracePlans, objectMapper.getTypeFactory() .constructMapLikeType(HashMap.class, String.class, DynatracePlan.class)); for (DynatracePlan p : plans.values()) { p.setPlanId();/*from w w w . j a v a2 s . co m*/ System.out.println("\t\tDynatracePlan: " + p); } return new Catalog().service().id(UUID.fromString(serviceId)).name("dynatrace").description( "Dynatrace is all-in-one full stack performance monitoring and management powered by artificial intelligence") .bindable(Boolean.valueOf(true)) .tags(new String[] { "dynatrace", "performance", "monitoring", "apm", "analytics" }).metadata() .displayName("Dynatrace") .imageUrl( URI.create("https://assets.dynatrace.com/global/resources/Signet_Logo_RGB_CP_48x48px.png")) .longDescription("Dynatrace is all-in-one full stack performance " + "monitoring and management powered by artificial " + "intelligence that provides you with automated application-health " + "and root-cause analysis information to quickly identify " + "performance bottlenecks in browsers, databases and code.") .providerDisplayName("Dynatrace LLC").documentationUrl(URI.create("https://help.dynatrace.com")) .supportUrl(URI.create("https://support.ruxit.com")).and().addAllPlans(plans).and(); }