summaryrefslogtreecommitdiff
path: root/src/repl/scala/tools/nsc/interpreter/IBindings.java
blob: b4cee4b9571fce6f2f62781603ecdd7e7c5f3462 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* NSC -- new Scala compiler
 * Copyright 2005-2013 LAMP/EPFL
 * @author Raphael Jolly
 */

package scala.tools.nsc.interpreter;

import java.util.Map;
import java.util.AbstractMap;
import java.util.Set;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
import javax.script.Bindings;

abstract class IBindings extends AbstractMap<String, Object> implements Bindings {
    public Set<Map.Entry<String, Object>> entrySet() {
        return new AbstractSet<Map.Entry<String, Object>>() {
            public int size() {
                return 0;
            }

            public Iterator<Map.Entry<String, Object>> iterator() {
                return new Iterator<Map.Entry<String, Object>>() {
                    public boolean hasNext() {
                        return false;
                    }

                    public Map.Entry<String, Object> next() {
                        throw new NoSuchElementException();
                    }

                    public void remove() {
                        throw new UnsupportedOperationException();
                    }
                };
            }

            public boolean add(Map.Entry<String, Object> e) {
                IBindings.this.put(e.getKey(), e.getValue());
                return true;
            }
        };
    }
}