Example usage for java.nio ByteBuffer hashCode

List of usage examples for java.nio ByteBuffer hashCode

Introduction

In this page you can find the example usage for java.nio ByteBuffer hashCode.

Prototype

public int hashCode() 

Source Link

Document

Calculates this buffer's hash code from the remaining chars.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    ByteBuffer bbuf = ByteBuffer.allocate(10);
    int capacity = bbuf.capacity(); // 10
    System.out.println(capacity);
    bbuf.putShort(2, (short) 123);
    ByteBuffer buf = bbuf.asReadOnlyBuffer();
    System.out.println(buf.hashCode());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    ByteBuffer bbuf = ByteBuffer.allocate(10);
    int capacity = bbuf.capacity(); // 10
    System.out.println(capacity);
    bbuf.putShort(2, (short) 123);

    System.out.println(bbuf.hashCode());
}

From source file:org.jhk.pulsing.web.aspect.UserDaoAspect.java

@AfterReturning(pointcut = "execution(org.jhk.pulsing.web.common.Result+ org.jhk.pulsing.web.dao.*.UserDao.*(..))", returning = "result")
public void patchUser(JoinPoint joinPoint, Result<User> result) {
    if (result.getCode() != SUCCESS) {
        return;//ww  w  . ja  v a  2  s.co m
    }

    User user = result.getData();
    user.setPassword(""); //blank out password
    Picture picture = user.getPicture();

    _LOGGER.debug("UserDaoAspect.setPictureUrl" + user);

    if (picture != null && picture.getName() != null) {

        ByteBuffer pBuffer = picture.getContent();
        String path = applicationContext.getServletContext().getRealPath("/resources/img");
        File parent = Paths.get(path).toFile();
        if (!parent.exists()) {
            parent.mkdirs();
        }

        String pFileName = user.getId().getId() + "_" + pBuffer.hashCode() + "_" + picture.getName();
        File pFile = Paths.get(path, pFileName).toFile();

        if (!pFile.exists()) {
            try (OutputStream fStream = Files.newOutputStream(pFile.toPath(), StandardOpenOption.CREATE_NEW,
                    StandardOpenOption.WRITE)) {
                fStream.write(pBuffer.array());
            } catch (IOException iException) {
                iException.printStackTrace();
                pFile = null;
            }
        }

        if (pFile != null) {
            _LOGGER.debug("UserDaoAspect Setting picture url - " + _RESOURCE_PREFIX + pFile.getName());
            picture.setUrl(_RESOURCE_PREFIX + pFile.getName());
        }
    }

}

From source file:org.bimserver.geometry.StreamingGeometryGenerator.java

int hash(ByteBuffer indices, ByteBuffer vertices, ByteBuffer normals, ByteBuffer colors) {
    int hashCode = 0;
    hashCode += indices.hashCode();
    hashCode += vertices.hashCode();/*from w  w w .  j  av  a2 s  .c o m*/
    hashCode += normals.hashCode();
    hashCode += colors.hashCode();

    return hashCode;
}