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

The following examples show how to use org.apache.commons.lang.builder.ToStringStyle. 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 File: Log.java    From boubei-tss with 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 #2
Source File: User.java    From ankush with 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 #3
Source File: VariableConfig.java    From openhab1-addons with 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 File: PluginMessages.java    From hop with 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 #5
Source File: LoginSession.java    From pxf with 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 #6
Source File: AssetPaymentDetail.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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 #7
Source File: RecoverableInputOperator.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
@Override
public String toString()
{
  return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
          .append("firstRun", this.firstRun)
          .append("checkpointedWindowId", Codec.getStringWindowId(checkpointedWindowId))
          .toString();
}
 
Example #8
Source File: Sun.java    From openhab1-addons with 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 #9
Source File: DnsStrategy.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 #10
Source File: WeatherBindingConfig.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String toString() {
    ToStringBuilder tsb = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
    tsb.append("locationId", locationId).append("type", type).append("property", property);
    if (roundingMode != null) {
        tsb.append("roundingMode", roundingMode).append("scale", scale);
    }
    if (unit != null) {
        tsb.append("unit", unit.toString());
    }
    return tsb.toString();
}
 
Example #11
Source File: LogicalPlanConfiguration.java    From Bats with 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 #12
Source File: PredictionResultEntry.java    From sailfish-core with 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 #13
Source File: ArgumentTypeMismatchTest.java    From QLExpress with Apache License 2.0 5 votes vote down vote up
@Test
public void test3() throws Exception {
    ExpressRunner runner = new ExpressRunner();
    runner.addFunction("abc", new Operator() {
        @Override
        public Object executeInner(Object[] list) throws Exception {
            Long paramA = Long.valueOf(list[0].toString());
            Integer paramB = Integer.valueOf(list[1].toString());
            String paramC = list[2].toString();
            singleton.functionABC(paramA, paramB, paramC);
            return null;
        }
    });
    
    OperatorBase function = runner.getFunciton("abc");
    System.out.println("function = " + ToStringBuilder.reflectionToString(function, ToStringStyle.MULTI_LINE_STYLE));
    
    String exp = "abc(a,b,c)";
    IExpressContext<String, Object> context = new DefaultContext<String, Object>();
    context.put("a", "1");
    context.put("b", "2");
    context.put("c", "3");
    
    InstructionSet instructionSet = runner.getInstructionSetFromLocalCache(exp);
    String[] outFunctionNames = runner.getOutFunctionNames(exp);
    String[] outVarNames = runner.getOutVarNames(exp);
    System.out.println("before execute instructionSet = " + instructionSet);
    System.out.println("outFunctionNames = " + ToStringBuilder.reflectionToString(outFunctionNames, ToStringStyle.MULTI_LINE_STYLE));
    System.out.println("outVarNames = " + ToStringBuilder.reflectionToString(outVarNames, ToStringStyle.MULTI_LINE_STYLE));

    runner.execute(exp, context, null, false, false);
    
    instructionSet = runner.getInstructionSetFromLocalCache(exp);
    outFunctionNames = runner.getOutFunctionNames(exp);
    outVarNames = runner.getOutVarNames(exp);
    System.out.println("after execute instructionSet = " + instructionSet);
    System.out.println("outFunctionNames = " + ToStringBuilder.reflectionToString(outFunctionNames, ToStringStyle.MULTI_LINE_STYLE));
    System.out.println("outVarNames = " + ToStringBuilder.reflectionToString(outVarNames, ToStringStyle.MULTI_LINE_STYLE));
}
 
Example #14
Source File: LogicalPlan.java    From attic-apex-core with 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("adqAnnotation", this.adqAnnotation)
      .append("field", this.fieldName)
      .toString();
}
 
Example #15
Source File: DnsStrategy.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 #16
Source File: LocationConfig.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("providerName", providerName)
            .append("language", language).append("updateInterval", updateInterval).append("latitude", latitude)
            .append("longitude", longitude).append("locationId", locationId).append("name", name).toString();
}
 
Example #17
Source File: Point.java    From usergrid with 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 #18
Source File: LogicalPlan.java    From attic-apex-core with 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();
}
 
Example #19
Source File: EdOrgHelper.java    From secure-data-service with 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 #20
Source File: TestPairingCatalogManagerMoreTests.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@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 #21
Source File: Sun.java    From smarthome with 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 #22
Source File: DnsStrategy.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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 #23
Source File: FileRecordListener.java    From iaf with 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 #24
Source File: SerializationTester.java    From iaf with 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 #25
Source File: AstroBindingConfig.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
@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 File: ProductPartitionTreeImpl.java    From googleads-java-lib with Apache License 2.0 5 votes vote down vote up
@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 #27
Source File: KeyValueSet.java    From pentaho-kettle with 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 #28
Source File: Params.java    From usergrid with 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 #29
Source File: BasicRunner.java    From usergrid with 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 #30
Source File: AvroStockAvgFileRead.java    From hiped2 with 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);
}