List of usage examples for java.util AbstractMap AbstractMap
protected AbstractMap()
From source file:com.revolsys.ui.web.config.JexlHttpServletRequestContext.java
@Override public Map getVars() { return new AbstractMap() { @Override/*from w w w . j a v a 2 s . c o m*/ public Set entrySet() { final Map map = new HashMap(); map.putAll(JexlHttpServletRequestContext.this.request.getParameterMap()); for (final Enumeration names = JexlHttpServletRequestContext.this.request.getAttributeNames(); names .hasMoreElements();) { final String name = (String) names.nextElement(); map.put(name, JexlHttpServletRequestContext.this.request.getAttribute(name)); } if (JexlHttpServletRequestContext.this.servletContext != null) { for (final Enumeration names = JexlHttpServletRequestContext.this.servletContext .getAttributeNames(); names.hasMoreElements();) { final String name = (String) names.nextElement(); map.put(name, JexlHttpServletRequestContext.this.servletContext.getAttribute(name)); } } return map.entrySet(); } @Override public Object get(final Object key) { if (key.equals("request")) { return JexlHttpServletRequestContext.this.request; } else if (key.equals("requestURI")) { return JexlHttpServletRequestContext.this.urlPathHelper .getOriginatingRequestUri(JexlHttpServletRequestContext.this.request); } final String keyString = key.toString(); Object value = null; if (JexlHttpServletRequestContext.this.servletContext != null) { value = JexlHttpServletRequestContext.this.servletContext.getAttribute(keyString); } if (value == null) { value = JexlHttpServletRequestContext.this.request.getAttribute(keyString); if (value == null) { value = JexlHttpServletRequestContext.this.request.getParameter(keyString); } } if (value == null) { return ""; } else { return value; } } }; }
From source file:com.revolsys.ui.web.config.HttpServletRequestJexlContext.java
@Override public Map getVars() { return new AbstractMap<String, Object>() { @Override//from ww w .j a v a 2s . c om @SuppressWarnings("unchecked") public Set<Entry<String, Object>> entrySet() { final HttpServletRequest request = getRequest(); final Map<String, Object> map = new HashMap<>(); map.putAll(request.getParameterMap()); for (final Enumeration<String> names = request.getAttributeNames(); names.hasMoreElements();) { final String name = names.nextElement(); map.put(name, request.getAttribute(name)); } if (HttpServletRequestJexlContext.this.servletContext != null) { for (final Enumeration<String> names = HttpServletRequestJexlContext.this.servletContext .getAttributeNames(); names.hasMoreElements();) { final String name = names.nextElement(); map.put(name, HttpServletRequestJexlContext.this.servletContext.getAttribute(name)); } } final Map<String, Object> attributes = HttpServletRequestJexlContext.this.localAttributes.get(); if (attributes != null) { map.putAll(attributes); } map.put("request", request); map.put("requestURI", HttpServletRequestJexlContext.this.urlPathHelper.getOriginatingRequestUri(request)); return map.entrySet(); } }; }
From source file:com.opensymphony.able.action.DefaultCrudActionBean.java
public Map<String, Object> getAllValues() { return new AbstractMap<String, Object>() { @Override/*www . j av a2 s . co m*/ public Object get(Object propertyName) { return getAllValuesForProperty((String) propertyName); } @Override public Set<Entry<String, Object>> entrySet() { return Collections.EMPTY_SET; } }; }
From source file:com.github.jknack.extend.Extend.java
/** * Converts an object to a {@link Map}. The resulting map is the union of the bean properties and * all the extra properties.//from w w w .j a v a2s. c o m * * @param source The object to extend. Required. * @param properties The extra property set. Required. * @param <T> The source type. * @return A new immutable map. */ @SuppressWarnings("unchecked") public static <T> Map<String, Object> map(final T source, final Map<String, Object> properties) { notNull(source, "The source object is required."); notNull(properties, "The properties is required"); final BeanMap beanMap = BeanMap.create(source); return new AbstractMap<String, Object>() { @Override public Object put(final String key, final Object value) { return null; } @Override public Object get(final Object key) { Object value = properties.get(key); return value == null ? beanMap.get(key) : value; } @Override public Set<Entry<String, Object>> entrySet() { LinkedHashMap<String, Object> mergedProperties = new LinkedHashMap<String, Object>(beanMap); mergedProperties.putAll(properties); return mergedProperties.entrySet(); } }; }
From source file:mondrian.olap.Util.java
/** * Converts a {@link Properties} object to a string-to-string {@link Map}. * * @param properties Properties//ww w . ja va 2 s .c o m * @return String-to-string map */ public static Map<String, String> toMap(final Properties properties) { return new AbstractMap<String, String>() { @SuppressWarnings({ "unchecked" }) public Set<Entry<String, String>> entrySet() { return (Set) properties.entrySet(); } }; }
From source file:org.jboss.dashboard.workspace.PanelInstance.java
public Map<String, String> getTitle() { LocaleManager localeManager = LocaleManager.lookup(); final String[] langs = localeManager.getPlatformAvailableLangs(); Map<String, String> title = new AbstractMap<String, String>() { public Set<Entry<String, String>> entrySet() { return new AbstractSet<Entry<String, String>>() { public int size() { return langs.length; }//from ww w. ja va2 s. co m public Iterator<Map.Entry<String, String>> iterator() { return new Iterator<Map.Entry<String, String>>() { int i = 0; public void remove() { throw new UnsupportedOperationException(); } public boolean hasNext() { return i < langs.length; } public Map.Entry<String, String> next() { i++; return new Map.Entry<String, String>() { int index = i - 1; public String getKey() { return langs[index]; } public String getValue() { return getParameterValue(PARAMETER_TITLE, langs[index]); } public String setValue(String value) { throw new UnsupportedOperationException(); } }; } }; } }; } }; return title; }
From source file:org.sakaiproject.content.tool.ListItem.java
/** * Provides a huge wrapper around ResourceProperties to use it as a Map * * @param resourceProperties ResourceProperties to wrap * @return the wrapped value/*from w w w. j a va2s . c o m*/ */ private Map<String, Object> wrapResourcePropertiesInMap(final ResourceProperties resourceProperties) { return new AbstractMap<String, Object>() { public boolean isEmpty() { return !resourceProperties.getPropertyNames().hasNext(); } public boolean containsKey(Object key) { return resourceProperties.get((String) key) != null; } public Object get(Object key) { return resourceProperties.get((String) key); } @Override public Set<Entry<String, Object>> entrySet() { return new AbstractSet<Entry<String, Object>>() { @Override public Iterator<Entry<String, Object>> iterator() { return new Iterator<Entry<String, Object>>() { private final Iterator<String> propertiesNames = resourceProperties.getPropertyNames(); public boolean hasNext() { return propertiesNames.hasNext(); } public Entry<String, Object> next() { return new Entry<String, Object>() { private final String key = propertiesNames.next(); public String getKey() { return key; } public Object getValue() { return resourceProperties.get(key); } public Object setValue(Object value) { throw new UnsupportedOperationException(); } }; } public void remove() { throw new UnsupportedOperationException(); } }; } @Override public int size() { throw new UnsupportedOperationException(); } }; } }; }
From source file:org.sakaiproject.content.tool.ListItem.java
/** * Provides a huge wrapper around parameterParser to use it as a Map * * @param params ParameterParser to wrap * @return the wrapped value//from w w w .jav a 2 s .co m */ private Map<String, ?> wrapParametersInMap(final ParameterParser params) { return new AbstractMap<String, Object>() { public boolean isEmpty() { return !params.getNames().hasNext(); } public boolean containsKey(Object key) { return params.get((String) key) != null; } public Object get(Object key) { String[] value = params.getStrings((String) key); if (value == null || value.length == 0) return null; else if (value.length > 1) { return value; } else return value[0]; } @Override public Set<Entry<String, Object>> entrySet() { return new AbstractSet<Entry<String, Object>>() { @Override public Iterator<Entry<String, Object>> iterator() { return new Iterator<Entry<String, Object>>() { private final Iterator<String> parametersNames = params.getNames(); public boolean hasNext() { return parametersNames.hasNext(); } public Entry<String, Object> next() { return new Entry<String, Object>() { private final String key = parametersNames.next(); public String getKey() { return key; } public Object getValue() { String[] value = params.getStrings(key); if (value == null || value.length == 0) return null; else if (value.length > 1) { return value; } else return value[0]; } public Object setValue(Object value) { throw new UnsupportedOperationException(); } }; } public void remove() { throw new UnsupportedOperationException(); } }; } @Override public int size() { throw new UnsupportedOperationException(); } }; } }; }
From source file:org.wso2.carbon.uuf.internal.io.StaticResolver.java
/** * The constructor of StaticResolver class *//*from w w w .j a v a2 s .c o m*/ public StaticResolver() { if (UUFServer.isDevModeEnabled()) { /* * When the dev mode is enabled, we do not cache last modified dates of serving static resources. This is * achieved by setting a dummy map to the 'resourcesLastModifiedDates' field. Dummy map does not store any * values and it size is always zero. */ this.resourcesLastModifiedDates = new AbstractMap<Path, ZonedDateTime>() { @Override public Set<Entry<Path, ZonedDateTime>> entrySet() { return Collections.emptySet(); // No entries in this dummy map. } @Override public ZonedDateTime put(Path key, ZonedDateTime value) { return value; // Do not store in this is dummy Map. } }; } else { this.resourcesLastModifiedDates = new ConcurrentHashMap<>(); } }