List of usage examples for java.util HashMap clear
public void clear()
From source file:org.tinygroup.jspengine.servlet.JspServlet.java
public void destroy() { if (log.isDebugEnabled()) { log.debug("JspServlet.destroy()"); }//from w ww. j a v a 2 s .c o m rctxt.destroy(); JspApplicationContextImpl.removeJspApplicationContext(context); // START GlassFish 750 taglibs.clear(); tagFileJarUrls.clear(); // END GlassFish 750 // START GlassFish 747 HashMap tldUriToLocationMap = (HashMap) context.getAttribute(Constants.JSP_TLD_URI_TO_LOCATION_MAP); if (tldUriToLocationMap != null) { tldUriToLocationMap.clear(); } // END GlassFish 747 }
From source file:com.antelink.sourcesquare.client.scan.SourceSquareFSWalker.java
private synchronized void analyzeMap(HashMap<String, String> tempMap) throws InterruptedException { if (tempMap == null || tempMap.isEmpty()) { return;// w w w.j a v a 2 s .c o m } ProcessWorker worker = null; while ((worker = getAvailableProcessor()) == null) { synchronized (this.lock) { this.lock.wait(); } } worker.process(new HashMap<String, String>(tempMap)); tempMap.clear(); }
From source file:edu.ku.brc.specify.toycode.L18NStringResApp.java
/** * /* w w w . ja v a 2s. c o m*/ */ public void checkAll() { HashMap<String, Pair<String, String>> hash = new HashMap<String, Pair<String, String>>(); File file = new File(ENGFILE_NAME); for (String lang : langs) { hash.clear(); System.out.println("Processing " + lang); destLocale = new Locale(lang); process(file, hash, 0); String fName = FilenameUtils.getBaseName(file.getName()) + "_" + destLocale.getLanguage() + ".xml"; process(new File(fName), hash, 1); } }
From source file:edu.ku.brc.specify.toycode.L18NStringResApp.java
/** * /*w ww . ja va 2 s.c om*/ */ protected void mergeAll() { HashMap<String, Pair<String, String>> hash = new HashMap<String, Pair<String, String>>(); File file = new File(ENGFILE_NAME); for (String lang : langs) { hash.clear(); System.out.println("-------------------------------------------------"); System.out.println("Merge new lines " + lang); destLocale = new Locale(lang); String dirName = RES_PATH + "values-" + destLocale.getLanguage(); String dstPath = dirName + File.separator + file.getName(); File dstFile = new File(dstPath); process(dstFile, hash, 0); mergeFile(file, dstFile, hash); } }
From source file:com.confighub.core.repository.RepoFile.java
private void checkFileForCircularReference(final Context context, final RepoFile file) throws ConfigException { Map<PropertyKey, Collection<Property>> keyListMap = context.resolveFile(file.getKeys(), false); HashMap<RepoFile, Property> breadcrumbs = new LinkedHashMap<>(); for (PropertyKey key : keyListMap.keySet()) { if (!PropertyKey.ValueDataType.FileEmbed.equals(key.getValueDataType())) { continue; }/*www.j a v a 2s . c o m*/ for (Property property : keyListMap.get(key)) { breadcrumbs.clear(); checkPropertyCircularReference(context, property, breadcrumbs); } } }
From source file:org.eclipse.thym.wp.internal.core.vstudio.WPProjectGenerator.java
@Override protected void generateNativeFiles(HybridMobileLibraryResolver resolver) throws CoreException { try {//from ww w .ja v a 2 s . c o m HybridProject hybridProject = HybridProject.getHybridProject(getProject()); if (hybridProject == null) { throw new CoreException( new Status(IStatus.ERROR, WPCore.PLUGIN_ID, Messages.WPProjectGenerator_NotHybridError)); } File destinationDir = getDestination(); Path destinationPath = new Path(destinationDir.toString()); String appName = hybridProject.getBuildArtifactAppName(); Widget widgetModel = WidgetModel.getModel(hybridProject).getWidgetForRead(); String packageName = widgetModel.getId(); if (!destinationDir.exists()) {// create the project directory destinationDir.mkdirs(); } String safeAppName = appName.replaceAll("/(\\.\\s|\\s\\.|\\s+|\\.+)/g", "_"); //$NON-NLS-1$ //$NON-NLS-2$ packageName = packageName.replaceAll("_", "-"); //$NON-NLS-1$ //$NON-NLS-2$ // /${project_name} directoryCopy(resolver.getTemplateFile(new Path(VAR_APP_NAME)), toURL(destinationDir)); // copy VERSION file to project's root directory fileCopy(resolver.getTemplateFile(new Path(WPLibraryResolver.VERSION)), toURL(destinationPath.append(WPLibraryResolver.VERSION).toFile())); // copy config.xml to /${project_name}/config.xml File configFile = getConfigFile(hybridProject.getProject()); fileCopy(toURL(configFile), toURL(destinationPath.append(PlatformConstants.FILE_XML_CONFIG).toFile())); UUID guid = UUID.randomUUID(); HashMap<String, String> values = new HashMap<String, String>(); values.put(SAFE_PROJECT_NAME, appName); values.put(GUID1, guid.toString()); // /${project_name}/Properties/WMAppManifest.xml IPath wpAppManifest = destinationPath.append(PROPERTIES).append(WPLibraryResolver.WP_APP_MANIFEST_XML); templatedFileCopy(resolver.getTemplateFile(new Path(WPLibraryResolver.WP_APP_MANIFEST_XML)), toURL(wpAppManifest.toFile()), values); values.clear(); values.put(SAFE_PROJECT_NAME, packageName); // /${project_name}/App.xaml templatedFileCopy(resolver.getTemplateFile(new Path(WPLibraryResolver.APP_XAML)), toURL(destinationPath.append(WPLibraryResolver.APP_XAML).toFile()), values); // /${project_name}/App.xaml.cs templatedFileCopy(resolver.getTemplateFile(new Path(WPLibraryResolver.APP_XAML_CS)), toURL(destinationPath.append(WPLibraryResolver.APP_XAML_CS).toFile()), values); // /${project_name}/MainPage.xaml templatedFileCopy(resolver.getTemplateFile(new Path(WPLibraryResolver.MAIN_PAGE_XAML)), toURL(destinationPath.append(WPLibraryResolver.MAIN_PAGE_XAML).toFile()), values); // /${project_name}/MainPage.xaml.cs templatedFileCopy(resolver.getTemplateFile(new Path(WPLibraryResolver.MAIN_PAGE_XAML_CS)), toURL(destinationPath.append(WPLibraryResolver.MAIN_PAGE_XAML_CS).toFile()), values); // /${project_name}/CordovaWP8AppProj.csproj templatedFileCopy(resolver.getTemplateFile(new Path(WPLibraryResolver.DEFAULT_APP_NAME_CSPROJ)), toURL(destinationPath.append(safeAppName + WPProjectUtils.CSPROJ_EXTENSION).toFile()), values); // remove default .csproj file if exists File defaultCsprojFile = destinationPath.append(WPLibraryResolver.DEFAULT_APP_NAME_CSPROJ).toFile(); if (defaultCsprojFile.exists()) { org.apache.commons.io.FileUtils.deleteQuietly(defaultCsprojFile); } values.put(WPLibraryResolver.DEFAULT_APP_NAME, safeAppName); // /${project_name}/CordovaWP8AppProj.sln templatedFileCopy(resolver.getTemplateFile(new Path(WPLibraryResolver.DEFAULT_SLN_NAME)), toURL(destinationPath.append(safeAppName + WPProjectUtils.SLN_EXTENSION).toFile()), values); // remove default .sln file if exists File defaultSlnFile = destinationPath.append(WPLibraryResolver.DEFAULT_SLN_NAME).toFile(); if (defaultSlnFile.exists()) { org.apache.commons.io.FileUtils.deleteQuietly(defaultSlnFile); } org.apache.commons.io.FileUtils.deleteQuietly(new File(destinationDir, "Bin")); //$NON-NLS-1$ org.apache.commons.io.FileUtils.deleteQuietly(new File(destinationDir, "obj")); //$NON-NLS-1$ org.apache.commons.io.FileUtils.deleteQuietly(new File(destinationDir, "__PreviewImage.jpg")); //$NON-NLS-1$ org.apache.commons.io.FileUtils.deleteQuietly(new File(destinationDir, "__TemplateIcon.png")); //$NON-NLS-1$ org.apache.commons.io.FileUtils.deleteQuietly(new File(destinationDir, "MyTemplate.vstemplate")); //$NON-NLS-1$ } catch (IOException e) { throw new CoreException( new Status(IStatus.ERROR, WPCore.PLUGIN_ID, Messages.WPProjectGenerator_GenerationError, e)); } }
From source file:au.org.ands.vocabs.toolkit.provider.transform.SesameInsertMetadataTransformProvider.java
@Override public final boolean transform(final TaskInfo taskInfo, final JsonNode subtask, final HashMap<String, String> results) { boolean result = true; // Get the metadata values to be inserted. Version version = taskInfo.getVersion(); // Use the release date as it is. As it may be // YYYY, YYYY-MM, or YYYY-MM-DD, can't use a date // formatter. String issuedDate = version.getReleaseDate(); String versionTitle = version.getTitle(); // Construct bindings for SPARQL Update. ValueFactory factory = ValueFactoryImpl.getInstance(); HashMap<String, Value> bindings = new HashMap<String, Value>(); if (issuedDate != null) { bindings.put("issuedDate", factory.createLiteral(issuedDate)); result = SesameTransformUtils.runUpdate(taskInfo, subtask, results, INSERT_DCTERMS_ISSUED_METADATA_UPDATE, bindings); if (!result) { // Failure applying the Update. Stop here. return false; }/*from ww w. j a v a 2 s . c o m*/ } if (versionTitle != null) { // Reset bindings and apply the version title Update. bindings.clear(); bindings.put("versionTitle", factory.createLiteral(versionTitle)); result = SesameTransformUtils.runUpdate(taskInfo, subtask, results, INSERT_OWL_VERSIONINFO_METADATA_UPDATE, bindings); if (!result) { // Failure applying the Update. Stop here. return false; } } /* Future work: Add ADMS status. The problem is, that the * publication workflow is not so great, so metadata injection * doesn't happen when the status changes. So once set, always * set with the same value. If/when publication workflow is * improved, uncomment this. */ /* String versionStatus = admsStatusMap.get(version.getStatus()); if (versionStatus != null) { // Reset bindings and apply the ADMS status Update. bindings.clear(); bindings.put("versionStatus", factory.createURI(versionStatus)); return SesameTransformUtils.runUpdate(taskInfo, subtask, results, INSERT_ADMS_STATUS_METADATA_UPDATE, bindings); } */ return result; }
From source file:org.nuxeo.launcher.config.JBossConfiguratorTest.java
@Test public void testSaveFilteredConfiguration() throws ConfigurationException { String propToSave1 = "nuxeo.notification.eMailSubjectPrefix"; String valueToSave1 = "[Nuxeo test]"; String propToSave2 = "mail.transport.user"; String valueToSave2 = "tester"; assertTrue(configGenerator.init());/*from w ww . j a v a2 s.co m*/ assertTrue(configGenerator.isConfigurable()); HashMap<String, String> parameters = new HashMap<String, String>(); parameters.put(propToSave1, valueToSave1); configGenerator.saveFilteredConfiguration(parameters); System.setProperty(ConfigurationGenerator.NUXEO_CONF, configGenerator.getNuxeoConf().getPath()); configGenerator = new ConfigurationGenerator(); assertTrue(configGenerator.init()); Properties userConfig = configGenerator.getUserConfig(); assertEquals("Save fail", valueToSave1, userConfig.getProperty(propToSave1)); parameters.clear(); parameters.put(propToSave2, valueToSave2); configGenerator.saveFilteredConfiguration(parameters); configGenerator = new ConfigurationGenerator(); assertTrue(configGenerator.init()); userConfig = configGenerator.getUserConfig(); assertEquals("Save fail", valueToSave2, userConfig.getProperty(propToSave2)); assertEquals("Save fail", valueToSave1, userConfig.getProperty(propToSave1)); }
From source file:io.pravega.service.server.host.ZKSegmentContainerMonitorTest.java
@Test public void testShutdownNotYetStartedContainer() throws Exception { @Cleanup/*from www . j a v a 2 s. co m*/ CuratorFramework zkClient = startClient(); initializeHostContainerMapping(zkClient); SegmentContainerRegistry containerRegistry = createMockContainerRegistry(); @Cleanup ZKSegmentContainerMonitor segMonitor = createContainerMonitor(containerRegistry, zkClient); segMonitor.initialize(Duration.ofSeconds(1)); // Simulate a container that takes a long time to start. Should be greater than a few monitor loops. ContainerHandle containerHandle = mock(ContainerHandle.class); when(containerHandle.getContainerId()).thenReturn(2); CompletableFuture<ContainerHandle> startupFuture = FutureHelpers .delayedFuture(() -> CompletableFuture.completedFuture(containerHandle), 3000, executorService()); when(containerRegistry.startContainer(eq(2), any())).thenReturn(startupFuture); // Use ZK to send that information to the Container Manager. HashMap<Host, Set<Integer>> currentData = deserialize(zkClient, PATH); currentData.put(PRAVEGA_SERVICE_ENDPOINT, Collections.singleton(2)); zkClient.setData().forPath(PATH, SerializationUtils.serialize(currentData)); // Verify it's not yet started. verify(containerRegistry, timeout(10000).atLeastOnce()).startContainer(eq(2), any()); assertEquals(0, segMonitor.getRegisteredContainers().size()); // Now simulate shutting it down. when(containerRegistry.stopContainer(any(), any())).thenReturn(CompletableFuture.completedFuture(null)); currentData.clear(); zkClient.setData().forPath(PATH, SerializationUtils.serialize(currentData)); verify(containerRegistry, timeout(10000).atLeastOnce()).stopContainer(any(), any()); Thread.sleep(2000); assertEquals(0, segMonitor.getRegisteredContainers().size()); }
From source file:fragment.web.SystemHealthControllerTest.java
@Test public void testaddStatus() { request = new MockHttpServletRequest(); ServiceNotification notification = serviceNotificationDAO.find(1L); ServiceNotificationForm form = new ServiceNotificationForm(notification); form.setDateFormat("ddMMyyyy"); form.setServiceInstanceUUID(defaultServiceInstance.getUuid()); HashMap<String, String> map = controller.addStatus(form, request); Assert.assertEquals(map.get("description"), notification.getDescription().toString()); Assert.assertEquals(map.get("notificationType"), notification.getNotificationType().toString()); Assert.assertNotNull(map.get("status")); Assert.assertNotNull(map.get("recordedOn")); Assert.assertNotNull(map.get("status")); map.clear(); notification.setNotificationType(Type.ISSUE); serviceNotificationDAO.save(notification); map = controller.addStatus(form, request); Assert.assertEquals(map.get("notificationType"), notification.getNotificationType().toString()); map.clear();/*ww w . j a v a 2s . c om*/ notification.setNotificationType(Type.RESOLUTION); serviceNotificationDAO.save(notification); map = controller.addStatus(form, request); Assert.assertEquals(map.get("notificationType"), notification.getNotificationType().toString()); }