Java ByteBuffer Clean getCleanerMethod(final ByteBuffer buffer)

Here you can find the source of getCleanerMethod(final ByteBuffer buffer)

Description

get Cleaner Method

License

Open Source License

Declaration

static Method getCleanerMethod(final ByteBuffer buffer) throws NoSuchMethodException 

Method Source Code


//package com.java2s;
/*/*from  w w  w .  j a  va2  s.  co m*/
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 * 
 *    (C) 2003-2008, Open Source Geospatial Foundation (OSGeo)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */

import java.lang.reflect.Method;
import java.nio.ByteBuffer;

import java.util.Map;

import java.util.concurrent.ConcurrentHashMap;

public class Main {
    static Map<Class, Method> cleanerMethodCache = new ConcurrentHashMap<Class, Method>();

    static Method getCleanerMethod(final ByteBuffer buffer) throws NoSuchMethodException {
        Method result = cleanerMethodCache.get(buffer.getClass());
        if (result == null) {
            result = buffer.getClass().getMethod("cleaner", (Class[]) null);
            result.setAccessible(true);
            cleanerMethodCache.put(buffer.getClass(), result);
        }
        return result;
    }
}

Related

  1. callCleaner(ByteBuffer byteBuffer)
  2. cleanBuffer(final ByteBuffer bb)
  3. cleanDirectBuffer(ByteBuffer buffer)
  4. cleanMemBuff(MappedByteBuffer buffer)