FileDocCategorySizeDatePackage
MappedByteBufferFactory.javaAPI DocAndroid 1.5 API2587Wed May 06 22:41:04 BST 2009org.apache.harmony.nio.internal

MappedByteBufferFactory

public class MappedByteBufferFactory extends Object

Fields Summary
static final Constructor
constructor
Constructors Summary
Methods Summary
static java.nio.MappedByteBuffergetBuffer(org.apache.harmony.luni.platform.PlatformAddress addr, int mapmode, long size, int offset)

        constructor = AccessController
                .doPrivileged(new PrivilegedAction<Constructor>() {
                    public Constructor run() {
                        try {
                            Class wrapperClazz = ClassLoader
                                    .getSystemClassLoader().loadClass(
                                            "java.nio.MappedByteBufferAdapter"); //$NON-NLS-1$
                            Constructor result = wrapperClazz
                                    .getConstructor(new Class[] {
                                            PlatformAddress.class, int.class,
                                            int.class, int.class });
                            result.setAccessible(true);
                            return result;
                        } catch (Exception e) {
                            throw new RuntimeException(e);
                        }
                    }
                });
    
        // Spec points out explicitly that the size of map should be no greater than
        // Integer.MAX_VALUE, so long to int cast is safe here.
        return (MappedByteBuffer) constructor.newInstance(new Object[] { addr,
                new Integer((int) size), new Integer(offset),
                new Integer(mapmode) });