@ Trivial // generates too much trace private Object getJSONValue ( Object value , Set < String > processed ) throws IOException { if ( value instanceof String ) { String s = ( String ) value ; if ( s . matches ( ".*_\\d+" ) ) { // If a value ends with _<numbers> assume it's a PID and try to look it up Configuration [ ] c ; try { String filter = FilterUtils . createPropertyFilter ( "service.pid" , s ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( this , tc , "getJSONValue pid filter" , filter ) ; c = configAdmin . listConfigurations ( filter ) ; } catch ( InvalidSyntaxException x ) { throw new RuntimeException ( x ) ; } if ( c != null ) { Dictionary < String , Object > props = c [ 0 ] . getProperties ( ) ; String uid = getUID ( ( String ) props . get ( "config.displayId" ) , ( String ) props . get ( "id" ) ) ; Object configInfo = getConfigInfo ( uid , props , new HashSet < String > ( processed ) ) ; if ( configInfo != null ) value = configInfo ; } } } else if ( value instanceof Number || value instanceof Boolean ) ; // common paths - no special handling else if ( value instanceof SerializableProtectedString ) value = "******" ; // hide passwords else if ( value . getClass ( ) . isArray ( ) ) { // list supplied as an array for positive cardinality JSONArray a = new JSONArray ( ) ; int length = Array . getLength ( value ) ; for ( int i = 0 ; i < length ; i ++ ) a . ( getJSONValue ( Array . get ( value , i ) , processed ) ) ; value = a ; } else if ( value instanceof Collection ) { // list supplied as a Vector for negative cardinality JSONArray a = new JSONArray ( ) ; for ( Object o : ( Collection < ? > ) value ) a . ( getJSONValue ( o , processed ) ) ; value = a ; } else value = value . toString ( ) ; // TODO any special handling here? Example: com.ibm.wsspi.kernel.service.utils.OnErrorUtil$OnError return value ; }
Converts the specified value to one that can be included in JSON