protected JsTreeNodeData populateTreeNodeData ( FileObject file , boolean noChild , String relativePath ) throws FileSystemException { JsTreeNodeData node = new JsTreeNodeData ( ) ; String baseName = file . getName ( ) . getBaseName ( ) ; FileContent content = file . getContent ( ) ; FileType type = file . getType ( ) ; node . setData ( baseName ) ; Map < String , Object > attr = new HashMap < String , Object > ( ) ; node . setAttr ( attr ) ; attr . put ( "id" , relativePath ) ; attr . put ( "rel" , type . getName ( ) ) ; attr . put ( "fileType" , type . getName ( ) ) ; if ( content != null ) { long fileLastModifiedTime = file . getContent ( ) . getLastModifiedTime ( ) ; attr . put ( "fileLastModifiedTime" , fileLastModifiedTime ) ; attr . put ( "fileLastModifiedTimeForDisplay" , DateFormat . getDateTimeInstance ( ) . format ( new Date ( fileLastModifiedTime ) ) ) ; if ( file . getType ( ) != FileType . FOLDER ) { attr . put ( "fileSize" , content . getSize ( ) ) ; attr . put ( "fileSizeForDisplay" , FileUtils . byteCountToDisplaySize ( content . getSize ( ) ) ) ; } } // these fields should not appear in JSON for leaf nodes if ( ! noChild ) { node . setState ( JsTreeNodeData . STATE_CLOSED ) ; } return node ; }
It transforms FileObject into JsTreeNodeData .