开发者

warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable localParams.put(name, values);

开发者 https://www.devze.com 2023-04-08 04:34 出处:网络
I have got 2 warning: -- The First is : HELPDESKGESTION2\\src\\java\\glpi\\filter\\LoginFilter.java:289: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtab

I have got 2 warning: -- The First is :

HELPDESKGESTION2\src\java\glpi\filter\LoginFilter.java:289: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
                    localParams.put(key, value);
                                   ^

--The Second is :

HELPDESK开发者_开发知识库GESTION2\src\java\glpi\filter\LoginFilter.java:292: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
            localParams.put(name, values);
                           ^

The Code ho generate this warnings is :

public void setParameter(String name, String []values) {
    if (debug) System.out.println("LoginFilter::setParameter(" + name + "=" + values + ")" + " localParams = "+ localParams);

    if (localParams == null) {
    localParams = new Hashtable();
    // Copy the parameters from the underlying request.
    Map wrappedParams = getRequest().getParameterMap();
    Set keySet = wrappedParams.keySet();
    for (Iterator it = keySet.iterator(); it.hasNext(); ) {
        Object key = it.next();
        Object value = wrappedParams.get(key);
        localParams.put(key, value);
    }
    }
    localParams.put(name, values);
}


Replace:

localParams = new Hashtable();

With:

localParams = new Hashtable<String,String>();

I assume you have a global variable like the following:

private Hashtable localParams;

Replace that with:

private Hashtable<String,String> localParams;

If you make the changes I suggested the warnings will go away but you will also have to replace all of your Object with String;


General thing is that you have to mention which type will represent the object that you are going to create. just think you have a lot of cars. you are going to meet someone. that person knows every car you have. but he doesn't know by which one you are coming this time. then he can't identify you at once when you coming. but if you had mentioned by which car you are coming earlier, he can easily identify you from far away also.

0

精彩评论

暂无评论...
验证码 换一张
取 消