private Integer getChildCount ( Value value ) { // all types listed here are directly toString() in the debugger if ( value instanceof NumericValue || value instanceof CharacterValue || value instanceof NilValue || value instanceof TokenValue ) { return 0 ; } else if ( value instanceof SetValue ) { return ( ( SetValue ) value ) . values . size ( ) ; } else if ( value instanceof SeqValue ) { boolean isString = true ; for ( Value v : ( ( SeqValue ) value ) . values ) { if ( ! ( deref ( v ) instanceof CharacterValue ) ) { isString = false ; } } if ( isString ) { return 0 ; // tread as simple value } else { return ( ( SeqValue ) value ) . values . size ( ) ; } } else if ( value instanceof MapValue ) { return ( ( MapValue ) value ) . values . size ( ) ; } else if ( value instanceof ObjectValue ) { int count = 0 ; for ( NameValuePair v : ( ( ObjectValue ) value ) . members . asList ( ) ) { if ( isDebugVisible ( v . value ) ) { count ++ ; } } return count ; } else if ( value instanceof UpdatableValue || value instanceof TransactionValue || value instanceof ReferenceValue ) { return getChildCount ( deref ( value ) ) ; } else if ( value instanceof RecordValue ) { RecordValue rVal = ( RecordValue ) value ; return rVal . fieldmap . size ( ) ; } else if ( value instanceof TupleValue ) { TupleValue tVal = ( TupleValue ) value ; return tVal . values . size ( ) ; } return 0 ; }
Calculates if a value has children and returns the child count