Android Buffer Get positionInBytes(Buffer dst)

Here you can find the source of positionInBytes(Buffer dst)

Description

position In Bytes

License

Apache License

Declaration

private static int positionInBytes(Buffer dst) 

Method Source Code

/*******************************************************************************
 * Copyright 2011 See AUTHORS file./*w w w.j a va  2 s  . co m*/
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.CharBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;

public class Main{
    private static int positionInBytes(Buffer dst) {
        if (dst instanceof ByteBuffer)
            return dst.position();
        else if (dst instanceof ShortBuffer)
            return dst.position() << 1;
        else if (dst instanceof CharBuffer)
            return dst.position() << 1;
        else if (dst instanceof IntBuffer)
            return dst.position() << 2;
        else if (dst instanceof LongBuffer)
            return dst.position() << 3;
        else if (dst instanceof FloatBuffer)
            return dst.position() << 2;
        else if (dst instanceof DoubleBuffer)
            return dst.position() << 3;
        else
            throw new GdxRuntimeException("Can't copy to a "
                    + dst.getClass().getName() + " instance");
    }
}