List of usage examples for org.apache.commons.lang3 ClassUtils getShortClassName
public static String getShortClassName(final Object object, final String valueIfNull)
Gets the class name minus the package name for an Object .
From source file:edu.umich.flowfence.common.CallParam.java
public String toString(ClassLoader loader) { StringBuilder sb = new StringBuilder(); sb.append("[param "); if ((header & FLAG_BY_REF) != 0) { sb.append("ref "); }//from w ww . j a v a2 s . co m if ((header & FLAG_RETURN) != 0) { sb.append("inout "); } switch (getType()) { case TYPE_NULL: sb.append("null"); break; case TYPE_DATA: Object value = "decode-failure"; sb.append("data "); try { value = decodePayload(loader); } catch (Exception e) { sb.append(payload); break; } sb.append(ClassUtils.getShortClassName(value, "null")); if (value != null) { sb.append(' '); sb.append(ArrayUtils.toString(value)); } break; case TYPE_HANDLE: sb.append("handle "); if ((header & HANDLE_RELEASE) != 0) { sb.append("release "); } if ((header & HANDLE_SYNC_ONLY) != 0) { sb.append("synconly "); } sb.append(payload); break; default: sb.append("<unknown>"); break; } sb.append(']'); return sb.toString(); }
From source file:cc.sion.core.utils.Exceptions.java
/** * ??: ? <-- RootCause??: ?// ww w . j av a2s . co m */ public static String toStringWithRootCause(@Nullable Throwable t) { if (t == null) { return StringUtils.EMPTY; } final String clsName = ClassUtils.getShortClassName(t, null); final String message = StringUtils.defaultString(t.getMessage()); Throwable cause = getRootCause(t); StringBuilder sb = new StringBuilder(128).append(clsName).append(": ").append(message); if (cause != t) { sb.append("; <---").append(toStringWithShortName(cause)); } return sb.toString(); }
From source file:net.xby1993.common.util.ExceptionUtil.java
/** * ??: ? <-- RootCause??: ?/*from w w w.j a va2s . c o m*/ */ public static String toStringWithRootCause(Throwable t) { if (t == null) { return StringUtils.EMPTY; } final String clsName = ClassUtils.getShortClassName(t, null); final String message = StringUtils.defaultString(t.getMessage()); Throwable cause = getRootCause(t); StringBuilder sb = new StringBuilder(128).append(clsName).append(": ").append(message); if (cause != t) { sb.append("; <---").append(toStringWithShortName(cause)); } return sb.toString(); }
From source file:org.apache.metron.management.ThreatTriageFunctions.java
/** * Retrieves the sensor enrichment configuration from the function arguments. The manner * of retrieving the configuration can differ based on what the user passes in. * @param args The function arguments./*from ww w .j a v a 2s . c o m*/ * @param position The position from which the configuration will be extracted. * @return The sensor enrichment configuration. */ private static SensorEnrichmentConfig getSensorEnrichmentConfig(List<Object> args, int position) { Object arg0 = Util.getArg(position, Object.class, args); SensorEnrichmentConfig config = new SensorEnrichmentConfig(); if (arg0 instanceof String) { // deserialize the configuration from json String json = Util.getArg(0, String.class, args); if (json != null) { config = (SensorEnrichmentConfig) ENRICHMENT.deserialize(json); } } else if (arg0 instanceof ThreatTriageProcessor) { // extract the configuration from the engine ThreatTriageProcessor engine = Util.getArg(0, ThreatTriageProcessor.class, args); config = engine.getSensorConfig(); } else { // unexpected type throw new IllegalArgumentException( String.format("Unexpected type: got '%s'", ClassUtils.getShortClassName(arg0, "null"))); } return config; }
From source file:org.apache.metron.profiler.bolt.KafkaDestinationHandler.java
@Override public void emit(ProfileMeasurement measurement, OutputCollector collector) { JSONObject message = new JSONObject(); message.put("profile", measurement.getDefinition().getProfile()); message.put("entity", measurement.getEntity()); message.put("period", measurement.getPeriod().getPeriod()); message.put("period.start", measurement.getPeriod().getStartTimeMillis()); message.put("period.end", measurement.getPeriod().getEndTimeMillis()); message.put("timestamp", System.currentTimeMillis()); message.put("source.type", sourceType); message.put("is_alert", "true"); // append each of the triage values to the message measurement.getTriageValues().forEach((key, value) -> { if (isValidType(value)) { message.put(key, value);/*from www . j av a2 s.com*/ } else { LOG.error(String.format( "triage expression has invalid type. expect primitive types only. skipping: profile=%s, entity=%s, expression=%s, type=%s", measurement.getDefinition().getProfile(), measurement.getEntity(), key, ClassUtils.getShortClassName(value, "null"))); } }); collector.emit(getStreamId(), new Values(message)); }
From source file:org.apache.metron.profiler.bolt.KafkaEmitter.java
/** * Appends triage values obtained from a {@code ProfileMeasurement} to the * outgoing message.//from w ww .ja va 2 s . c o m * * @param measurement The measurement that may contain triage values. * @param message The message that the triage values are appended to. */ private void appendTriageValues(ProfileMeasurement measurement, JSONObject message) { // for each triage value... Map<String, Object> triageValues = MapUtils.emptyIfNull(measurement.getTriageValues()); triageValues.forEach((key, value) -> { // append the triage value to the message if (isValidType(value)) { message.put(key, value); } else { LOG.error(String.format( "triage expression must result in primitive type, skipping; type=%s, profile=%s, entity=%s, expr=%s", ClassUtils.getShortClassName(value, "null"), measurement.getDefinition().getProfile(), measurement.getEntity(), key)); } }); }