Java Code Examples for java.util.UUID
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project airlift, under directory /jmx-http-rpc/src/test/java/io/airlift/jmx/http/rpc/.
Source file: TestMBeanServerResource.java

@Test public void testSetAttribute() throws Exception { mbeanServerConnection.setAttribute(testMBeanName,new Attribute("Value","Foo")); assertEquals(testMBean.getValue(),"Foo"); mbeanServerConnection.setAttribute(testMBeanName,new Attribute("Value",null)); assertEquals(testMBean.getValue(),null); UUID uuid=UUID.randomUUID(); mbeanServerConnection.setAttribute(testMBeanName,new Attribute("ObjectValue",uuid)); assertEquals(testMBean.getObjectValue(),uuid); mbeanServerConnection.setAttribute(testMBeanName,new Attribute("ObjectValue",null)); assertEquals(testMBean.getObjectValue(),null); }
Example 2
From project androidquery, under directory /demo/src/com/androidquery/test/.
Source file: TestUtility.java

public static String getDeviceId(Context context){ if (deviceId == null) { TelephonyManager tm=(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); String tmDevice, tmSerial, tmPhone, androidId; tmDevice="" + tm.getDeviceId(); tmSerial="" + tm.getSimSerialNumber(); androidId="" + android.provider.Settings.Secure.getString(context.getContentResolver(),android.provider.Settings.Secure.ANDROID_ID); UUID deviceUuid=new UUID(androidId.hashCode(),((long)tmDevice.hashCode() << 32) | tmSerial.hashCode()); deviceId=deviceUuid.toString(); System.err.println(deviceId); } return deviceId; }
Example 3
From project android_5, under directory /src/aarddict/android/.
Source file: DictionaryService.java

@SuppressWarnings("unchecked") public Map<UUID,List<Volume>> getVolumes(){ Map<UUID,List<Volume>> result=new LinkedHashMap(); for ( Volume d : library) { UUID dictionaryId=d.getDictionaryId(); if (!result.containsKey(dictionaryId)) { result.put(dictionaryId,new ArrayList<Volume>()); } result.get(dictionaryId).add(d); } return result; }
Example 4
From project apollo, under directory /injector/src/test/java/com/bskyb/cg/environments/cassandra/.
Source file: TestCassandraDao.java

@Test public void testAdd() throws InterruptedException { long timestamp=System.currentTimeMillis(); UUID uuid=TimeUUIDUtils.getTimeUUID(timestamp); String epochtime=new Long(timestamp).toString(); String msgtype="auditd"; String rowkey="chicgdatapp109.cg.bskyb.com"; String hostname=""; try { cassandraDao.insert(uuid,epochtime,msgtype,testLog,rowkey,hostname); } catch ( CassandraException e) { e.printStackTrace(); } }
Example 5
From project Arecibo, under directory /aggregator/src/main/java/com/ning/arecibo/aggregator/impl/.
Source file: InternalDispatcherImpl.java

private UUID mapKeyToUUID(String key){ UUID uuid=cache.get(key); if (uuid == null) { uuid=UUIDUtil.md5UUID(key); cache.put(key,uuid); } return uuid; }
Example 6
From project astyanax, under directory /src/test/java/com/netflix/astyanax/util/.
Source file: TimeUUIDTest.java

@Test @Ignore public void testMicrosResolution(){ Clock clock=new MicrosecondsSyncClock(); long time=clock.getCurrentTime(); UUID uuid=TimeUUIDUtils.getUniqueTimeUUIDinMicros(); long uuidTime=TimeUUIDUtils.getMicrosTimeFromUUID(uuid); Assert.assertEquals(time / 10000,uuidTime / 10000); }
Example 7
From project bagheera, under directory /src/test/java/com/mozilla/bagheera/util/.
Source file: IdUtilTest.java

@Test public void testBucketizeIdWithTimestamp2() throws IOException { UUID uuid=UUID.randomUUID(); long ts=System.currentTimeMillis(); byte[] idBytes=IdUtil.bucketizeId(uuid.toString(),ts); assertNotNull(idBytes); String bucketIdStr=new String(idBytes); assertTrue(bucketIdStr.endsWith(IdUtil.SDF.format(new Date(ts)) + uuid.toString())); }
Example 8
From project beintoo-android-sdk, under directory /BeintooSDK/src/com/beintoo/beintoosdkutility/.
Source file: DeviceId.java

public static String getUniqueAndroidDeviceId(Context context){ final TelephonyManager tm=(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); String tmDevice, tmSerial, androidId=null; try { tmDevice="" + tm.getDeviceId(); tmSerial=tm.getSimSerialNumber() != null ? tm.getSimSerialNumber() : ""; androidId=android.provider.Settings.Secure.getString(context.getContentResolver(),android.provider.Settings.Secure.ANDROID_ID); if (androidId == null) { return toSHA1(DeveloperConfiguration.apiKey); } else if (androidId.equals(BUGGED_ANDROID_ID) && ("000000000000000".equals(tmDevice))) { return toSHA1(DeveloperConfiguration.apiKey); } else if ((androidId.equals(BUGGED_ANDROID_ID)) && (tmSerial.equals(""))) { return null; } else { UUID deviceUuid=new UUID(androidId.hashCode(),((long)tmDevice.hashCode() << 32) | tmSerial.hashCode()); String deviceId=deviceUuid.toString(); return deviceId; } } catch ( Exception e) { return null; } }
Example 9
From project bson4jackson, under directory /src/test/java/de/undercouch/bson4jackson/.
Source file: BsonGeneratorTest.java

@Test public void uuids() throws Exception { Map<String,Object> data=new LinkedHashMap<String,Object>(); data.put("Int32",5); data.put("Arr",Arrays.asList("a","b","c")); UUID uuid=UUID.randomUUID(); data.put("Uuid",uuid); BSONObject obj=generateAndParse(data); assertEquals(5,obj.get("Int32")); assertNotNull(obj.get("Uuid")); assertEquals(UUID.class,obj.get("Uuid").getClass()); assertEquals(uuid,obj.get("Uuid")); }
Example 10
From project Cassandra-Client-Tutorial, under directory /src/test/java/com/jeklsoft/cassandraclient/astyanax/.
Source file: TestReadingSerializer.java

@Test public void SerializingThenDeserializingReadingResultsInSameReading(){ UUID uuid=UUID.randomUUID(); DateTime date=new DateTime(); Reading reading=new Reading(uuid,date,new BigDecimal(195).movePointLeft(1),24,"ESE",BigInteger.valueOf(17L),false); ByteBuffer buffer=serializer.toByteBuffer(reading); Reading deserializedReading=new Reading(uuid,date,(Reading)serializer.fromByteBuffer(buffer)); assertEquals(reading,deserializedReading); }
Example 11
From project Carolina-Digital-Repository, under directory /persistence/src/main/java/edu/unc/lib/dl/pidgen/.
Source file: UUIDPIDGenerator.java

public List<PID> getNextPIDs(int howMany){ List<PID> result=new ArrayList<PID>(); for (int i=0; i < howMany; i++) { while (true) { UUID u=UUID.randomUUID(); String s=String.format("uuid:%1$s",u); PID p=new PID(s); if (this.verifyUnique) { if (this.tripleStoreQueryService.verify(p) != null) { continue; } } result.add(p); break; } } return result; }
Example 12
From project ajah, under directory /ajah-event-http/src/main/java/com/ajah/log/http/request/.
Source file: RequestEvent.java

/** * Populates a RequestEvent from a servlet request. * @param request */ public RequestEvent(final HttpServletRequest request){ this.id=new RequestEventId(UUID.randomUUID().toString()); this.start=System.currentTimeMillis(); this.method=HttpMethod.get(request.getMethod()); this.uri=request.getRequestURI(); this.queryString=request.getQueryString(); this.ip=request.getRemoteAddr(); this.userAgent=UserAgent.from(request.getHeader("User-Agent")); }
Example 13
From project ChessCraft, under directory /src/main/java/me/desht/chesscraft/.
Source file: Metrics.java

public Metrics(final Plugin plugin) throws IOException { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } this.plugin=plugin; configurationFile=new File(CONFIG_FILE); configuration=YamlConfiguration.loadConfiguration(configurationFile); configuration.addDefault("opt-out",false); configuration.addDefault("guid",UUID.randomUUID().toString()); if (configuration.get("guid",null) == null) { configuration.options().header("http://mcstats.org").copyDefaults(true); configuration.save(configurationFile); } guid=configuration.getString("guid"); }
Example 14
From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/ui/process/.
Source file: ProcessDefinitionImageStreamResourceBuilder.java

public StreamResource buildStreamResource(ProcessInstance processInstance,RepositoryService repositoryService,RuntimeService runtimeService){ StreamResource imageResource=null; ProcessDefinitionEntity processDefinition=(ProcessDefinitionEntity)((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(processInstance.getProcessDefinitionId()); if (processDefinition != null && processDefinition.isGraphicalNotationDefined()) { InputStream definitionImageStream=ProcessDiagramGenerator.generateDiagram(processDefinition,"png",runtimeService.getActiveActivityIds(processInstance.getId())); StreamSource streamSource=new InputStreamStreamSource(definitionImageStream); String imageExtension=extractImageExtension(processDefinition.getDiagramResourceName()); String fileName=processInstance.getId() + UUID.randomUUID() + "."+ imageExtension; imageResource=new StreamResource(streamSource,fileName,ExplorerApp.get()); } return imageResource; }
Example 15
From project Activiti-KickStart, under directory /activiti-kickstart-java/src/main/java/org/activiti/kickstart/service/alfresco/.
Source file: AlfrescoKickstartServiceImpl.java

protected void uploadTaskModel(StringBuilder taskModelsString,String baseFileName){ Session session=getCmisSession(); Folder modelFolder=(Folder)session.getObjectByPath(DATA_DICTIONARY_FOLDER); String taskModelFileName=baseFileName + "-task-model.xml"; String taskModelId=UUID.randomUUID().toString(); String taskModelXML=MessageFormat.format(getTaskModelTemplate(),taskModelId,taskModelsString.toString()); LOGGER.info("Deploying task model XML:"); prettyLogXml(taskModelXML); ByteArrayInputStream inputStream=new ByteArrayInputStream(taskModelXML.getBytes()); ContentStream contentStream=new ContentStreamImpl(taskModelFileName,null,"application/xml",inputStream); Document taskModelDocument=getDocumentFromFolder(DATA_DICTIONARY_FOLDER,taskModelFileName); if (taskModelDocument == null) { HashMap<String,Object> properties=new HashMap<String,Object>(); properties.put("cmis:name",taskModelFileName); properties.put("cmis:objectTypeId","D:cm:dictionaryModel"); properties.put("cm:modelActive",true); LOGGER.info("Task model file : " + taskModelFileName); modelFolder.createDocument(properties,contentStream,VersioningState.MAJOR); } else { LOGGER.info("Updating content of " + taskModelFileName); taskModelDocument.setContentStream(contentStream,true); } }
Example 16
From project AdminCmd, under directory /src/main/java/be/Balor/Tools/Metrics/.
Source file: Metrics.java

public Metrics(final Plugin plugin) throws IOException { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } this.plugin=plugin; configurationFile=new File(CONFIG_FILE); configuration=YamlConfiguration.loadConfiguration(configurationFile); configuration.addDefault("opt-out",false); configuration.addDefault("guid",UUID.randomUUID().toString()); if (configuration.get("guid",null) == null) { configuration.options().header("http://mcstats.org").copyDefaults(true); configuration.save(configurationFile); } guid=configuration.getString("guid"); }
Example 17
From project AdServing, under directory /modules/server/adserver/src/main/java/net/mad/ads/server/utils/context/.
Source file: AdContextHelper.java

public static AdContext getAdContext(HttpServletRequest request,HttpServletResponse response){ AdContext context=new AdContext(); String userID=null; Cookie cookie=CookieUtils.getCookie(request.getCookies(),AdServerConstants.Cookie.USERID); if (cookie != null) { userID=cookie.getValue(); } if (Strings.isEmpty(userID)) { userID=UUID.randomUUID().toString(); CookieUtils.addCookie(response,AdServerConstants.Cookie.USERID,userID,CookieUtils.ONE_YEAR,RuntimeContext.getProperties().getProperty(AdServerConstants.CONFIG.PROPERTIES.COOKIE_DOMAIN)); } context.setUserid(userID); String requestID=(String)request.getParameter(RequestHelper.requestId); if (Strings.isEmpty(requestID)) { requestID=UUID.randomUUID().toString(); } context.setRequestid(requestID); String slot=(String)request.getParameter(RequestHelper.slot); if (!Strings.isEmpty(slot)) { try { AdSlot aduuid=AdSlot.fromString(slot); context.setSlot(aduuid); } catch ( Exception e) { logger.error("",e); } } String clientIP=request.getRemoteAddr(); if (request.getHeader("X-Real-IP") != null) { clientIP=request.getHeader("X-Real-IP"); } context.setIp(clientIP); return context; }
Example 18
From project aether-core, under directory /aether-connector-asynchttpclient/src/main/java/org/eclipse/aether/connector/async/.
Source file: AsyncRepositoryConnector.java

private File getTmpFile(String path){ File file; do { file=new File(path + ".ahc" + UUID.randomUUID().toString().replace("-","").substring(0,16)); } while (file.exists()); return file; }
Example 19
From project AirCastingAndroidClient, under directory /src/main/java/ioio/lib/android/bluetooth/.
Source file: BluetoothIOIOConnection.java

public static BluetoothSocket createSocket(final BluetoothDevice device) throws IOException { BluetoothSocket socket=null; try { Method m=device.getClass().getMethod("createRfcommSocket",int.class); socket=(BluetoothSocket)m.invoke(device,1); } catch ( NoSuchMethodException ignore) { socket=device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB")); } catch ( Exception ignore) { } return socket; }
Example 20
From project Airports, under directory /src/com/nadmm/airports/.
Source file: DownloadActivity.java

private int downloadManifest(){ try { if (!NetworkUtils.isNetworkAvailable(mActivity)) { UiUtils.showToast(mActivity,"Please check your network connection"); return -1; } DefaultHttpClient httpClient=new DefaultHttpClient(); File manifest=new File(getCacheDir(),MANIFEST); boolean fetch=true; if (manifest.exists()) { Date now=new Date(); long age=now.getTime() - manifest.lastModified(); if (age < 10 * DateUtils.MINUTE_IN_MILLIS) { fetch=false; } } if (fetch) { NetworkUtils.doHttpGet(mActivity,httpClient,HOST,PORT,PATH + "/" + MANIFEST,"uuid=" + UUID.randomUUID().toString(),manifest); } } catch ( Exception e) { UiUtils.showToast(mActivity,e.getMessage()); return -1; } return 0; }
Example 21
From project akubra, under directory /akubra-rmi/src/test/java/org/akubraproject/rmi/.
Source file: TransactionalStoreTest.java

@Test public void testMTStress() throws InterruptedException, ExecutionException { ScheduledExecutorService executor=Executors.newScheduledThreadPool(10); List<Future<Void>> futures=new ArrayList<Future<Void>>(); for (int loop=0; loop < 30; loop++) { futures.add(executor.submit(new Callable<Void>(){ public Void call() throws Exception { for (int i=0; i < 10; i++) { doInTxn(new Action(){ public void run( BlobStoreConnection con) throws Exception { for (int j=0; j < 3; j++) { URI id=URI.create("urn:mt:" + UUID.randomUUID()); byte[] buf=new byte[4096]; Blob b; b=con.getBlob(id,null); OutputStream out; IOUtils.copyLarge(new ByteArrayInputStream(buf),out=b.openOutputStream(buf.length,true)); out.close(); InputStream in; assertEquals(buf,IOUtils.toByteArray(in=b.openInputStream())); in.close(); b.delete(); } } } ,true); } return null; } } )); } for ( Future<Void> res : futures) res.get(); }
Example 22
private static void writeInstallationFile(File installation) throws IOException { FileOutputStream out=new FileOutputStream(installation); String id=UUID.randomUUID().toString(); out.write(id.getBytes()); out.close(); }
Example 23
From project alphaportal_dev, under directory /sys-src/alphaportal/core/src/main/java/alpha/portal/dao/hibernate/.
Source file: AlphaCardDaoHibernate.java

/** * Overridden to generate UUID and for versioning. Clones the descriptor and increases the sequenceNumber before saving. * @param card the card * @return the alpha card * @see org.appfuse.dao.hibernate.GenericDaoHibernate#save(java.lang.Object) */ @Override public AlphaCard save(final AlphaCard card){ if (card.getAlphaCardIdentifier() != null) { if (card.getAlphaCardIdentifier().getCardId() == null) { card.getAlphaCardIdentifier().setCardId(UUID.randomUUID().toString()); } else { this.getHibernateTemplate().flush(); this.getHibernateTemplate().evict(card); this.getHibernateTemplate().clear(); } card.setAlphaCardDescriptor(card.getAlphaCardDescriptor().clone()); final Long newSequenceNumber=this.getLastValue() + 1L; card.getAlphaCardIdentifier().setSequenceNumber(newSequenceNumber); card.getAlphaCardDescriptor().getAlphaCardIdentifier().setSequenceNumber(newSequenceNumber); } return super.save(card); }
Example 24
From project android-aac-enc, under directory /src/com/googlecode/mp4parser/boxes/piff/.
Source file: ProtectionSpecificHeader.java

public static ProtectionSpecificHeader createFor(UUID systemId,ByteBuffer bufferWrapper){ final Class<? extends ProtectionSpecificHeader> aClass=uuidRegistry.get(systemId); ProtectionSpecificHeader protectionSpecificHeader=new ProtectionSpecificHeader(); if (aClass != null) { try { protectionSpecificHeader=aClass.newInstance(); } catch ( InstantiationException e) { throw new RuntimeException(e); } catch ( IllegalAccessException e) { throw new RuntimeException(e); } } protectionSpecificHeader.parse(bufferWrapper); return protectionSpecificHeader; }
Example 25
From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.
Source file: BluetoothActivity.java

public ClientSocketThread(String device,Handler handle){ mMACAddres=device.substring(device.lastIndexOf('\n') + 1,device.lastIndexOf(":")).toUpperCase(); mHandle=handle; try { mRemoteDevice=mBluetoothAdapter.getRemoteDevice(mMACAddres); mSocket=mRemoteDevice.createRfcommSocketToServiceRecord(UUID.fromString(DEV_UUID)); } catch ( IllegalArgumentException e) { mSocket=null; Message msg=new Message(); msg.obj=e.getMessage(); mHandle.sendEmptyMessage(DIALOG_CANCEL); } catch ( IOException e) { Message msg=new Message(); msg.obj=e.getMessage(); mHandle.sendEmptyMessage(DIALOG_CANCEL); } }
Example 26
From project Android-GifStitch, under directory /src/com/phunkosis/gifstitch/settings/.
Source file: GSSettings.java

public static String getDeviceId(){ String value=getStringSetting(Setting.STR_DEVICEID); if (value == null) { String newDeviceId=UUID.randomUUID().toString().replace("-",""); addStringSetting(Setting.STR_DEVICEID,newDeviceId); return newDeviceId; } return value; }
Example 27
From project android-sdk, under directory /src/main/java/com/mobeelizer/mobile/android/.
Source file: MobeelizerFileService.java

String addFile(final InputStream stream){ String guid=UUID.randomUUID().toString(); String path=savaFile(guid,stream); application.getDatabase().addFile(guid,path); return guid; }
Example 28
From project Android-Terminal-Emulator, under directory /src/jackpal/androidterm/.
Source file: RemoteInterface.java

private String openNewWindow(String iInitialCommand){ TermService service=mTermService; String initialCommand=mSettings.getInitialCommand(); if (iInitialCommand != null) { if (initialCommand != null) { initialCommand+="\r" + iInitialCommand; } else { initialCommand=iInitialCommand; } } TermSession session=Term.createTermSession(this,mSettings,initialCommand); session.setFinishCallback(service); service.getSessions().add(session); String handle=UUID.randomUUID().toString(); ((ShellTermSession)session).setHandle(handle); Intent intent=new Intent(PRIVACT_OPEN_NEW_WINDOW); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); return handle; }
Example 29
From project AndroidBillingLibrary, under directory /AndroidBillingLibrary/src/net/robotmedia/billing/utils/.
Source file: Installation.java

private static void writeInstallationFile(File installation) throws IOException { FileOutputStream out=new FileOutputStream(installation); String id=UUID.randomUUID().toString(); out.write(id.getBytes()); out.close(); }
Example 30
From project Android_1, under directory /org.eclipse.ecf.provider.zookeeper/src/org/eclipse/ecf/provider/zookeeper/core/.
Source file: AdvertisedService.java

public AdvertisedService(ServiceReference ref){ Assert.isNotNull(ref); this.serviceReference=ref; this.uuid=UUID.randomUUID().toString(); String services[]=(String[])this.serviceReference.getProperty(Constants.OBJECTCLASS); for ( String k : this.serviceReference.getPropertyKeys()) { Object value=this.serviceReference.getProperty(k); if (value instanceof String && ((String)value).contains("localhost")) { this.properties.put(k,((String)value).replace("localhost",Geo.getHost())); continue; } this.properties.put(k,this.serviceReference.getProperty(k)); } IServiceTypeID serviceTypeID=ServiceIDFactory.getDefault().createServiceTypeID(DiscoveryContainer.getSingleton().getConnectNamespace(),services,IServiceTypeID.DEFAULT_PROTO); serviceTypeID=new ZooServiceTypeID((DiscoveryNamespace)DiscoveryContainer.getSingleton().getConnectNamespace(),serviceTypeID,this.serviceReference.getProperty(Constants.SERVICE_ID).toString()); serviceID=new ZooServiceID(DiscoveryContainer.getSingleton().getConnectNamespace(),serviceTypeID,Geo.getLocation()); super.properties=new ServiceProperties(this.properties); this.properties.put(Constants.OBJECTCLASS,arrayToString(services)); this.properties.put(LOCATION,Geo.getLocation()); this.properties.put(WEIGHT,getWeight()); this.properties.put(PRIORITY,getPriority()); this.properties.put(NODE_PROPERTY_NAME_PROTOCOLS,arrayToString(IServiceTypeID.DEFAULT_PROTO)); this.properties.put(NODE_PROPERTY_NAME_SCOPE,arrayToString(IServiceTypeID.DEFAULT_SCOPE)); this.properties.put(NODE_PROPERTY_NAME_NA,IServiceTypeID.DEFAULT_NA); publishedServices.put(serviceTypeID.getInternal(),this); }
Example 31
From project android_8, under directory /src/com/google/gson/.
Source file: DefaultTypeAdapters.java

private static ParameterizedTypeHandlerMap<JsonSerializer<?>> createDefaultSerializers(){ ParameterizedTypeHandlerMap<JsonSerializer<?>> map=new ParameterizedTypeHandlerMap<JsonSerializer<?>>(); map.register(URL.class,URL_TYPE_ADAPTER); map.register(URI.class,URI_TYPE_ADAPTER); map.register(UUID.class,UUUID_TYPE_ADAPTER); map.register(Locale.class,LOCALE_TYPE_ADAPTER); map.register(Date.class,DATE_TYPE_ADAPTER); map.register(java.sql.Date.class,JAVA_SQL_DATE_TYPE_ADAPTER); map.register(Timestamp.class,DATE_TYPE_ADAPTER); map.register(Time.class,TIME_TYPE_ADAPTER); map.register(Calendar.class,GREGORIAN_CALENDAR_TYPE_ADAPTER); map.register(GregorianCalendar.class,GREGORIAN_CALENDAR_TYPE_ADAPTER); map.register(BigDecimal.class,BIG_DECIMAL_TYPE_ADAPTER); map.register(BigInteger.class,BIG_INTEGER_TYPE_ADAPTER); map.register(BitSet.class,BIT_SET_ADAPTER); map.register(Boolean.class,BOOLEAN_TYPE_ADAPTER); map.register(boolean.class,BOOLEAN_TYPE_ADAPTER); map.register(Byte.class,BYTE_TYPE_ADAPTER); map.register(byte.class,BYTE_TYPE_ADAPTER); map.register(Character.class,CHARACTER_TYPE_ADAPTER); map.register(char.class,CHARACTER_TYPE_ADAPTER); map.register(Integer.class,INTEGER_TYPE_ADAPTER); map.register(int.class,INTEGER_TYPE_ADAPTER); map.register(Number.class,NUMBER_TYPE_ADAPTER); map.register(Short.class,SHORT_TYPE_ADAPTER); map.register(short.class,SHORT_TYPE_ADAPTER); map.register(String.class,STRING_TYPE_ADAPTER); map.register(StringBuilder.class,STRING_BUILDER_TYPE_ADAPTER); map.register(StringBuffer.class,STRING_BUFFER_TYPE_ADAPTER); map.makeUnmodifiable(); return map; }
Example 32
From project apps-for-android, under directory /BTClickLinkCompete/src/net/clc/bt/.
Source file: ConnectionService.java

public ConnectionService(){ mSelf=this; mBtAdapter=BluetoothAdapter.getDefaultAdapter(); mApp=""; mBtSockets=new HashMap<String,BluetoothSocket>(); mBtDeviceAddresses=new ArrayList<String>(); mBtStreamWatcherThreads=new HashMap<String,Thread>(); mUuid=new ArrayList<UUID>(); mUuid.add(UUID.fromString("a60f35f0-b93a-11de-8a39-08002009c666")); mUuid.add(UUID.fromString("503c7430-bc23-11de-8a39-0800200c9a66")); mUuid.add(UUID.fromString("503c7431-bc23-11de-8a39-0800200c9a66")); mUuid.add(UUID.fromString("503c7432-bc23-11de-8a39-0800200c9a66")); mUuid.add(UUID.fromString("503c7433-bc23-11de-8a39-0800200c9a66")); mUuid.add(UUID.fromString("503c7434-bc23-11de-8a39-0800200c9a66")); mUuid.add(UUID.fromString("503c7435-bc23-11de-8a39-0800200c9a66")); }
Example 33
From project aranea, under directory /server/src/main/java/no/dusken/aranea/web/control/.
Source file: FormController.java

protected Map referenceData(HttpServletRequest httpServletRequest) throws Exception { Map<String,Object> map=new HashMap<String,Object>(); map.put("captchaString",UUID.randomUUID().toString()); map.put("captchaEnabled",captchaEnabled); return map; }
Example 34
From project archive-commons, under directory /archive-commons/src/main/java/org/archive/format/warc/.
Source file: WARCRecordWriter.java

private String makeRecordId(){ StringBuilder recID=new StringBuilder(); recID.append("<").append(SCHEME_COLON); recID.append(UUID.randomUUID().toString()); recID.append(">"); return recID.toString(); }
Example 35
From project arquillian-container-openshift, under directory /openshift-express/src/main/java/org/jboss/arquillian/container/openshift/express/.
Source file: OpenShiftRepository.java

public String saveState(){ String branch=UUID.randomUUID().toString(); git.createBranch(branch.toString()); lastSavedState=branch; return branch; }
Example 36
From project arquillian-container-tomcat, under directory /tomcat-embedded-6/src/main/java/org/jboss/arquillian/container/tomcat/embedded_6/.
Source file: TomcatContainer.java

public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException { try { StandardContext standardContext=archive.as(ShrinkWrapStandardContext.class); standardContext.addLifecycleListener(new EmbeddedContextConfig()); standardContext.setUnpackWAR(configuration.isUnpackArchive()); standardContext.setJ2EEServer("Arquillian-" + UUID.randomUUID().toString()); standardContext.setParentClassLoader(Thread.currentThread().getContextClassLoader()); if (standardContext.getUnpackWAR()) { deleteUnpackedWAR(standardContext); } WebappLoader webappLoader=new WebappLoader(standardContext.getParentClassLoader()); webappLoader.setDelegate(standardContext.getDelegate()); webappLoader.setLoaderClass(EmbeddedWebappClassLoader.class.getName()); standardContext.setLoader(webappLoader); standardHost.addChild(standardContext); standardContextProducer.set(standardContext); String contextPath=standardContext.getPath(); HTTPContext httpContext=new HTTPContext(bindAddress,bindPort); for ( String mapping : standardContext.findServletMappings()) { httpContext.add(new Servlet(standardContext.findServletMapping(mapping),contextPath)); } return new ProtocolMetaData().addContext(httpContext); } catch ( Exception e) { throw new DeploymentException("Failed to deploy " + archive.getName(),e); } }
Example 37
From project arquillian-extension-jacoco, under directory /src/main/java/org/jboss/arquillian/extension/jacoco/container/.
Source file: StartCoverageData.java

public void createRuntime(@Observes BeforeSuite event) throws Exception { IRuntime runtime=ArquillianRuntime.getInstance(); runtime.setSessionId(UUID.randomUUID().toString()); runtime.startup(); runtimeInst.set(runtime); }
Example 38
From project arquillian_deprecated, under directory /containers/tomcat-embedded-6/src/main/java/org/jboss/arquillian/container/tomcat/embedded_6/.
Source file: TomcatContainer.java

public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException { try { StandardContext standardContext=archive.as(ShrinkWrapStandardContext.class); standardContext.addLifecycleListener(new EmbeddedContextConfig()); standardContext.setUnpackWAR(configuration.isUnpackArchive()); standardContext.setJ2EEServer("Arquillian-" + UUID.randomUUID().toString()); standardContext.setParentClassLoader(Thread.currentThread().getContextClassLoader()); if (standardContext.getUnpackWAR()) { deleteUnpackedWAR(standardContext); } WebappLoader webappLoader=new WebappLoader(standardContext.getParentClassLoader()); webappLoader.setDelegate(standardContext.getDelegate()); webappLoader.setLoaderClass(EmbeddedWebappClassLoader.class.getName()); standardContext.setLoader(webappLoader); standardHost.addChild(standardContext); standardContextProducer.set(standardContext); String contextPath=standardContext.getPath(); HTTPContext httpContext=new HTTPContext(bindAddress,bindPort); for ( String mapping : standardContext.findServletMappings()) { httpContext.add(new Servlet(standardContext.findServletMapping(mapping),contextPath)); } return new ProtocolMetaData().addContext(httpContext); } catch ( Exception e) { throw new DeploymentException("Failed to deploy " + archive.getName(),e); } }
Example 39
From project ATHENA, under directory /components/payments/src/main/java/org/fracturedatlas/athena/payments/processor/.
Source file: MockPaymentProcessor.java

@Override public AuthorizationResponse authorizePayment(AuthorizationRequest authorizationRequest){ AuthorizationResponse authorizationResponse=new AuthorizationResponse(); String someId=UUID.randomUUID().toString(); if (!VALID_CARD_NUMBERS.contains(authorizationRequest.getCreditCard().getCardNumber())) { authorizationResponse.setSuccess(Boolean.FALSE); authorizationResponse.setMessage("Declined"); return authorizationResponse; } else { authorizationResponse.setSuccess(true); authorizationResponse.setTransactionId(someId); } if (authorizationRequest.getStoreCard()) { org.fracturedatlas.athena.payments.model.CreditCard card=authorizationRequest.getCreditCard(); String token=UUID.randomUUID().toString(); card.setToken(token); card.setId(token); cards.put(card.getId(),card); authorizationResponse.setCreditCard(card); org.fracturedatlas.athena.payments.model.Customer customer=authorizationRequest.getCustomer(); String customerId=UUID.randomUUID().toString(); customer.setId(customerId); customers.put(customer.getId(),customer); authorizationResponse.setCustomer(customer); } authorizationResponse.setMessage("Success"); return authorizationResponse; }
Example 40
From project AuthDB, under directory /src/main/java/com/authdb/util/encryption/.
Source file: Encryption.java

public static String encrypt(String encryption,String toencrypt) throws NoSuchAlgorithmException, UnsupportedEncodingException { if (encryption.equalsIgnoreCase("md5")) { return md5(toencrypt); } else if (encryption.equalsIgnoreCase("sha1") || encryption.equalsIgnoreCase("sha-1")) { return SHA1(toencrypt); } else if (encryption.equalsIgnoreCase("sha256") || encryption.equalsIgnoreCase("sha-256")) { return SHA256(toencrypt); } else if (encryption.equalsIgnoreCase("sha512") || encryption.equalsIgnoreCase("sha2") || encryption.equalsIgnoreCase("sha-512")|| encryption.equalsIgnoreCase("sha-2")) { return SHA512(toencrypt); } else if (encryption.equalsIgnoreCase("whirlpool")) { return whirlpool(toencrypt); } else if (encryption.equalsIgnoreCase("xauth")) { String salt=whirlpool(UUID.randomUUID().toString()).substring(0,12); String hash=whirlpool(salt + toencrypt); int saltPos=(toencrypt.length() >= hash.length() ? hash.length() - 1 : toencrypt.length()); return hash.substring(0,saltPos) + salt + hash.substring(saltPos); } if (Config.debug_enable) { Util.logging.Info("Could not find encryption method: " + encryption + ", using default: md5"); } Config.custom_encryption="md5"; return md5(toencrypt); }
Example 41
From project AuthMe-Reloaded, under directory /src/main/java/uk/org/whoami/authme/.
Source file: Metrics.java

public Metrics() throws IOException { File file=new File(CONFIG_FILE); configuration=YamlConfiguration.loadConfiguration(file); configuration.addDefault("opt-out",false); configuration.addDefault("guid",UUID.randomUUID().toString()); if (configuration.get("guid",null) == null) { configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true); configuration.save(file); } guid=configuration.getString("guid"); }
Example 42
From project avro, under directory /lang/java/avro/src/main/java/org/apache/avro/file/.
Source file: DataFileWriter.java

private static byte[] generateSync(){ try { MessageDigest digester=MessageDigest.getInstance("MD5"); long time=System.currentTimeMillis(); digester.update((UUID.randomUUID() + "@" + time).getBytes()); return digester.digest(); } catch ( NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
Example 43
From project avro-utils, under directory /src/test/java/com/tomslabs/grid/avro/.
Source file: FileUtils.java

public static File generateTempBaseDir(){ String tempDir=System.getProperty("java.io.tmpdir"); File f=new File(tempDir + File.separator + UUID.randomUUID().toString()); f.mkdir(); return f; }
Example 44
From project aws-toolkit-for-eclipse, under directory /com.amazonaws.eclipse.core/src/com/amazonaws/eclipse/core/.
Source file: AwsToolkitCore.java

/** * Bootstraps the current account preferences for new customers or customers migrating from the legacy single-account preference */ private void bootstrapAccountPreferences(){ String currentAccount=getPreferenceStore().getString(PreferenceConstants.P_CURRENT_ACCOUNT); if (currentAccount == null || currentAccount.length() == 0) { String accountId=UUID.randomUUID().toString(); getPreferenceStore().putValue(PreferenceConstants.P_CURRENT_ACCOUNT,accountId); getPreferenceStore().putValue(PreferenceConstants.P_ACCOUNT_IDS,accountId); getPreferenceStore().putValue(accountId + ":" + PreferenceConstants.P_ACCOUNT_NAME,PreferenceConstants.DEFAULT_ACCOUNT_NAME_BASE_64); for ( String prefName : new String[]{PreferenceConstants.P_ACCESS_KEY,PreferenceConstants.P_CERTIFICATE_FILE,PreferenceConstants.P_PRIVATE_KEY_FILE,PreferenceConstants.P_SECRET_KEY,PreferenceConstants.P_USER_ID}) { convertExistingPreference(accountId,prefName); } } }
Example 45
From project azkaban, under directory /azkaban/src/java/azkaban/app/.
Source file: PropsUtils.java

public static Props produceParentProperties(final ExecutableFlow flow){ Props parentProps=new Props(); parentProps.put("azkaban.flow.id",flow.getId()); parentProps.put("azkaban.flow.uuid",UUID.randomUUID().toString()); DateTime loadTime=new DateTime(); parentProps.put("azkaban.flow.start.timestamp",loadTime.toString()); parentProps.put("azkaban.flow.start.year",loadTime.toString("yyyy")); parentProps.put("azkaban.flow.start.month",loadTime.toString("MM")); parentProps.put("azkaban.flow.start.day",loadTime.toString("dd")); parentProps.put("azkaban.flow.start.hour",loadTime.toString("HH")); parentProps.put("azkaban.flow.start.minute",loadTime.toString("mm")); parentProps.put("azkaban.flow.start.seconds",loadTime.toString("ss")); parentProps.put("azkaban.flow.start.milliseconds",loadTime.toString("SSS")); parentProps.put("azkaban.flow.start.timezone",loadTime.toString("ZZZZ")); return parentProps; }
Example 46
From project Backpack, under directory /src/main/java/com/almuramc/backpack/bukkit/storage/.
Source file: Storage.java

public final void store(Player player,World world,BackpackInventory toStore){ if (player == null || world == null) { return; } HashMap<UUID,BackpackInventory> playerMap=BACKPACKS.get(world.getUID()); if (playerMap == null) { playerMap=new HashMap<UUID,BackpackInventory>(); } if (playerMap.containsKey(player.getUniqueId()) && toStore == null) { playerMap.remove(player.getUniqueId()); BACKPACKS.put(world.getUID(),playerMap); return; } playerMap.put(player.getUniqueId(),toStore); BACKPACKS.put(world.getUID(),playerMap); }
Example 47
From project BazaarUtils, under directory /src/com/congenialmobile/adad/.
Source file: AdsManager.java

/** * Prepares the unique UUID for this app installation. This actually means making UUID for the first time and saving this. The next time the UUID will be loaded from preferences. */ private void prepareUUID(){ SharedPreferences pref=mContext.getSharedPreferences(PREF_TAG,Activity.MODE_PRIVATE); mUUID=pref.getString(PREF_UUID,""); if (mUUID.length() > 0) { return; } mUUID=UUID.randomUUID().toString(); ; SharedPreferences.Editor editor=pref.edit(); editor.putString(PREF_UUID,mUUID); editor.commit(); }
Example 48
From project behemoth, under directory /core/src/main/java/com/digitalpebble/behemoth/util/.
Source file: ContentExtractor.java

public static FileNamingMode toMode(String str){ try { return valueOf(str); } catch ( Exception ex) { return UUID; } }
Example 49
From project BetterShop_1, under directory /src/com/randomappdev/pluginstats/.
Source file: Ping.java

private static Boolean configExists(){ config.addDefault("usage.opt-out",false); config.addDefault("usage.guid",UUID.randomUUID().toString()); if (!configFile.exists()) { try { config.options().copyDefaults(true); config.save(configFile); } catch ( Exception ex) { logger.log(Level.SEVERE,"Error with config file!"); logger.log(Level.SEVERE,"",ex); return false; } } return true; }
Example 50
From project big-data-plugin, under directory /shims/common/src-mapred/org/pentaho/hadoop/mapreduce/.
Source file: MRUtil.java

public static Trans getTrans(final Configuration conf,final String transXml,boolean singleThreaded) throws KettleException { initKettleEnvironment(conf); TransConfiguration transConfiguration=TransConfiguration.fromXML(transXml); TransMeta transMeta=transConfiguration.getTransMeta(); String carteObjectId=UUID.randomUUID().toString(); SimpleLoggingObject servletLoggingObject=new SimpleLoggingObject("HADOOP_MAPPER",LoggingObjectType.CARTE,null); servletLoggingObject.setContainerObjectId(carteObjectId); TransExecutionConfiguration executionConfiguration=transConfiguration.getTransExecutionConfiguration(); servletLoggingObject.setLogLevel(executionConfiguration.getLogLevel()); if (singleThreaded) { transMeta.setTransformationType(TransformationType.SingleThreaded); transMeta.setUsingThreadPriorityManagment(false); } else { transMeta.setTransformationType(TransformationType.Normal); } return new Trans(transMeta,servletLoggingObject); }
Example 51
From project BlameSubversion-plugin, under directory /src/main/java/hudson/scm/.
Source file: BlameSubversionSCM.java

/** * Repository UUID. Lazy computed and cached. */ public UUID getUUID(AbstractProject context) throws SVNException { if (repositoryUUID == null || repositoryRoot == null) { synchronized (this) { SVNRepository r=openRepository(context); r.testConnection(); repositoryUUID=UUID.fromString(r.getRepositoryUUID(false)); repositoryRoot=r.getRepositoryRoot(false); } } return repositoryUUID; }
Example 52
From project BleedingMobs, under directory /src/me/snowleo/bleedingmobs/.
Source file: Metrics.java

public Metrics(final Plugin plugin) throws IOException { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } this.plugin=plugin; configurationFile=getConfigFile(); configuration=YamlConfiguration.loadConfiguration(configurationFile); configuration.addDefault("opt-out",false); configuration.addDefault("guid",UUID.randomUUID().toString()); if (configuration.get("guid",null) == null) { configuration.options().header("http://mcstats.org").copyDefaults(true); configuration.save(configurationFile); } guid=configuration.getString("guid"); }
Example 53
From project bpelunit, under directory /net.bpelunit.framework/src/main/java/net/bpelunit/framework/control/soap/.
Source file: WSAHeaderProcessor.java

private String addMessageID(SOAPHeader header) throws HeaderProcessingException { try { String id=null; if (fProperties.containsKey(WSA_TAG_MESSAGE_ID)) { id=fProperties.get(WSA_TAG_MESSAGE_ID); } else { id=WSA_MESSAGE_ID_PREFIX + UUID.randomUUID().toString(); } SOAPElement msgId=header.addChildElement(wsaQName(WSA_TAG_MESSAGE_ID)); msgId.setTextContent(id); return id; } catch ( SOAPException e) { throw new HeaderProcessingException("Could not add MessageID header to outgoing SOAP message.",e); } }
Example 54
From project brix-cms, under directory /brix-core/src/main/java/org/brixcms/plugin/site/resource/admin/.
Source file: UploadResourcesPanel.java

private void processUploads(){ final BrixNode parentNode=getModelObject(); for ( final FileUpload upload : uploads) { final String fileName=upload.getClientFileName(); if (parentNode.hasNode(fileName)) { if (overwrite) { parentNode.getNode(fileName).remove(); } else { class ModelObject implements Serializable { @SuppressWarnings("unused") private String fileName=upload.getClientFileName(); } getSession().error(getString("fileExists",new Model<ModelObject>(new ModelObject()))); continue; } } BrixNode newNode=(BrixNode)parentNode.addNode(fileName,"nt:file"); try { File temp=File.createTempFile(Brix.NS + "-upload-" + UUID.randomUUID().toString(),null); Streams.copy(upload.getInputStream(),new FileOutputStream(temp)); upload.closeStreams(); String mime=upload.getContentType(); BrixFileNode file=BrixFileNode.initialize(newNode,mime); file.setData(file.getSession().getValueFactory().createBinary(new FileInputStream(temp))); file.getParent().save(); } catch ( IOException e) { throw new IllegalStateException(e); } } SitePlugin.get().selectNode(this,parentNode,true); }
Example 55
From project btmidi, under directory /BluetoothMidi/src/com/noisepages/nettoyeur/bluetooth/.
Source file: BluetoothSppConnection.java

/** * Connect to a Bluetooth device with the given address and UUID. * @param addr string representation of MAC address of the Bluetooth device * @param uuid UUID of the Bluetooth device * @throws IOException */ public synchronized void connect(String addr,UUID uuid) throws IOException { cancelThreads(); BluetoothDevice device=btAdapter.getRemoteDevice(addr); connectThread=new ConnectThread(device,uuid); connectThread.start(); setState(State.CONNECTING); }
Example 56
From project BukkitUtilities, under directory /src/main/java/name/richardson/james/bukkit/utilities/metrics/.
Source file: Metrics.java

public Metrics(final Plugin plugin) throws IOException { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } this.plugin=plugin; this.configurationFile=this.getConfigFile(); this.configuration=YamlConfiguration.loadConfiguration(this.configurationFile); this.configuration.addDefault("opt-out",false); this.configuration.addDefault("guid",UUID.randomUUID().toString()); if (this.configuration.get("guid",null) == null) { this.configuration.options().header("http://mcstats.org").copyDefaults(true); this.configuration.save(this.configurationFile); } this.guid=this.configuration.getString("guid"); }
Example 57
From project Cafe, under directory /webapp/src/org/openqa/selenium/android/.
Source file: WebViewManager.java

public void addView(WebView view){ synchronized (syncObject) { String u=UUID.randomUUID().toString(); map.put(u,view); } }
Example 58
From project candlepin, under directory /src/test/java/org/candlepin/controller/.
Source file: CrlGeneratorTest.java

@Test public void crlNumberWithCert() throws Exception { X509V2CRLGenerator g=new X509V2CRLGenerator(); g.setIssuerDN(new X500Principal("CN=test, UID=" + UUID.randomUUID())); g.setThisUpdate(new Date()); g.setNextUpdate(Util.tomorrow()); g.setSignatureAlgorithm("SHA1withRSA"); g.addExtension(X509Extensions.CRLNumber,false,new CRLNumber(BigInteger.TEN)); X509CRL x509crl=g.generate(KP.getPrivate()); assertEquals(BigInteger.TEN,this.generator.getCRLNumber(x509crl)); }
Example 59
From project capedwarf-blue, under directory /tasks/src/main/java/org/jboss/capedwarf/tasks/.
Source file: JBossQueue.java

public List<TaskHandle> add(Transaction transaction,Iterable<TaskOptions> taskOptionses){ final ServletExecutorProducer producer=new ServletExecutorProducer(); try { final List<TaskHandle> handles=new ArrayList<TaskHandle>(); for ( TaskOptions to : taskOptionses) { TaskOptions copy=null; final TaskOptions.Method m=getMethod.invoke(to); if (m == TaskOptions.Method.PULL) { copy=new TaskOptions(to); String taskName=getTaskName.invoke(to); if (taskName == null) { taskName=UUID.randomUUID().toString(); copy.taskName(taskName); } Long lifespan=getEtaMillis.invoke(to); RetryOptions retryOptions=getRetryOptions.invoke(to); getTasks().put(taskName,new TaskOptionsEntity(taskName,queueName,copy.getTag(),lifespan,copy,retryOptions),lifespan,TimeUnit.MILLISECONDS); } else if (m == TaskOptions.Method.POST) { final MessageCreator mc=createMessageCreator(to); final String id=producer.sendMessage(mc); copy=new TaskOptions(to); if (getTaskName.invoke(to) == null) copy.taskName(toTaskName(id)); } if (copy != null) handles.add(new TaskHandle(copy,getQueueName())); } return handles; } catch ( Exception e) { throw new RuntimeException(e); } finally { producer.dispose(); } }
Example 60
From project capedwarf-green, under directory /server-jee/src/main/java/org/jboss/capedwarf/server/jee/io/.
Source file: DefaultBlobService.java

protected String storeBytesInternal(String mimeType,ByteBuffer buffer) throws IOException { String key=UUID.randomUUID().toString(); File file=new File(getDataDir(),key); FileOutputStream fos=new FileOutputStream(file); try { while (buffer.hasRemaining()) fos.write(buffer.get()); fos.flush(); } finally { fos.close(); } return key; }
Example 61
From project chililog-server, under directory /src/main/java/org/chililog/server/common/.
Source file: AppProperties.java

static String loadMqSystemUsername(Properties properties){ String s=loadString(properties,MQ_SYSTEM_USERNAME,StringUtils.EMPTY); if (StringUtils.isBlank(s)) { s="systemuser_" + UUID.randomUUID().toString(); } return s; }