当前位置: 首页>>代码示例>>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;未经允许,请勿转载。