开发者

the method ceilingEntry(MyTime) is undefined for the type TreeMap<MyTime,Integer>

I'm working on a GWT project. I'm building a class that holds a TreeMap as a class member. The definition of the member:

private TreeMap<MyTime, Integer> VisitMap;

The Keys of the treeMap are objects of a type I've built before called "MyTime" (which implement Comparable interface), and the values are simple integers.

At one of the functions in the class I try to find the ceilingEntry using a MyTime object t开发者_JS百科hat was given as a key input.

public void getCeil(MyTime _MT)
{
    int myVal = VisitMap.ceilingEntry(_MT).getValue();
}

For some reason I get this error message:

the method ceilingEntry(MyTime) is undefined for the type TreeMap<MyTime,Integer>. 

Any ideas?


Are you trying to use this in client-side code?

GWT JRE emulation doesn't support all of the JRE classes. According to GWT 1.6 docs, only following methods of treemap are supported:

TreeMap(), TreeMap(Comparator), TreeMap(Map), TreeMap(SortedMap), clear(), comparator(), containsKey(Object), entrySet(), firstKey(), get(Object), headMap(K), lastKey(), put(K, V), remove(Object), size(), subMap(K, K), tailMap(K)

EDIT:

Just checked GWT 2.3 docs, and the support seems to be same as GWT 1.6


Are you using 1.5 ? ceilingEntry is only available in 1.6, looks like.

http://download.oracle.com/javase/1.5.0/docs/api/java/util/TreeMap.html#ceilingEntry%28K%29 http://download.oracle.com/javase/6/docs/api/java/util/TreeMap.html#ceilingEntry%28K%29


You have a Map of MyTime to Integer, which I assume holds the ceiling for the MyTime. So, shouldn't you just look up the Integer corresponding to the MyTime?

Also, getter usually returns a value.

I think your method should be just this:

public int getCeil(MyTime _MT) {
    return VisitMap.get(_MT);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜