當前位置: 首頁>>代碼示例>>Java>>正文


Java Hashtable.clear方法代碼示例

本文整理匯總了Java中java.util.Hashtable.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java Hashtable.clear方法的具體用法?Java Hashtable.clear怎麽用?Java Hashtable.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Hashtable的用法示例。


在下文中一共展示了Hashtable.clear方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readParams

import java.util.Hashtable; //導入方法依賴的package包/類
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) {

    }
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:17,代碼來源:Request.java

示例2: main

import java.util.Hashtable; //導入方法依賴的package包/類
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());
  }
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:21,代碼來源:EmptyHashtableExample.java

示例3: retrieveMessage

import java.util.Hashtable; //導入方法依賴的package包/類
/**
 * 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;

}
 
開發者ID:yaochi,項目名稱:pac4j-plus,代碼行數:30,代碼來源:HttpSessionStorage.java

示例4: getParams

import java.util.Hashtable; //導入方法依賴的package包/類
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;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:30,代碼來源:Request.java

示例5: testProvidesRequiresNeedsParsing

import java.util.Hashtable; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:52,代碼來源:ActivatorTest.java

示例6: registerWithKeyboardManager

import java.util.Hashtable; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:61,代碼來源:JComponent.java

示例7: registerWithKeyboardManager

import java.util.Hashtable; //導入方法依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:62,代碼來源:JComponent.java


注:本文中的java.util.Hashtable.clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。