Example usage for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE

List of usage examples for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE

Introduction

In this page you can find the example usage for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE.

Prototype

ToStringStyle MULTI_LINE_STYLE

To view the source code for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE.

Click Source Link

Document

The multi line toString style.

Usage

From source file:com.comphenix.protocol.error.DetailedErrorReporter.java

/**
 * Retrieve a string representation of the given object.
 * @param value - object to convert./*from   w ww. j  a  va2  s .  c om*/
 * @return String representation.
 */
public static String getStringDescription(Object value) {
    // We can't only rely on toString.
    if (value == null) {
        return "[NULL]";
    }
    if (isSimpleType(value) || value instanceof Class<?>) {
        return value.toString();
    } else {
        try {
            if (!apacheCommonsMissing)
                return ToStringBuilder.reflectionToString(value, ToStringStyle.MULTI_LINE_STYLE, false, null);
        } catch (LinkageError ex) {
            // Apache is probably missing
            apacheCommonsMissing = true;
        } catch (ThreadDeath | OutOfMemoryError e) {
            throw e;
        } catch (Throwable ex) {
            // Don't use the error logger to log errors in error logging (that could lead to infinite loops)
            ProtocolLogger.log(Level.WARNING, "Cannot convert to a String with Apache: " + ex.getMessage());
        }

        // Use our custom object printer instead
        try {
            return PrettyPrinter.printObject(value, value.getClass(), Object.class);
        } catch (IllegalAccessException e) {
            return "[Error: " + e.getMessage() + "]";
        }
    }
}

From source file:com.xtructure.xneat.genetics.UTestGeneMap.java

public void toStringReturnsExpectedString() {
    NodeGene node0 = new NodeGeneImpl(0, NodeType.INPUT, NODE_CONFIGURATION);
    NodeGene node1 = new NodeGeneImpl(1, NodeType.OUTPUT, NODE_CONFIGURATION);
    LinkGene link0 = new LinkGeneImpl(0, node0.getId(), node1.getId(), LINK_CONFIGURATION);
    GeneMap geneMap = new GeneMap(//
            new SetBuilder<NodeGene>().add(node0, node1).newImmutableInstance(), //
            new SetBuilder<LinkGene>().add(link0).newImmutableInstance());
    assertThat("", //
            geneMap.toString(), //
            isEqualTo(new ToStringBuilder(geneMap, ToStringStyle.MULTI_LINE_STYLE)//
                    .append(node0).append(node1).append(link0).toString()));
}

From source file:com.jeefuse.system.security.model.GsysUser.java

/** @generated */
@Override/*from ww w.  j  a v a  2s. c o m*/
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId())
            .append("username", username).append("createTime", createTime).append("email", email)
            .append("level", level).append("updateTime", updateTime).append("loginName", loginName)
            .append("password", password).append("remark", remark).append("sex", sex).append("mobile", mobile)
            .append("telephone", telephone).append("enabled", enabled).append("activated", activated)
            .append("lastLoginTime", lastLoginTime).toString();
}

From source file:com.gemini.provision.network.openstack.NetworkProviderOpenStackImpl.java

@Override
public ProvisioningProviderResponseType deleteNetwork(GeminiTenant tenant, GeminiEnvironment env,
        GeminiNetwork delNetwork) {//from  ww  w .  j a v  a  2  s .  c om
    //authenticate the session with the OpenStack installation
    //authenticate the session with the OpenStack installation
    OSClient os = OSFactory.builder().endpoint(env.getEndPoint())
            .credentials(env.getAdminUserName(), env.getAdminPassword()).tenantName(tenant.getName())
            .authenticate();
    if (os == null) {
        Logger.error("Failed to authenticate Tenant: {}",
                ToStringBuilder.reflectionToString(tenant, ToStringStyle.MULTI_LINE_STYLE));
        return ProvisioningProviderResponseType.CLOUD_AUTH_FAILURE;
    }

    //check to see if this network exists
    Network n;
    try {
        n = os.networking().network().get(delNetwork.getCloudID());
    } catch (NullPointerException | ClientResponseException ex) {
        Logger.error("Failed to delete network - does not exist. Tenant: {} Environment: {} Network: {}",
                tenant.getName(), env.getName(), delNetwork.getName());
        return ProvisioningProviderResponseType.OBJECT_NOT_FOUND;
    }

    try {
        os.networking().network().delete(delNetwork.getCloudID());
    } catch (ClientResponseException ex) {
        Logger.error(
                "Cloud exception, could not delete network. status code {} Tenant: {} Environment: {} Network: {}",
                ex.getStatusCode(), tenant.getName(), env.getName(), delNetwork.getName());
        return ProvisioningProviderResponseType.CLOUD_EXCEPTION;
    }

    Logger.debug("Successfully deleted network - Tenant: {} Environment: {} Network: {}", tenant.getName(),
            env.getName(), delNetwork.getName());
    return ProvisioningProviderResponseType.SUCCESS;
}

From source file:de.iteratec.iteraplan.model.dto.LandscapeDiagramConfigDTO.java

@Override
public String toString() {
    ToStringBuilder.setDefaultStyle(ToStringStyle.MULTI_LINE_STYLE);
    return ToStringBuilder.reflectionToString(this);
}

From source file:com.gemini.provision.loadbalancer.openstack.LoadBalancerProviderOpenStackImpl.java

public ProvisioningProviderResponseType getResponseType(Object object, GeminiTenant tenant,
        GeminiEnvironment env, String operation) {
    if (object == null) {
        Logger.error("Failed to {}, failure in Cloud provider. Tenant: {} Environment: {} Network: {}",
                operation, tenant.getName(), env.getName(),
                ToStringBuilder.reflectionToString(object, ToStringStyle.MULTI_LINE_STYLE));
        return ProvisioningProviderResponseType.CLOUD_FAILURE;
    }/* w  w w .  j  a v  a2  s .  c om*/

    Logger.debug("Successfully {} {} - Tenant: {} Environment: {} Network: {}", operation,
            object.getClass().getName(), tenant.getName(), env.getName(),
            ToStringBuilder.reflectionToString(object, ToStringStyle.MULTI_LINE_STYLE));
    return ProvisioningProviderResponseType.SUCCESS;
}

From source file:com.gemini.provision.network.openstack.NetworkProviderOpenStackImpl.java

@Override
public ProvisioningProviderResponseType updateNetwork(GeminiTenant tenant, GeminiEnvironment env,
        GeminiNetwork n) {//w  w w .  j  a  va2 s  .  c o  m
    //authenticate the session with the OpenStack installation
    //authenticate the session with the OpenStack installation
    OSClient os = OSFactory.builder().endpoint(env.getEndPoint())
            .credentials(env.getAdminUserName(), env.getAdminPassword()).tenantName(tenant.getName())
            .authenticate();
    if (os == null) {
        Logger.error("Failed to authenticate Tenant: {}",
                ToStringBuilder.reflectionToString(tenant, ToStringStyle.MULTI_LINE_STYLE));
        return ProvisioningProviderResponseType.CLOUD_AUTH_FAILURE;
    }

    // Get a network by ID
    Network network;
    try {
        network = os.networking().network().get(n.getCloudID());
    } catch (NullPointerException ex) {
        Logger.error("Failed to update network - does not exist. Tenant: {} Environment: {} Network: {}",
                tenant.getName(), env.getName(), n.getName());
        return ProvisioningProviderResponseType.OBJECT_NOT_FOUND;
    }

    //update the network
    Network updatedNetwork;
    try {
        updatedNetwork = os.networking().network().update(n.getCloudID(),
                Builders.networkUpdate().name(n.getName()).build());
    } catch (ClientResponseException ex) {
        Logger.error(
                "Cloud exception, could not update network. status code {} Tenant: {} Environment: {} Network: {}",
                ex.getStatusCode(), tenant.getName(), env.getName(), n.getName());
        return ProvisioningProviderResponseType.CLOUD_EXCEPTION;
    }

    //TODO: Need to get detailed error codes for the call above. Research the StatusCode class
    if (updatedNetwork == null) {
        Logger.error("Failed to update network, Cloud provider failure Tenant: {} Environment: {} Network: {}",
                tenant.getName(), env.getName(), n.getName());
        return ProvisioningProviderResponseType.CLOUD_FAILURE;
    }

    Logger.debug("Successfully updated the network. Tenant: {} Environment: {} Network: {}", tenant.getName(),
            env.getName(), n.getName());
    return ProvisioningProviderResponseType.SUCCESS;
}

From source file:com.gemini.provision.loadbalancer.openstack.LoadBalancerProviderOpenStackImpl.java

public ProvisioningProviderResponseType getResponseType(ActionResponse actionResponse, Object object,
        GeminiTenant tenant, GeminiEnvironment env, String operation) {
    if (!actionResponse.isSuccess()) {
        Logger.error("Failed to {} {}, failure in Cloud provider. Tenant: {} Environment: {} Network: {}",
                operation, object.getClass().getName(), tenant.getName(), env.getName(),
                ToStringBuilder.reflectionToString(object, ToStringStyle.MULTI_LINE_STYLE));
        return ProvisioningProviderResponseType.CLOUD_FAILURE;
    }/*from w ww  . j a  v  a2  s.  c  o  m*/

    Logger.debug("Successfully {} {} - Tenant: {} Environment: {} Network: {}", operation,
            object.getClass().getName(), tenant.getName(), env.getName(),
            ToStringBuilder.reflectionToString(object, ToStringStyle.MULTI_LINE_STYLE));
    return ProvisioningProviderResponseType.SUCCESS;
}

From source file:com.likethecolor.alchemy.api.entity.AlchemySubjectTest.java

@Test
public void testToString_Formatted() {
    final ToStringStyle style = ToStringStyle.MULTI_LINE_STYLE;
    final String text = "U.S. marshals Deputy John Beeman";
    final String census = "http://census.org/resource/Israel";
    final String ciaFactbook = "http://www4.wiwiss.fu-berlin.de/factbook/resource/Israel";
    final String crunchbase = "http://crunchbase.com/resource/Israel";
    final String dbPedia = "http://dbpedia.org/resource/Israel";
    final String freebase = "http://rdf.freebase.com/ns/guid.9202a8c04000641f800000000001e2be";
    final Double latitude = 31.0D;
    final Double longitude = 35.0D;
    final String geo = latitude + " " + longitude;
    final String geonames = "http://geonames.com/Israel";
    final String musicBrainz = "http://musicbrainz.com/Israel";
    final String name = "Israel";
    final String opencyc = "http://sw.opencyc.org/concept/Mx4rvViP55wpEbGdrcN5Y29ycA";
    final String semanticCrunchbase = "http://semanticcrunchbase.com/concept/Mx4rvViP55wpEbGdrcN5Y29ycA";
    final String type = "Country";
    final String entityText = "Israel";
    final String umbel = "http://umbel.org/umbel/ne/wikipedia/Israel";
    final String website = "http://www.knesset.gov.il/";
    final String yago = "http://mpii.de/yago/resource/Israel";
    final List<String> subtypes = new ArrayList<String>();
    subtypes.add("Location");
    subtypes.add("Country");
    subtypes.add("GovernmentalJurisdiction");
    final boolean isMixed = false;
    final double score = 0.121;
    final SentimentAlchemyEntity.TYPE sentimentType = SentimentAlchemyEntity.TYPE.POSITIVE;

    final AlchemyEntity alchemyEntity = new AlchemyEntity();
    alchemyEntity.setCensus(census);//from  w  w  w  . j  a  va2  s  . co m
    alchemyEntity.setCIAFactbook(ciaFactbook);
    alchemyEntity.setCrunchbase(crunchbase);
    alchemyEntity.setDBPedia(dbPedia);
    alchemyEntity.setFreebase(freebase);
    alchemyEntity.setGeo(geo);
    alchemyEntity.setGeonames(geonames);
    alchemyEntity.setMusicBrainz(musicBrainz);
    alchemyEntity.setName(name);
    alchemyEntity.setOpencyc(opencyc);
    alchemyEntity.setSemanticCrunchbase(semanticCrunchbase);
    alchemyEntity.setText(entityText);
    alchemyEntity.setType(type);
    alchemyEntity.setUmbel(umbel);
    alchemyEntity.setWebsite(website);
    alchemyEntity.setYago(yago);
    for (String subtype : subtypes) {
        alchemyEntity.addSubtype(subtype);
    }

    final SentimentAlchemyEntity sentimentAlchemyEntity = new SentimentAlchemyEntity(isMixed, score,
            sentimentType.toString());

    final AlchemySubject entity = new AlchemySubject();
    entity.setEntity(alchemyEntity);
    entity.setSentiment(sentimentAlchemyEntity);
    entity.setText(text);

    final String expectedString = new ToStringBuilder(entity, style)
            .append("entity", alchemyEntity.toString(style))
            .append("sentiment", sentimentAlchemyEntity.toString(style)).append("text", text).toString();

    final String actualString = entity.toString(style);

    assertEquals(expectedString, actualString);
}

From source file:com.opengamma.engine.view.ViewCalculationConfiguration.java

@Override
public String toString() {
    if (s_logger.isDebugEnabled()) {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE, false);
    } else {/*from  w  w  w . j  av  a2  s .  c om*/
        return "ViewCalculationConfiguration[" + getName() + "]";
    }
}