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

The following examples show how to use org.apache.commons.lang.builder.ToStringStyle. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: ankush   Source File: User.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String toString() {
    ToStringBuilder sb = new ToStringBuilder(this.id, ToStringStyle.DEFAULT_STYLE).append("id", this.id)
    		.append("username", this.username).append("enabled", this.enabled).append("accountExpired", this.accountExpired)
            .append("credentialsExpired", this.credentialsExpired).append("accountLocked", this.accountLocked);

    if (roles != null) {
        sb.append("Granted Authorities: ");

        int i = 0;
        for (Role role : roles) {
            if (i > 0) {
                sb.append(", ");
            }
            sb.append(role.toString());
            i++;
        }
    } else {
        sb.append("No Granted Authorities");
    }
    return sb.toString();
}
 
Example 2
Source Project: boubei-tss   Source File: Log.java    License: Apache License 2.0 6 votes vote down vote up
public Log(String operationCode, Object entity) {
	if(operationCode != null && operationCode.length() > 100) {
		operationCode = operationCode.substring(0, 100);
	}
	entity = entity == null ? "" : entity;
	
	this.setOperatorId( Environment.getUserId() );
    this.setOperatorName( Environment.getUserName() );
    this.setOperatorIP( Environment.getClientIp() );
    this.setOperationCode( operationCode );
    this.setOperateTable ( entity.getClass().getName() );
    this.setOperateTime  ( new Date() );
    
    String content;
 if(entity instanceof String || entity instanceof Number) {
 	content = String.valueOf(entity);
	} else {
		content = ToStringBuilder.reflectionToString(entity, ToStringStyle.SHORT_PREFIX_STYLE);
	}
    this.setContent( content);
    this.setOperatorBrowser( Environment.getOrigin() );
}
 
Example 3
Source Project: openhab1-addons   Source File: VariableConfig.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String toString() {
    ToStringBuilder tsb = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
    tsb.append("name", name);
    if (converter != null) {
        tsb.append("converter", converter);
    }
    if (action != null) {
        tsb.append("action", action);
    }
    if (forceUpdate) {
        tsb.append("forceUpdate", forceUpdate);
    }
    if (delay > 0.0) {
        tsb.append("delay", delay);
    }
    return tsb.toString();
}
 
Example 4
Source Project: hiped2   Source File: AvroStockAvgFileRead.java    License: Apache License 2.0 5 votes vote down vote up
public static void readFromAvro(InputStream is) throws IOException {
  DataFileStream<StockAvg> reader =     //<co id="ch03_smallfileread_comment1"/>
      new DataFileStream<StockAvg>(
          is,
          new SpecificDatumReader<StockAvg>(StockAvg.class));

  for (StockAvg a : reader) {          //<co id="ch03_smallfileread_comment2"/>
    System.out.println(ToStringBuilder.reflectionToString(a,
        ToStringStyle.SHORT_PREFIX_STYLE
    ));
  }

  IOUtils.closeStream(is);
  IOUtils.closeStream(reader);
}
 
Example 5
Source Project: secure-data-service   Source File: SDKAPIClient.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<GenericEntity> searchStudents(String token, String query, Map<String, String> params) {
    LOG.info("searchStudents: " + query);
    LOG.info("params: " + ToStringBuilder.reflectionToString(params, ToStringStyle.MULTI_LINE_STYLE));

    //rreturn this.readEntityList(token, "search/students?q=" + query + "&" + this.buildQueryString(params));
    return this.readEntityList(token, SDKConstants.STUDENTS + "?" + SDKConstants.PARAM_LAST_NAME  + "=~" + query + "&" + this.buildQueryString(params));
}
 
Example 6
Source Project: openhab1-addons   Source File: Sun.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("sunrise", getRise())
            .append("noon", getNoon()).append("sunset", getSet()).append("night", night)
            .append("morningNight", morningNight).append("astroDawn", astroDawn).append("nauticDawn", nauticDawn)
            .append("civilDawn", civilDawn).append("civilDusk", civilDusk).append("nauticDusk", nauticDusk)
            .append("astroDusk", astroDusk).append("daylight", getDaylight())
            .append("eveningNight", getEveningNight()).append("eclipse", eclipse).toString();
}
 
Example 7
Source Project: Bats   Source File: LogicalPlanConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString()
{
  return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
      .append("id", this.id)
      .toString();
}
 
Example 8
Source Project: Bats   Source File: LogicalPlanConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * @return String
 */
@Override
public String toString()
{
  return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
      .append("id", this.id)
      .toString();
}
 
Example 9
Source Project: Bats   Source File: PTContainer.java    License: Apache License 2.0 5 votes vote down vote up
public String toIdStateString()
{
  return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
      .append("id", "" + seq + "(" + this.containerId + ")")
      .append("state", this.getState())
      .toString();
}
 
Example 10
Source Project: attic-apex-core   Source File: LogicalPlan.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString()
{
  return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
      .append("operators", this.operators)
      .append("streams", this.streams)
      .append("properties", this.attributes)
      .toString();
}
 
Example 11
Source Project: usergrid   Source File: Point.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
            .append("x", x)
            .append("y", y)
            .toString();
}
 
Example 12
/**
 * {@inheritDoc}
 */
@Override
public void addForward(String fqdn, String ipAddress) {
    List<String> commands = createCommands();
    List<String> stdins = createAddForward(fqdn, ipAddress);

    CommandResult result = execute(commands, stdins);

    if (result.getExitValue() != 0) {
        // 正引きレコードの追加に失敗
        AutoException exception = new AutoException("ECOMMON-000201", fqdn, ipAddress);
        exception.addDetailInfo(
                "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
        throw exception;
    }

    // 正引きの確認
    long timeout = 10000L;
    long startTime = System.currentTimeMillis();
    while (true) {
        String hostAddress = getHostAddress(fqdn);
        if (StringUtils.equals(ipAddress, hostAddress)) {
            break;
        }
        if (System.currentTimeMillis() - startTime > timeout) {
            // タイムアウト発生時
            throw new AutoException("ECOMMON-000202", fqdn, ipAddress, hostAddress);
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ignore) {
        }
    }
}
 
Example 13
Source Project: hop   Source File: PluginMessages.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @see java.lang.Object#toString()
 */
@Override
public String toString() {
  final ToStringBuilder builder = new ToStringBuilder( this, ToStringStyle.SHORT_PREFIX_STYLE );
  builder.append( "packageName", this.packageName );
  return builder.toString();
}
 
Example 14
@Test
public void testInspect() {
	ListMultimap<CustomizationType, Customization> customizationMap = loadCustomizationMap();
	List<Customization> curCustomizations = customizationMap.get(CustomizationType.INFO);
	for(Customization cur : curCustomizations) {
		System.out.println(ReflectionToStringBuilder.toString(cur, ToStringStyle.MULTI_LINE_STYLE));
	}
}
 
Example 15
Source Project: smarthome   Source File: Sun.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("sunrise", getRise())
            .append("noon", getNoon()).append("sunset", getSet()).append("night", getNight())
            .append("morningNight", getMorningNight()).append("astroDawn", getAstroDawn())
            .append("nauticDawn", getNauticDawn()).append("civilDawn", getCivilDawn())
            .append("civilDusk", getCivilDusk()).append("nauticDusk", getNauticDawn())
            .append("astroDusk", getAstroDusk()).append("daylight", getDaylight())
            .append("eveningNight", getEveningNight()).append("eclipse", eclipse).append("phase", phase)
            .append("radiation", radiation).toString();
}
 
Example 16
Source Project: usergrid   Source File: Params.java    License: Apache License 2.0 5 votes vote down vote up
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
            .append("moduleId", moduleId)
            .append("testName", testName)
            .append("commitId", commitId)
            .append("runNumber", runNumber)
            .append("metricType", metric)
            .append("percentile", percentile)
            .append("failureType", failureType)
            .toString();
}
 
Example 17
Source Project: usergrid   Source File: BasicRunner.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return new ToStringBuilder( this, ToStringStyle.SHORT_PREFIX_STYLE )
            .append( "url", url )
            .append( "ipv4Address", ipv4Address )
            .append( "hostname", hostname )
            .append( "serverPort", serverPort )
            .append( "tempDir", tempDir )
            .toString();
}
 
Example 18
Source Project: pentaho-kettle   Source File: KeyValueSet.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return string representation.
 */
public String toMultiLineString() {
  final ToStringBuilder builder = new ToStringBuilder( this, ToStringStyle.MULTI_LINE_STYLE );
  for ( KeyValue<?> keyValue : this.entries.values() ) {
    builder.append( keyValue.getKey(), keyValue.getValue() );
  }
  return builder.toString();
}
 
Example 19
Source Project: pxf   Source File: LoginSession.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
            .append("config", configDirectory)
            .append("principal", principalName)
            .append("keytab", keytabPath)
            .append("kerberosMinMillisBeforeRelogin", kerberosMinMillisBeforeRelogin)
            .toString();
}
 
Example 20
Source Project: openhab1-addons   Source File: Moon.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
            .append("rise", DateTimeUtils.getDate(getRise().getStart()))
            .append("set", DateTimeUtils.getDate(getSet().getEnd())).append("phase", phase).append("apogee", apogee)
            .append("perigee", perigee).append("distance", distance).append("eclipse", eclipse)
            .append("position", position).append("zodiac", zodiac).toString();
}
 
Example 21
/**
 * {@inheritDoc}
 */
@Override
public void deleteCanonicalName(String fqdn) {
    List<String> commands = createCommands();
    List<String> stdins = createDeleteCanonicalName(fqdn);

    CommandResult result = execute(commands, stdins);

    if (result.getExitValue() != 0) {
        // CNAMEレコードの削除に失敗
        AutoException exception = new AutoException("ECOMMON-000211", fqdn);
        exception.addDetailInfo(
                "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
        throw exception;
    }

    // CNAMEの確認
    long timeout = 10000L;
    long startTime = System.currentTimeMillis();
    while (true) {
        String cname = getCanonicalName(fqdn);
        if (cname == null) {
            break;
        }
        if (System.currentTimeMillis() - startTime > timeout) {
            // タイムアウト発生時
            throw new AutoException("ECOMMON-000212", fqdn, cname);
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ignore) {
        }
    }
}
 
Example 22
Source Project: sailfish-core   Source File: PredictionResultEntry.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {

    ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
    toStringBuilder.append("actionId", actionId)
            .append("messageId", messageId)
            .append("classValue", classValue)
            .append("probabilities", predictedClassProbability);

    return toStringBuilder.toString();
}
 
Example 23
/**
 * Create a key including the
 * <li><b>expenditureFinancialDocumentNumber</b></li>
 * <li><b>expenditureFinancialDocumentTypeCode</b></li>
 * with accounting information for asset payment distribution
 *
 * Make sure the full accounting line information is part of the key
 * chartOfAccount, accountNumber, subAccountNumber, objectCode, subObjectCode, projectCode
 *
 * @return
 */
public String getAssetPaymentDetailKey() {
    LinkedHashMap<String,String> paymentMap = assetPaymentToStringMapper();
    paymentMap.put("expenditureFinancialDocumentTypeCode",this.getExpenditureFinancialDocumentTypeCode());
    paymentMap.put("expenditureFinancialDocumentNumber",this.getExpenditureFinancialDocumentNumber());

    //use SHORT_PREFIX_STYLE so that memory address is not part of the toString output
    ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
    for (String key : paymentMap.keySet()){
        builder.append(key, paymentMap.get(key));
    }
    return paymentMap.toString();
}
 
Example 24
@Override
public String toString() {
  return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
      .append("adGroupId", adGroupId)
      .append("biddingStrategyConfig", biddingStrategyConfig)
      .append("originalRoot is empty", originalRoot == null)
      // Add a newline before the root so that the tree levels all line up.
      .append("root", String.format("%n%s", root.toDetailedString()))
      .toString();
}
 
Example 25
@Override
public String toString() {
    ToStringBuilder tsb = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
    tsb.append("planet", planetName.toString().toLowerCase()).append("type", type).append("property", property);
    if (offset != 0) {
        tsb.append("offset", offset);
    }
    return tsb.toString();
}
 
Example 26
Source Project: iaf   Source File: SerializationTester.java    License: Apache License 2.0 5 votes vote down vote up
public T testSerialization(T in) throws Exception {
	byte[] wire=serialize(in);
	if (wire==null) {
		throw new NullPointerException("Could not Serialize ["+ToStringBuilder.reflectionToString(in,ToStringStyle.MULTI_LINE_STYLE)+"]");
	}
	T out=deserialize(wire);
	if (out==null) {
		throw new NullPointerException("Could not Deserialize ["+ToStringBuilder.reflectionToString(in,ToStringStyle.MULTI_LINE_STYLE)+"]");
	}
	return out;
}
 
Example 27
Source Project: iaf   Source File: FileRecordListener.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
	String result = super.toString();
	ToStringBuilder ts = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
	ts.append("name", getName());
	ts.append("inputDirectory", getInputDirectory());
	ts.append("wildcard", getWildcard());
	result += ts.toString();
	return result;

}
 
Example 28
/**
 * {@inheritDoc}
 */
@Override
public void deleteReverse(String ipAddress) {
    List<String> commands = createCommands();
    List<String> stdins = createDeleteReverse(ipAddress);

    CommandResult result = execute(commands, stdins);

    if (result.getExitValue() != 0) {
        // 逆引きレコードの削除に失敗
        AutoException exception = new AutoException("ECOMMON-000209", ipAddress);
        exception.addDetailInfo(
                "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
        throw exception;
    }

    // 逆引きの確認
    long timeout = 10000L;
    long startTime = System.currentTimeMillis();
    while (true) {
        String hostName = getHostName(ipAddress);
        if (StringUtils.equals(ipAddress, hostName)) {
            break;
        }
        if (System.currentTimeMillis() - startTime > timeout) {
            // タイムアウト発生時
            throw new AutoException("ECOMMON-000210", ipAddress, hostName);
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ignore) {
        }
    }
}
 
Example 29
Source Project: secure-data-service   Source File: EdOrgHelper.java    License: Apache License 2.0 5 votes vote down vote up
private Set<String> getEdOrgs(Entity principal, boolean filterByOwnership) {
    LOG.trace(">>>EdOrgHelper.getDirectEdorgs()");
    LOG.trace("  principal: " + ToStringBuilder.reflectionToString(principal, ToStringStyle.MULTI_LINE_STYLE));
    LOG.trace("  filterByOwnership: " + filterByOwnership);

    Set<String> result = new HashSet<String>();

    if (isStaff(principal) || isTeacher(principal)) {
        LOG.trace("  ...staff or teacher");
        result = getStaffDirectlyAssociatedEdorgs(principal, filterByOwnership);
    } else if (isStudent(principal)) {
        LOG.trace("  ...student");
        result = getStudentsCurrentAssociatedEdOrgs(Collections.singleton(principal.getEntityId()), filterByOwnership);
    } else if (isParent(principal)) {
        LOG.trace("  ...parent");
        SLIPrincipal prince = new SLIPrincipal();
        prince.setEntity(principal);
        prince.populateChildren(repo);
        result = getStudentsCurrentAssociatedEdOrgs(prince.getOwnedStudentIds(), false);
    }

    if (result == null) {
        LOG.debug("  ...method did not do anything so return empty set...");
    }

    return result;
}
 
Example 30
Source Project: attic-apex-core   Source File: LogicalPlan.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String toString()
{
  return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
      .append("operator", this.operatorMeta)
      .append("portAnnotation", this.portAnnotation)
      .append("adrAnnotation", this.adrAnnotation)
      .append("field", this.fieldName)
      .toString();
}