MapAdapter.java

    1/*******************************************************************************
    2 * Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and others
    3 * All rights reserved. This program and the accompanying materials
    4 * are made available under the terms of the Eclipse Public License v1.0
    5 * which accompanies this distribution, and is available at
    6 * http://www.eclipse.org/legal/epl-v10.html
    7 *
    8 * Contributors:
    9 *    Marc R. Hoffmann - initial API and implementation
   10 *    
   11 * $Id: $
   12 *******************************************************************************/
   13package org.jacoco.core.runtime;
   14
   15import java.util.Collection;
   16import java.util.Map;
   17import java.util.Set;
   18
   19import org.jacoco.core.data.ExecutionDataStore;
   20
   21/**
   22 * Utility class that wraps read-access to an {@link ExecutionDataStore} in a
   23 * {@link Map} interface. The map interface can then safely be referenced by
   24 * instrumented code.
   25 * 
   26 * @author Marc R. Hoffmann
   27 * @version $Revision: $
   28 */
   29class MapAdapter implements Map<Long, boolean[]> {
   30
   31    private final ExecutionDataStore store;
   32
   33    MapAdapter(final ExecutionDataStore store) {
   34        this.store = store;
   35    }
   36
   37    public boolean[] get(final Object key) {
   38        final Long id = (Long) key;
   39        synchronized (store) {
   40            final boolean[] data = store.getData(id);
   41            if (data == null) {
   42                throw new IllegalStateException(String.format(
   43                        "Unknown class id %x.", id));
   44            }
   45            return data;
   46        }
   47    }
   48
   49    public void clear() {
   50        throw new UnsupportedOperationException();
   51    }
   52
   53    public boolean containsKey(final Object key) {
   54        throw new UnsupportedOperationException();
   55    }
   56
   57    public boolean containsValue(final Object value) {
   58        throw new UnsupportedOperationException();
   59    }
   60
   61    public Set<Entry<Long, boolean[]>> entrySet() {
   62        throw new UnsupportedOperationException();
   63    }
   64
   65    public boolean isEmpty() {
   66        throw new UnsupportedOperationException();
   67    }
   68
   69    public Set<Long> keySet() {
   70        throw new UnsupportedOperationException();
   71    }
   72
   73    public boolean[] put(final Long key, final boolean[] value) {
   74        throw new UnsupportedOperationException();
   75    }
   76
   77    public void putAll(final Map<? extends Long, ? extends boolean[]> t) {
   78        throw new UnsupportedOperationException();
   79    }
   80
   81    public boolean[] remove(final Object key) {
   82        throw new UnsupportedOperationException();
   83    }
   84
   85    public Collection<boolean[]> values() {
   86        throw new UnsupportedOperationException();
   87    }
   88
   89    public int size() {
   90        throw new UnsupportedOperationException();
   91    }
   92
   93}