KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > walker > MapEntryNode


1 /*
2  * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

5 package com.tc.object.walker;
6
7 public class MapEntryNode extends AbstractNode {
8
9   private final Object JavaDoc key;
10   private final Object JavaDoc value;
11   private int nextCount = 0;
12
13   public MapEntryNode(MapEntry entry) {
14     super(entry);
15     key = entry.getKey();
16     value = entry.getValue();
17   }
18
19   public boolean done() {
20     return nextCount > 1;
21   }
22
23   public MemberValue next() {
24     final MemberValue rv;
25
26     switch (nextCount) {
27       case 0: {
28         rv = MemberValue.mapKey(key);
29         break;
30       }
31       case 1: {
32         rv = MemberValue.mapValue(value);
33         break;
34       }
35       default:
36         throw new IllegalStateException JavaDoc();
37     }
38
39     nextCount++;
40     return rv;
41   }
42
43 }
44
Popular Tags