Java Code Examples for java.util.Hashtable.clear()
The following are Jave code examples for showing how to use
clear() of the
java.util.Hashtable
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: ramus File: Request.java View Source Code | 6 votes |
private static void readParams(final String line, final Hashtable<String, String> params) { params.clear(); final StringTokenizer st = new StringTokenizer(line, "&"); try { while (st.hasMoreTokens()) { final StringTokenizer tmp = new StringTokenizer(st.nextToken(), "="); final String key = tmp.nextToken(); final String value = decoderString(tmp.nextToken()); params.put(key, value); } } catch (final Exception e) { } }
Example 2
Project: javaide File: EmptyHashtableExample.java View Source Code | 6 votes |
public static void main(String[] args) { //create Hashtable object Hashtable ht = new Hashtable(); //add key value pairs to Hashtable ht.put("1", "One"); ht.put("2", "Two"); ht.put("3", "Three"); /* To remove all values or clear Hashtable use void clear method() of Hashtable class. Remove method removes all key value pairs contained in Hashtable. */ ht.clear(); System.out.println("Total key value pairs in Hashtable are : " + ht.size()); }
Example 3
Project: pac4j-plus File: HttpSessionStorage.java View Source Code | 6 votes |
/** * Returns previously stored message with the given ID or null, if there is no message * stored. * <p> * Message is stored in String format and must be unmarshalled into XMLObject. Call to this * method may thus be expensive. * <p> * Messages are automatically cleared upon successful reception, as we presume that there * are never multiple ongoing SAML exchanges for the same session. This saves memory used by * the session. * * @param messageID ID of message to retrieve * @return message found or null */ @Override public XMLObject retrieveMessage(final String messageID) { final Hashtable<String, XMLObject> messages = getMessages(); final XMLObject o = messages.get(messageID); if (o == null) { log.debug("Message {} not found in session {}", messageID, session.getSessionIdentifier()); return null; } log.debug("Message {} found in session {}, clearing", messageID, session.getSessionIdentifier()); messages.clear(); updateSession(messages); return o; }
Example 4
Project: ramus File: Request.java View Source Code | 5 votes |
public static String getParams(final String line, final Hashtable<String, String> params) { char c; int j = line.length(); params.clear(); for (int i = 0; i < line.length(); i++) { if (line.charAt(i) == ' ') { j = i; break; } } String res = null; for (int i = 0; i < j; i++) { c = line.charAt(i); if (c == '#') { res = line.substring(0, i); } else if (c == '?') { if (res == null) { res = line.substring(0, i); } readParams(line.substring(i + 1, j), params); break; } } if (res == null) { res = line.substring(0, j); } return res; }
Example 5
Project: incubator-netbeans File: ActivatorTest.java View Source Code | 4 votes |
public void testProvidesRequiresNeedsParsing() throws Exception { Hashtable<String,String> headers = new Hashtable<String,String>(); assertEquals(Collections.emptySet(), Activator.provides(headers)); assertEquals(Collections.emptySet(), Activator.requires(headers)); assertEquals(Collections.emptySet(), Activator.needs(headers)); headers.put("Bundle-SymbolicName", "org.netbeans.modules.projectui"); headers.put("OpenIDE-Module-Provides", "org.netbeans.modules.project.uiapi.ActionsFactory, " + "org.netbeans.modules.project.uiapi.OpenProjectsTrampoline, org.netbeans.modules.project.uiapi.ProjectChooserFactory"); assertEquals(new TreeSet<String>(Arrays.asList( "cnb.org.netbeans.modules.projectui", "org.netbeans.modules.project.uiapi.ActionsFactory", "org.netbeans.modules.project.uiapi.OpenProjectsTrampoline", "org.netbeans.modules.project.uiapi.ProjectChooserFactory" )), Activator.provides(headers)); assertEquals(Collections.emptySet(), Activator.requires(headers)); assertEquals(Collections.emptySet(), Activator.needs(headers)); headers.clear(); headers.put("Require-Bundle", "org.netbeans.api.progress;bundle-version=\"[101.0.0,200)\", " + "org.netbeans.spi.quicksearch;bundle-version=\"[1.0.0,100)\""); headers.put("OpenIDE-Module-Requires", "org.openide.modules.InstalledFileLocator"); assertEquals(Collections.emptySet(), Activator.provides(headers)); assertEquals(new TreeSet<String>(Arrays.asList( "cnb.org.netbeans.api.progress", "cnb.org.netbeans.spi.quicksearch", "org.openide.modules.InstalledFileLocator" )), Activator.requires(headers)); assertEquals(Collections.emptySet(), Activator.needs(headers)); headers.clear(); headers.put("OpenIDE-Module-Needs", "org.netbeans.modules.java.preprocessorbridge.spi.JavaSourceUtilImpl"); assertEquals(Collections.emptySet(), Activator.provides(headers)); assertEquals(Collections.emptySet(), Activator.requires(headers)); assertEquals(Collections.singleton("org.netbeans.modules.java.preprocessorbridge.spi.JavaSourceUtilImpl"), Activator.needs(headers)); headers.clear(); String os = System.getProperty("os.name"); System.setProperty("os.name", "Windows 2000"); try { headers.put("Bundle-SymbolicName", "org.openide.modules"); final TreeSet<String> export = new TreeSet<String>(Arrays.asList( "cnb.org.openide.modules", "org.openide.modules.os.Windows" )); if (isJavaFX()) { export.add("org.openide.modules.jre.JavaFX"); } assertEquals(export, Activator.provides(headers)); assertEquals(Collections.emptySet(), Activator.requires(headers)); assertEquals(Collections.emptySet(), Activator.needs(headers)); } finally { System.setProperty("os.name", os); } }
Example 6
Project: OpenJSharp File: JComponent.java View Source Code | 4 votes |
/** * Registers any bound <code>WHEN_IN_FOCUSED_WINDOW</code> actions with * the <code>KeyboardManager</code>. If <code>onlyIfNew</code> * is true only actions that haven't been registered are pushed * to the <code>KeyboardManager</code>; * otherwise all actions are pushed to the <code>KeyboardManager</code>. * * @param onlyIfNew if true, only actions that haven't been registered * are pushed to the <code>KeyboardManager</code> */ private void registerWithKeyboardManager(boolean onlyIfNew) { InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false); KeyStroke[] strokes; Hashtable<KeyStroke, KeyStroke> registered = (Hashtable<KeyStroke, KeyStroke>)getClientProperty (WHEN_IN_FOCUSED_WINDOW_BINDINGS); if (inputMap != null) { // Push any new KeyStrokes to the KeyboardManager. strokes = inputMap.allKeys(); if (strokes != null) { for (int counter = strokes.length - 1; counter >= 0; counter--) { if (!onlyIfNew || registered == null || registered.get(strokes[counter]) == null) { registerWithKeyboardManager(strokes[counter]); } if (registered != null) { registered.remove(strokes[counter]); } } } } else { strokes = null; } // Remove any old ones. if (registered != null && registered.size() > 0) { Enumeration<KeyStroke> keys = registered.keys(); while (keys.hasMoreElements()) { KeyStroke ks = keys.nextElement(); unregisterWithKeyboardManager(ks); } registered.clear(); } // Updated the registered Hashtable. if (strokes != null && strokes.length > 0) { if (registered == null) { registered = new Hashtable<KeyStroke, KeyStroke>(strokes.length); putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, registered); } for (int counter = strokes.length - 1; counter >= 0; counter--) { registered.put(strokes[counter], strokes[counter]); } } else { putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, null); } }
Example 7
Project: jdk8u-jdk File: JComponent.java View Source Code | 4 votes |
/** * Registers any bound <code>WHEN_IN_FOCUSED_WINDOW</code> actions with * the <code>KeyboardManager</code>. If <code>onlyIfNew</code> * is true only actions that haven't been registered are pushed * to the <code>KeyboardManager</code>; * otherwise all actions are pushed to the <code>KeyboardManager</code>. * * @param onlyIfNew if true, only actions that haven't been registered * are pushed to the <code>KeyboardManager</code> */ private void registerWithKeyboardManager(boolean onlyIfNew) { InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false); KeyStroke[] strokes; Hashtable<KeyStroke, KeyStroke> registered = (Hashtable<KeyStroke, KeyStroke>)getClientProperty (WHEN_IN_FOCUSED_WINDOW_BINDINGS); if (inputMap != null) { // Push any new KeyStrokes to the KeyboardManager. strokes = inputMap.allKeys(); if (strokes != null) { for (int counter = strokes.length - 1; counter >= 0; counter--) { if (!onlyIfNew || registered == null || registered.get(strokes[counter]) == null) { registerWithKeyboardManager(strokes[counter]); } if (registered != null) { registered.remove(strokes[counter]); } } } } else { strokes = null; } // Remove any old ones. if (registered != null && registered.size() > 0) { Enumeration<KeyStroke> keys = registered.keys(); while (keys.hasMoreElements()) { KeyStroke ks = keys.nextElement(); unregisterWithKeyboardManager(ks); } registered.clear(); } // Updated the registered Hashtable. if (strokes != null && strokes.length > 0) { if (registered == null) { registered = new Hashtable<KeyStroke, KeyStroke>(strokes.length); putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, registered); } for (int counter = strokes.length - 1; counter >= 0; counter--) { registered.put(strokes[counter], strokes[counter]); } } else { putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, null); } }
Example 8
Project: openjdk-jdk10 File: JComponent.java View Source Code | 4 votes |
/** * Registers any bound <code>WHEN_IN_FOCUSED_WINDOW</code> actions with * the <code>KeyboardManager</code>. If <code>onlyIfNew</code> * is true only actions that haven't been registered are pushed * to the <code>KeyboardManager</code>; * otherwise all actions are pushed to the <code>KeyboardManager</code>. * * @param onlyIfNew if true, only actions that haven't been registered * are pushed to the <code>KeyboardManager</code> */ private void registerWithKeyboardManager(boolean onlyIfNew) { InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false); KeyStroke[] strokes; @SuppressWarnings("unchecked") Hashtable<KeyStroke, KeyStroke> registered = (Hashtable<KeyStroke, KeyStroke>)getClientProperty (WHEN_IN_FOCUSED_WINDOW_BINDINGS); if (inputMap != null) { // Push any new KeyStrokes to the KeyboardManager. strokes = inputMap.allKeys(); if (strokes != null) { for (int counter = strokes.length - 1; counter >= 0; counter--) { if (!onlyIfNew || registered == null || registered.get(strokes[counter]) == null) { registerWithKeyboardManager(strokes[counter]); } if (registered != null) { registered.remove(strokes[counter]); } } } } else { strokes = null; } // Remove any old ones. if (registered != null && registered.size() > 0) { Enumeration<KeyStroke> keys = registered.keys(); while (keys.hasMoreElements()) { KeyStroke ks = keys.nextElement(); unregisterWithKeyboardManager(ks); } registered.clear(); } // Updated the registered Hashtable. if (strokes != null && strokes.length > 0) { if (registered == null) { registered = new Hashtable<KeyStroke, KeyStroke>(strokes.length); putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, registered); } for (int counter = strokes.length - 1; counter >= 0; counter--) { registered.put(strokes[counter], strokes[counter]); } } else { putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, null); } }