001: /* ResolverMap.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Wed Oct 17 11:24:09 2007, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: This program is distributed under GPL Version 2.0 in the hope that
016: it will be useful, but WITHOUT ANY WARRANTY.
017: }}IS_RIGHT
018: */
019: package org.zkoss.zkmax.xel.util;
020:
021: import java.util.Collection;
022: import java.util.Collections;
023: import java.util.Map;
024: import java.util.Set;
025:
026: import org.zkoss.xel.VariableResolver;
027:
028: /**
029: * A Map interface on top of {@link VariableResolver}.
030: *
031: * @author tomyeh
032: * @since 3.0.0
033: */
034: public class ResolverMap implements Map {
035: private VariableResolver _resolver;
036:
037: public ResolverMap(VariableResolver resolver) {
038: _resolver = resolver;
039: }
040:
041: public boolean containsKey(Object key) {
042: return get(key) != null;
043: }
044:
045: public Object get(Object key) {
046: return _resolver.resolveVariable((String) key);
047: }
048:
049: /** Always returns an empty set, no matter any variable is defined.
050: */
051: public Set entrySet() {
052: return Collections.EMPTY_SET;
053: }
054:
055: public void clear() {
056: throw new UnsupportedOperationException();
057: }
058:
059: /** Always returns false, no matter any variable is defined.
060: */
061: public boolean containsValue(Object value) {
062: return false;
063: }
064:
065: /** Always returns true, no matter any variable is defined.
066: */
067: public boolean isEmpty() {
068: return true;
069: }
070:
071: /** Always returns an empty set, no matter any variable is defined.
072: */
073: public Set keySet() {
074: return Collections.EMPTY_SET;
075: }
076:
077: public Object put(Object key, Object value) {
078: throw new UnsupportedOperationException();
079: }
080:
081: public void putAll(Map map) {
082: throw new UnsupportedOperationException();
083: }
084:
085: public Object remove(Object key) {
086: throw new UnsupportedOperationException();
087: }
088:
089: /** Always returns 0, no matter any variable is defined.
090: */
091: public int size() {
092: return 0;
093: }
094:
095: /** Always returns an empty collection, no matter any variable is defined.
096: */
097: public Collection values() {
098: return Collections.EMPTY_LIST;
099: }
100: }
|