Java Code Examples for org.apache.commons.lang.builder.ToStringBuilder

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project ATHENA, under directory /components/payments/src/main/java/org/fracturedatlas/athena/payments/model/.

Source file: Customer.java

  22 
vote

public String toEscapedString(){
  ToStringBuilder builder=new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE);
  builder.append(firstName).append(lastName).append(company).append(phone).append(fax).append(email).append(id);
  for (  CreditCard cc : creditCards) {
    builder.append(cc.toEscapedString());
  }
  return builder.toString();
}
 

Example 2

From project cas, under directory /cas-server-core/src/main/java/org/jasig/cas/services/.

Source file: AbstractRegisteredService.java

  22 
vote

public String toString(){
  final ToStringBuilder toStringBuilder=new ToStringBuilder(null,ToStringStyle.SHORT_PREFIX_STYLE);
  toStringBuilder.append("id",this.id);
  toStringBuilder.append("name",this.name);
  toStringBuilder.append("description",this.description);
  toStringBuilder.append("serviceId",this.serviceId);
  toStringBuilder.append("usernameAttribute",this.usernameAttribute);
  toStringBuilder.append("attributes",this.allowedAttributes.toArray());
  return toStringBuilder.toString();
}
 

Example 3

From project gora, under directory /gora-core/src/main/java/org/apache/gora/query/impl/.

Source file: QueryBase.java

  22 
vote

@Override public String toString(){
  ToStringBuilder builder=new ToStringBuilder(this);
  builder.append("dataStore",dataStore);
  builder.append("fields",fields);
  builder.append("startKey",startKey);
  builder.append("endKey",endKey);
  builder.append("filter",filter);
  builder.append("limit",limit);
  return builder.toString();
}
 

Example 4

From project license-maven-plugin, under directory /src/main/java/org/codehaus/mojo/license/model/.

Source file: License.java

  22 
vote

@Override public String toString(){
  ToStringBuilder builder=new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE);
  builder.append("name",name);
  builder.append("description",description);
  builder.append("licenseURL",licenseURL);
  builder.append("headerURL",headerURL);
  return builder.toString();
}
 

Example 5

From project ptest-server, under directory /src/main/java/com/mnxfst/testing/plan/config/.

Source file: TSPlanConfigOption.java

  22 
vote

/** 
 * @see java.lang.Object#toString()
 */
public String toString(){
  ToStringBuilder builder=new ToStringBuilder(this);
  builder.append("name",name);
  for (  String key : options.keySet())   builder.append(key,options.get(key));
  return builder.toString();
}
 

Example 6

From project sched-assist, under directory /sched-assist-spi/src/main/java/org/jasig/schedassist/impl/owner/.

Source file: PersistencePreference.java

  22 
vote

@Override public String toString(){
  ToStringBuilder builder=new ToStringBuilder(this,ToStringStyle.SHORT_PREFIX_STYLE);
  builder.append("ownerId",ownerId);
  builder.append("preferenceKey",preferenceKey);
  builder.append("preferenceValue",preferenceValue);
  return builder.toString();
}
 

Example 7

From project BookmarksPortlet, under directory /src/main/java/edu/wisc/my/portlets/bookmarks/domain/.

Source file: Folder.java

  21 
vote

/** 
 * @see java.lang.Object#toString()
 */
public String toString(){
  final Set<Integer> visited=toStringVisitedFolder.getSet();
  final int identityHash=System.identityHashCode(this);
  try {
    if (!visited.add(identityHash)) {
      visited.clear();
      throw new IllegalStateException("A loop exists in the Folder tree.");
    }
    return new ToStringBuilder(this).appendSuper(super.toString()).append("children",this.children).append("minimized",this.minimized).toString();
  }
  finally {
    visited.remove(identityHash);
  }
}
 

Example 8

From project formic, under directory /src/java/org/apache/commons/lang/.

Source file: ArrayUtils.java

  21 
vote

/** 
 * <p>Outputs an array as a String handling <code>null</code>s.</p> <p>Multi-dimensional arrays are handled correctly, including multi-dimensional primitive arrays.</p> <p>The format is that of Java source code, for example <code>{a,b}</code>.</p>
 * @param array  the array to get a toString for, may be <code>null</code>
 * @param stringIfNull  the String to return if the array is <code>null</code>
 * @return a String representation of the array
 */
public static String toString(Object array,String stringIfNull){
  if (array == null) {
    return stringIfNull;
  }
  return new ToStringBuilder(array,ToStringStyle.SIMPLE_STYLE).append(array).toString();
}
 

Example 9

From project maven-dependency-versions-check-plugin, under directory /src/main/java/com/ning/maven/plugins/dependencyversionscheck/.

Source file: ResolverDefinition.java

  21 
vote

public String toString(){
  if (toString == null) {
    toString=new ToStringBuilder(this).append("id",id).append("strategyName",strategyName).append("includes",includes).toString();
  }
  return toString;
}
 

Example 10

From project vmarket, under directory /src/main/java/org/apache/velocity/runtime/parser/node/.

Source file: SimpleNode.java

  20 
vote

/** 
 * @since 1.5
 */
public String toString(){
  StrBuilder tokens=new StrBuilder();
  for (Token t=getFirstToken(); t != null; ) {
    tokens.append("[").append(t.image).append("]");
    if (t.next != null) {
      if (t.equals(getLastToken())) {
        break;
      }
 else {
        tokens.append(", ");
      }
    }
    t=t.next;
  }
  return new ToStringBuilder(this).append("id",getType()).append("info",getInfo()).append("invalid",isInvalid()).append("children",jjtGetNumChildren()).append("tokens",tokens).toString();
}
 

Example 11

From project beanstalker, under directory /beanstalk-maven-plugin/src/main/java/br/com/ingenieux/mojo/beanstalk/cmd/env/waitfor/.

Source file: WaitForEnvironmentCommand.java

  19 
vote

public EnvironmentDescription executeInternal(WaitForEnvironmentContext context) throws Exception {
  long timeoutMins=context.getTimeoutMins();
  String environmentId=context.getEnvironmentId();
  String applicationName=context.getApplicationName();
  String statusToWaitFor=context.getStatusToWaitFor();
  boolean hasDomainToWaitFor=StringUtils.isNotBlank(context.getDomainToWaitFor());
  String domainToWaitFor=String.format("%s.elasticbeanstalk.com",context.getDomainToWaitFor());
  Date expiresAt=new Date(System.currentTimeMillis() + INTERVAL * timeoutMins);
  boolean done=false;
  info("Will wait until " + expiresAt + " for environment "+ environmentId+ " to get into "+ statusToWaitFor);
  if (hasDomainToWaitFor)   info("... as well as having domain " + domainToWaitFor);
  do {
    if (timedOutP(expiresAt))     throw new MojoExecutionException("Timed out");
    DescribeEnvironmentsRequest req=new DescribeEnvironmentsRequest().withApplicationName(applicationName).withEnvironmentIds(environmentId);
    DescribeEnvironmentsResult result=service.describeEnvironments(req);
    for (    EnvironmentDescription d : result.getEnvironments()) {
      debug("Environment Detail:" + ToStringBuilder.reflectionToString(d));
      done=d.getStatus().equalsIgnoreCase(statusToWaitFor);
      if (done && hasDomainToWaitFor)       done=domainToWaitFor.equals(d.getCNAME());
      if (done)       return d;
    }
    sleepInterval();
  }
 while (true);
}
 

Example 12

From project build-info, under directory /build-info-extractor-gradle/src/examples/multiproject/services/webservice/src/main/java/org/gradle/webservice/.

Source file: TestTest.java

  19 
vote

public void method(){
  FilenameUtils.separatorsToUnix("my/unix/filename");
  ToStringBuilder.reflectionToString(new Person("name"));
  new GrowthList();
  new PersonList().doSomethingWithImpl();
}
 

Example 13

From project ExperienceMod, under directory /ExperienceMod/src/com/comphenix/xp/listeners/.

Source file: ErrorReporting.java

  19 
vote

protected String getStringDescription(Object value){
  if (value == null) {
    return "[NULL]";
  }
  if (isSimpleType(value)) {
    return value.toString();
  }
 else {
    return (ToStringBuilder.reflectionToString(value,ToStringStyle.MULTI_LINE_STYLE,false,null));
  }
}
 

Example 14

From project hadoop-book_1, under directory /src/main/java/com/manning/hip/ch13/.

Source file: TaskSplitReader.java

  19 
vote

public static void main(String... args) throws IOException {
  String taskSplitFile=args[0];
  Configuration conf=new Configuration();
  DataInputStream is=new DataInputStream(new FileInputStream(taskSplitFile));
  JobSplit.TaskSplitIndex taskSplitIndex=new JobSplit.TaskSplitIndex();
  taskSplitIndex.readFields(is);
  is.close();
  Object split=getSplitDetails(conf,new Path(taskSplitIndex.getSplitLocation()),taskSplitIndex.getStartOffset());
  System.out.println("InputSplit instance class = " + split.getClass().getName());
  System.out.println("ToString on split = " + split);
  System.out.println("Reflection fields = " + ToStringBuilder.reflectionToString(split,ToStringStyle.SHORT_PREFIX_STYLE));
}
 

Example 15

From project psl, under directory /psl-core/src/main/java/edu/umd/cs/psl/sampler/.

Source file: HitAndRunSamplerStatistics.java

  19 
vote

HitAndRunSamplerStatistics(AbstractHitAndRunSampler s,RunningProcess proc){
  process=proc;
  proc.setString(descriptionKey,ToStringBuilder.reflectionToString(s,ToStringStyle.MULTI_LINE_STYLE));
  proc.setLong(timeInCornersKey,0);
  proc.setLong(noCallBacksKey,0);
  startTime=System.currentTimeMillis();
}
 

Example 16

From project shopzilla-core, under directory /src/test/java/com/shopzilla/spring/messaging/hornetq/config/example/.

Source file: HornetQConfigurationExample.java

  19 
vote

@PostConstruct public void start(){
  final String destination="exampleQueue";
  jmsTemplate.send(destination,new MessageCreator(){
    public Message createMessage(    final Session session) throws JMSException {
      return session.createTextMessage(String.format("Hello, world! @ %s",System.currentTimeMillis() + ""));
    }
  }
);
  Message msg=jmsTemplate.receive(destination);
  System.out.println(ToStringBuilder.reflectionToString(msg));
}
 

Example 17

From project spring-advanced-marhshallers-and-service-exporters, under directory /obm/src/test/java/org/springframework/http/converter/obm/.

Source file: AvroHttpMessageConverterTest.java

  19 
vote

@Test public void testSimpleIntegration() throws Throwable {
  RestIntegrationTestUtils.startServiceAndConnect(MyService.class,new RestIntegrationTestUtils.ServerExecutionCallback(){
    @Override public void doWithServer(    RestTemplate restTemplate,    Server server) throws Throwable {
      Assert.assertNotNull(restTemplate);
      int id=344;
      Map<String,Object> mapOfVars=new HashMap<String,Object>();
      mapOfVars.put("cid",id);
      Customer customer=restTemplate.getForEntity("http://localhost:8080/ws/customers/{cid}",Customer.class,mapOfVars).getBody();
      Assert.assertTrue(customer.id == id);
      Assert.assertTrue(customer.firstName.toString().equals(fn));
      Assert.assertTrue(customer.lastName.toString().equals(ln));
      Assert.assertTrue(customer.email.toString().equals(email));
      if (log.isDebugEnabled()) {
        log.debug("response payload: " + ToStringBuilder.reflectionToString(customer));
      }
    }
  }
);
}
 

Example 18

From project staccatissimo, under directory /staccatissimo-util/src/main/java/net/sf/staccatocommons/util/.

Source file: Strings.java

  19 
vote

/** 
 * Returns a function that returns the result of sending {@link ToStringBuilder#reflectionToString(Object,org.apache.commons.lang.builder.ToStringStyle)}to its argument, using the given  {@link ToStringStyle}
 * @param < A >
 * @return a function that returns toString() of the argument using reflection
 */
public static <A>Function<A,String> reflectionToString(final ToStringStyle toStringStyle){
class ReflectionToString extends TopLevelFunction<A,String> {
    private static final long serialVersionUID=1L;
    public String apply(    A arg){
      return ToStringBuilder.reflectionToString(arg,toStringStyle);
    }
  }
  return new ReflectionToString();
}