private static JSONArray parseChildShapesRecursive ( ArrayList < Shape > childShapes ) throws JSONException { if ( childShapes != null ) { JSONArray childShapesArray = new JSONArray ( ) ; for ( Shape childShape : childShapes ) { JSONObject childShapeObject = new JSONObject ( ) ; childShapeObject . put ( "resourceId" , childShape . getResourceId ( ) . toString ( ) ) ; childShapeObject . put ( "properties" , parseProperties ( childShape . getProperties ( ) ) ) ; childShapeObject . put ( "stencil" , parseStencil ( childShape . getStencilId ( ) ) ) ; childShapeObject . put ( "childShapes" , parseChildShapesRecursive ( childShape . getChildShapes ( ) ) ) ; childShapeObject . put ( "outgoing" , parseOutgoings ( childShape . getOutgoings ( ) ) ) ; childShapeObject . put ( "bounds" , parseBounds ( childShape . getBounds ( ) ) ) ; childShapeObject . put ( "dockers" , parseDockers ( childShape . getDockers ( ) ) ) ; if ( childShape . getTarget ( ) != null ) { childShapeObject . put ( "target" , parseTarget ( childShape . getTarget ( ) ) ) ; } childShapesArray . put ( childShapeObject ) ; } return childShapesArray ; } return new JSONArray ( ) ; }
Parses all child Shapes recursively and adds them to the correct JSON Object