Example usage for java.io Serializable toString

List of usage examples for java.io Serializable toString

Introduction

In this page you can find the example usage for java.io Serializable toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.obiba.onyx.jade.instrument.jtech.Tracker5InstrumentRunner.java

private Map<String, Data> extractExam() {

    ParadoxDb gripTestDb = getGripTestDB();

    if (gripTestDb.getHeader().getNumRecords() != 1) {
        throw new RuntimeException("there should be only one test");
    }//from   www.ja  va2  s .c  o  m

    ParadoxRecord record = gripTestDb.iterator().next();
    LinkedHashMap<String, Data> map = new LinkedHashMap<String, Data>();
    String[] fields = { "Rung", "MaxReps", "Sequence", "RestTime", "Rate", "Threshold", "NormType",
            "Comparison" };
    DataType[] types = { DataType.INTEGER, DataType.INTEGER, DataType.TEXT, DataType.INTEGER, DataType.INTEGER,
            DataType.DECIMAL, DataType.INTEGER, DataType.INTEGER };
    Set<String> expectedValues = this.instrumentExecutionService.getExpectedOutputParameterVendorNames();
    for (int i = 0; i < fields.length; i++) {
        String field = fields[i];
        DataType type = types[i];
        if (expectedValues.contains(field)) {
            Serializable value = record.getValue(field);
            if (field.equals("Threshold")) {
                value = Tracker5Util.asKg(((Number) value).intValue());
            }
            Data data = value != null ? DataBuilder.build(type, value.toString()) : null;
            log.info("{} : {}", field, data);
            map.put(field, data);
        }
    }
    return map;
}

From source file:org.craftercms.cstudio.share.servlet.CookieManagerImpl.java

public void putCookieValue(HttpServletRequest request, HttpServletResponse response, String path, String key,
        int age, Serializable value) throws CStudioException {

    String cookieValue = null;/*  ww w. ja  va  2  s  . c o  m*/

    if (_encryptCookies) {
        cookieValue = getEncryptedObjectAsString(value);
    } else {
        cookieValue = value.toString();
    }

    Cookie cookie = new Cookie(key, cookieValue);
    if (!StringUtils.isEmpty(path)) {
        cookie.setPath(path);
    } else {
        cookie.setPath("/");
    }
    cookie.setMaxAge(age);

    //if(request.getServerName().indexOf(".") != -1) {
    //   String validForDomain = request.getServerName().substring(request.getServerName().indexOf("."));
    //   cookie.setDomain(validForDomain);
    //}

    if (_cookieDomain != null) {
        cookie.setDomain(_cookieDomain);
    }

    response.addCookie(cookie);
}

From source file:eu.openanalytics.rsb.component.EmailDepositHandler.java

public void handleResult(final MultiFilesResult result) throws MessagingException, IOException {
    final Serializable responseBody = result.getMeta().get(EMAIL_BODY_META_NAME);
    final String responseText = responseBody instanceof File ? FileUtils.readFileToString((File) responseBody)
            : responseBody.toString();

    final MimeMessage mimeMessage = mailSender.createMimeMessage();
    final MimeMessageHelper mmh = new MimeMessageHelper(mimeMessage, true);

    mmh.setFrom((String) result.getMeta().get(EMAIL_ADDRESSEE_META_NAME));
    mmh.setTo((String) result.getMeta().get(EMAIL_REPLY_TO_META_NAME));
    mmh.setCc((String[]) result.getMeta().get(EMAIL_REPLY_CC_META_NAME));
    mmh.setSubject("RE: " + result.getMeta().get(EMAIL_SUBJECT_META_NAME));

    if (result.isSuccess()) {
        mmh.setText(responseText);/*from w  ww  . j  a va 2s  .  c  o m*/
        for (final File resultFile : result.getPayload()) {
            mmh.addAttachment(resultFile.getName(), resultFile);
        }
    } else {
        mmh.setText(FileUtils.readFileToString(result.getPayload()[0]));
    }

    final Message<MimeMailMessage> message = new GenericMessage<MimeMailMessage>(new MimeMailMessage(mmh));
    outboundEmailChannel.send(message);
}

From source file:org.openmrs.module.openhmis.commons.api.entity.db.hibernate.HibernateRepository.java

@Override
@SuppressWarnings("unchecked")
public <E extends OpenmrsObject> E selectSingle(Class<E> cls, Serializable id) {
    Session session = sessionFactory.getCurrentSession();

    try {/*  www . ja  v a2  s .c om*/
        return (E) session.get(cls, id);
    } catch (Exception ex) {
        throw new APIException("An exception occurred while attempting to select a single "
                + cls.getSimpleName() + " entity with ID" + " " + id.toString() + ".", ex);
    }
}

From source file:com.reactivetechnologies.platform.datagrid.HazelcastKeyValueAdapterBean.java

public void set(Serializable id, Object item, Serializable keyspace) {
    if (!hz.isStarted())
        throw new IllegalStateException("Hazelcast service not started!");
    Assert.notNull(id, "Cannot add item with null id.");
    Assert.notNull(keyspace, "Cannot add item for null collection.");
    hz.set(id, item, keyspace.toString());
}

From source file:com.reactivetechnologies.platform.datagrid.HazelcastKeyValueAdapterBean.java

@Override
public Object get(Serializable id, Serializable keyspace) {
    if (!hz.isStarted())
        throw new IllegalStateException("Hazelcast service not started!");
    Assert.notNull(id, "Cannot get item with null id.");
    Assert.notNull(keyspace, "Cannot get item for null collection.");
    return hz.get(id, keyspace.toString());
}

From source file:com.reactivetechnologies.platform.datagrid.HazelcastKeyValueAdapterBean.java

public void deleteAsync(Serializable id, Serializable keyspace) {
    if (!hz.isStarted())
        throw new IllegalStateException("Hazelcast service not started!");
    Assert.notNull(id, "Cannot delete item with null id.");
    Assert.notNull(keyspace, "Cannot delete item for null collection.");
    hz.remove(id, keyspace.toString());
}

From source file:com.reactivetechnologies.platform.datagrid.HazelcastKeyValueAdapterBean.java

@Override
public boolean contains(Serializable id, Serializable keyspace) {
    if (!hz.isStarted())
        throw new IllegalStateException("Hazelcast service not started!");
    Assert.notNull(id, "Cannot check item with null id.");
    Assert.notNull(keyspace, "Cannot check item for null collection.");
    return hz.getMap(keyspace.toString()).containsKey(id);
}

From source file:com.reactivetechnologies.platform.datagrid.HazelcastKeyValueAdapterBean.java

@Override
public Object put(Serializable id, Object item, Serializable keyspace) {
    if (!hz.isStarted())
        throw new IllegalStateException("Hazelcast service not started!");
    Assert.notNull(id, "Cannot add item with null id.");
    Assert.notNull(keyspace, "Cannot add item for null collection.");
    return hz.put(id, item, keyspace.toString());
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.converter.CswUnmarshallHelper.java

/**
 * Takes a CSW attribute as a name and value and returns an {@link Attribute} whose value is
 * {@code cswAttributeValue} converted to the type of the attribute
 * {@code metacardAttributeName} in a {@link Metacard}.
 *
 * @param cswAttributeName  the name of the CSW attribute
 * @param cswAttributeValue  the value of the CSW attribute
 * @param metacardAttributeName  the name of the {@code Metacard} attribute whose type
 *                               {@code cswAttributeValue} will be converted to
 * @return an {@code Attribute} with the name {@code metacardAttributeName} and the value
 *         {@code cswAttributeValue} converted to the type of the attribute
 *         {@code metacardAttributeName} in a {@code Metacard}.
 *///from   w  ww.j a v  a  2  s . c o m
public static Attribute getMetacardAttributeFromCswAttribute(String cswAttributeName,
        Serializable cswAttributeValue, String metacardAttributeName) {
    AttributeType.AttributeFormat cswAttributeFormat = CSW_METACARD_TYPE
            .getAttributeDescriptor(cswAttributeName).getType().getAttributeFormat();
    AttributeDescriptor metacardAttributeDescriptor = CSW_METACARD_TYPE
            .getAttributeDescriptor(metacardAttributeName);
    AttributeType.AttributeFormat metacardAttrFormat = metacardAttributeDescriptor.getType()
            .getAttributeFormat();
    LOGGER.debug(
            "Setting overlapping Metacard attribute [{}] to value in "
                    + "CSW attribute [{}] that has value [{}] and format {}",
            metacardAttributeName, cswAttributeName, cswAttributeValue, metacardAttrFormat);

    if (cswAttributeFormat.equals(metacardAttrFormat)) {
        return new AttributeImpl(metacardAttributeName, cswAttributeValue);
    } else {
        Serializable value = convertStringValueToMetacardValue(metacardAttrFormat,
                cswAttributeValue.toString());
        return new AttributeImpl(metacardAttributeName, value);
    }
}