Example usage for java.lang Integer byteValue

List of usage examples for java.lang Integer byteValue

Introduction

In this page you can find the example usage for java.lang Integer byteValue.

Prototype

public byte byteValue() 

Source Link

Document

Returns the value of this Integer as a byte after a narrowing primitive conversion.

Usage

From source file:de.unibayreuth.bayeos.goat.table.MassenTableModel.java

public boolean updateRow(ObjektNode objektNode, int row, Vector values) {
    boolean bol = false;
    try {// w  w w.  j a v  a 2  s.  c  o  m

        // get update columns
        java.util.Date new_von = (java.util.Date) values.elementAt(0);
        Double wert = (Double) values.elementAt(1);
        Integer status = (Integer) values.elementAt(2);

        java.util.Date old_von = (java.util.Date) getValueAt(row, 0);

        Vector params = new Vector();
        params.add(objektNode.getId());
        params.add(old_von);
        params.add(status);
        params.add(wert);
        params.add(new_von);

        bol = ((Boolean) xmlClient.execute("MassenTableHandler.updateRow", params)).booleanValue();

        // Update display values 
        setValueAt(new_von, row, 0);
        setValueAt(wert, row, 1);
        setValueAt(new Byte(status.byteValue()), row, 2);
        fireTableDataChanged();

    } catch (XmlRpcException x) {
        MsgBox.error(x.getMessage());
        return false;
    }

    return bol;
}

From source file:de.unibayreuth.bayeos.goat.table.MassenTableModel.java

public boolean updateRows(final ObjektNode objektNode, final int rows[], final Vector values) {
    boolean bol = false;
    try {/*from www . jav a  2  s.c  o  m*/

        // get update columns
        Integer status = (Integer) values.elementAt(0);

        // get keys
        Vector vonDates = new Vector();
        for (int r = 0; r < rows.length; r++) {
            vonDates.add(getValueAt(rows[r], 0));
        }
        Vector params = new Vector();
        params.add(objektNode.getId());
        params.add(vonDates);
        params.add(status);

        bol = ((Boolean) xmlClient.execute("MassenTableHandler.updateRows", params)).booleanValue();

        // Update display values 
        for (int r = 0; r < rows.length; r++) {
            setValueAt(new Byte(status.byteValue()), rows[r], 2);
        }

        fireTableDataChanged();

    } catch (XmlRpcException x) {
        MsgBox.error(x.getMessage());
        return false;
    }

    return bol;
}

From source file:edu.ku.brc.specify.datamodel.Attachment.java

/**
 * @param scopeType the scopeType to set
 *///  w  ww . j av a 2 s. c o m
public void setScopeType(Integer scopeType) {
    this.scopeType = scopeType != null ? scopeType.byteValue() : null;
}

From source file:com.ikon.module.jcr.JcrAuthModule.java

@Override
public HashMap<String, Integer> getGrantedUsers(String token, String nodePath)
        throws PathNotFoundException, AccessDeniedException, RepositoryException, DatabaseException {
    log.debug("getGrantedUsers({})", nodePath);
    HashMap<String, Integer> users = new HashMap<String, Integer>();
    Session session = null;//from  ww  w  . jav  a  2s  .c o  m

    try {
        if (token == null) {
            session = JCRUtils.getSession();
        } else {
            session = JcrSessionManager.getInstance().get(token);
        }

        Node node = session.getRootNode().getNode(nodePath.substring(1));
        Value[] usersRead = node.getProperty(Permission.USERS_READ).getValues();

        for (int i = 0; i < usersRead.length; i++) {
            users.put(usersRead[i].getString(), new Integer(Permission.READ));
        }

        Value[] usersWrite = node.getProperty(Permission.USERS_WRITE).getValues();

        for (int i = 0; i < usersWrite.length; i++) {
            Integer previous = (Integer) users.get(usersWrite[i].getString());

            if (previous != null) {
                users.put(usersWrite[i].getString(), new Integer(previous.byteValue() | Permission.WRITE));
            } else {
                users.put(usersWrite[i].getString(), new Integer(Permission.WRITE));
            }
        }

        Value[] usersDelete = node.getProperty(Permission.USERS_DELETE).getValues();

        for (int i = 0; i < usersDelete.length; i++) {
            Integer previous = (Integer) users.get(usersDelete[i].getString());

            if (previous != null) {
                users.put(usersDelete[i].getString(), new Integer(previous.byteValue() | Permission.DELETE));
            } else {
                users.put(usersDelete[i].getString(), new Integer(Permission.DELETE));
            }
        }

        Value[] usersSecurity = node.getProperty(Permission.USERS_SECURITY).getValues();

        for (int i = 0; i < usersSecurity.length; i++) {
            Integer previous = (Integer) users.get(usersSecurity[i].getString());

            if (previous != null) {
                users.put(usersSecurity[i].getString(),
                        new Integer(previous.byteValue() | Permission.SECURITY));
            } else {
                users.put(usersSecurity[i].getString(), new Integer(Permission.SECURITY));
            }
        }
    } catch (javax.jcr.PathNotFoundException e) {
        log.warn(e.getMessage(), e);
        throw new PathNotFoundException(e.getMessage(), e);
    } catch (javax.jcr.RepositoryException e) {
        log.error(e.getMessage(), e);
        throw new RepositoryException(e.getMessage(), e);
    } finally {
        if (token == null)
            JCRUtils.logout(session);
    }

    log.debug("getGrantedUsers: {}", users);
    return users;
}

From source file:com.openkm.module.jcr.JcrAuthModule.java

@Override
public HashMap<String, Integer> getGrantedUsers(String token, String nodePath)
        throws PathNotFoundException, AccessDeniedException, RepositoryException, DatabaseException {
    log.debug("getGrantedUsers({})", nodePath);
    HashMap<String, Integer> users = new HashMap<String, Integer>();
    Session session = null;//from  www.j  a v  a2 s . com

    try {
        if (token == null) {
            session = JCRUtils.getSession();
        } else {
            session = JcrSessionManager.getInstance().get(token);
        }

        Node node = session.getRootNode().getNode(nodePath.substring(1));
        Value[] usersRead = node.getProperty(Permission.USERS_READ).getValues();

        for (int i = 0; i < usersRead.length; i++) {
            users.put(usersRead[i].getString(), new Integer(Permission.READ));
        }

        Value[] usersWrite = node.getProperty(Permission.USERS_WRITE).getValues();

        for (int i = 0; i < usersWrite.length; i++) {
            Integer previous = (Integer) users.get(usersWrite[i].getString());

            if (previous != null) {
                users.put(usersWrite[i].getString(), new Integer(previous.byteValue() | Permission.WRITE));
            } else {
                users.put(usersWrite[i].getString(), new Integer(Permission.WRITE));
            }
        }

        Value[] usersDelete = node.getProperty(Permission.USERS_DELETE).getValues();

        for (int i = 0; i < usersDelete.length; i++) {
            Integer previous = (Integer) users.get(usersDelete[i].getString());

            if (previous != null) {
                users.put(usersDelete[i].getString(), new Integer(previous.byteValue() | Permission.DELETE));
            } else {
                users.put(usersDelete[i].getString(), new Integer(Permission.DELETE));
            }
        }

        Value[] usersSecurity = node.getProperty(Permission.USERS_SECURITY).getValues();

        for (int i = 0; i < usersSecurity.length; i++) {
            Integer previous = (Integer) users.get(usersSecurity[i].getString());

            if (previous != null) {
                users.put(usersSecurity[i].getString(),
                        new Integer(previous.byteValue() | Permission.SECURITY));
            } else {
                users.put(usersSecurity[i].getString(), new Integer(Permission.SECURITY));
            }
        }
    } catch (javax.jcr.PathNotFoundException e) {
        log.warn(e.getMessage(), e);
        throw new PathNotFoundException(e.getMessage(), e);
    } catch (javax.jcr.RepositoryException e) {
        log.error(e.getMessage(), e);
        throw new RepositoryException(e.getMessage(), e);
    } finally {
        if (token == null) {
            JCRUtils.logout(session);
        }
    }

    log.debug("getGrantedUsers: {}", users);
    return users;
}

From source file:com.alliander.osgp.webdevicesimulator.service.RegisterDevice.java

public DeviceMessageStatus sendEventNotificationCommand(final Long id, final Integer event,
        final String description, final Integer index) {
    // Find device
    Device device = this.deviceManagementService.findDevice(id);
    if (device == null) {

        // Set the DeviceMessageStatus NOT_FOUND as the device is NOT_FOUND
        return DeviceMessageStatus.NOT_FOUND;
    }/*from w  w  w  .ja  v  a 2s .  c  om*/
    this.errorMessage = "";

    try {
        // Set index when provided in request.
        Integer idx;
        if (index == null) {
            idx = 0;
        } else {
            idx = index;
        }

        final int sequenceNumber = device.doGetNextSequence();

        // Create registration message (for now with 1 event)
        final OslpEnvelope request = this.createEnvelopeBuilder(device.getDeviceUid(), sequenceNumber)
                .withPayloadMessage(
                        Message.newBuilder()
                                .setEventNotificationRequest(Oslp.EventNotificationRequest.newBuilder()
                                        .addNotifications(EventNotification.newBuilder()
                                                .setEvent(Oslp.Event.valueOf(event))
                                                .setDescription(description == null ? "" : description)
                                                .setIndex(ByteString.copyFrom(new byte[] { idx.byteValue() }))))
                                .build())
                .build();

        // Write request log
        OslpLogItem logItem = new OslpLogItem(request.getDeviceId(), device.getDeviceIdentification(), false,
                request.getPayloadMessage());
        this.oslpLogItemRepository.save(logItem);

        OslpEnvelope response = null;
        if (device.getProtocol().equals(ProtocolType.OSLP.toString())) {
            // Send registration message
            response = this.oslpChannelHandler.send(
                    new InetSocketAddress(this.oslpAddressServer, this.oslpPortClient), request,
                    device.getDeviceIdentification());

        } else if (device.getProtocol().equals(ProtocolType.OSLP_ELSTER.toString())) {
            // Send registration message
            response = this.oslpChannelHandler.send(
                    new InetSocketAddress(this.oslpAddressServer, this.oslpElsterPortClient), request,
                    device.getDeviceIdentification());
        }

        LOGGER.debug("Controller Received Send Event Notification Command: "
                + response.getPayloadMessage().toString());

        // Write request log
        logItem = new OslpLogItem(response.getDeviceId(), device.getDeviceIdentification(), false,
                response.getPayloadMessage());
        this.oslpLogItemRepository.save(logItem);

        // Get the sequence number from the response envelope and check it
        this.checkSequenceNumber(response.getSequenceNumber(), sequenceNumber);

        // Success
        device.setSequenceNumber(sequenceNumber);
        device = this.deviceManagementService.updateDevice(device);

        // Set the DeviceMessageStatus OK as the SendEvent is Success.
        return DeviceMessageStatus.OK;
    } catch (final Exception e) {
        LOGGER.error("send event notification exception", e);
        this.errorMessage = e.getMessage();

        // Set the DeviceMessageStatus FAILURE as the SendEvent is NOT
        // Success.
        return DeviceMessageStatus.FAILURE;

    }
}

From source file:com.splicemachine.derby.impl.load.HdfsImportIT.java

@Test
public void testImportNullFields() throws Exception {
    PreparedStatement ps = methodWatcher.prepareStatement(format("call SYSCS_UTIL.IMPORT_DATA(" + "'%s'," + // schema name
            "'%s'," + // table name
            "null," + // insert column list
            "'%s'," + // file path
            "','," + // column delimiter
            "'%s'," + // character delimiter
            "null," + // timestamp format
            "null," + // date format
            "null," + // time format
            "%d," + // max bad records
            "'%s'," + // bad record dir
            "null," + // has one line records
            "null)", // char set
            spliceSchemaWatcher.schemaName, TABLE_10, getResourceDirectory() + "null_field.csv", "\"", 0,
            BADDIR.getCanonicalPath()));
    ps.execute();/*from w  ww.ja v a 2 s.  co m*/

    ResultSet rs = methodWatcher
            .executeQuery(format("select * from %s.%s", spliceSchemaWatcher.schemaName, TABLE_10));
    int count = 0;
    while (rs.next()) {
        Integer i = rs.getInt(1);
        Float j = rs.getFloat(2);
        String k = rs.getString(3);
        Timestamp l = rs.getTimestamp(4);
        Assert.assertEquals(i.byteValue(), 0);
        Assert.assertEquals(j.byteValue(), 0);
        Assert.assertNull("String failure " + k, k);
        Assert.assertNull("Timestamp failure " + l, l);
        count++;
    }
    Assert.assertTrue("import failed!" + count, count == 1);
}

From source file:org.apache.ambari.server.serveraction.kerberos.KerberosOperationHandler.java

/**
 * Create a keytab using the specified principal and password.
 *
 * @param principal a String containing the principal to test
 * @param password  a String containing the password to use when creating the principal
 * @param keyNumber a Integer indicating the key number for the keytab entries
 * @return the created Keytab//from w ww  .  j a v  a 2  s .c  o  m
 * @throws KerberosOperationException
 */
protected Keytab createKeytab(String principal, String password, Integer keyNumber)
        throws KerberosOperationException {

    if ((principal == null) || principal.isEmpty()) {
        throw new KerberosOperationException("Failed to create keytab file, missing principal");
    }

    if (password == null) {
        throw new KerberosOperationException(
                String.format("Failed to create keytab file for %s, missing password", principal));
    }

    Set<EncryptionType> ciphers = new HashSet<EncryptionType>(keyEncryptionTypes);
    List<KeytabEntry> keytabEntries = new ArrayList<KeytabEntry>();
    Keytab keytab = new Keytab();

    if (!ciphers.isEmpty()) {
        // Create a set of keys and relevant keytab entries
        Map<EncryptionType, EncryptionKey> keys = KerberosKeyFactory.getKerberosKeys(principal, password,
                ciphers);

        if (keys != null) {
            byte keyVersion = (keyNumber == null) ? 0 : keyNumber.byteValue();
            KerberosTime timestamp = new KerberosTime();

            for (EncryptionKey encryptionKey : keys.values()) {
                keytabEntries.add(new KeytabEntry(principal, 1, timestamp, keyVersion, encryptionKey));
            }

            keytab.setEntries(keytabEntries);
        }
    }

    return keytab;
}

From source file:com.zoffcc.applications.zanavi.Navit.java

public static void Java_Crash_001() {
    Integer i = null;
    i.byteValue();
}