// Path: hierarchyviewer/src/main/java/com/polidea/hierarchyviewer/HierarchyViewer.java
// public class HierarchyViewer {
// 
//     private static Injector injector;
// 
//     public static Injector injector() {
//         return injector;
//     }
// 
//     public static boolean isInjector() {
//         return injector != null;
//     }
// 
//     public static void start(Context context) {
//         start(context, new Config.Builder().build());
//     }
// 
//     public static void start(Context context, Config config) {
//         if (HierarchyViewerService.isRunning()) {
//             return;
//         }
// 
//         injector = new Injector(context, config);
// 
//         context.startService(new Intent(context, HierarchyViewerService.class));
//     }
// }
// 
// Path: hierarchyviewer/src/main/java/com/polidea/hierarchyviewer/internal/logic/HierarchyViewConverter.java
// public class HierarchyViewConverter {
// 
//     private HierarchyViewProvider hierarchyViewProvider;
//     private Gson gson;
//     private ConvertersContainer convertersContainer;
//     private FileUtilsProvider fileUtilsProvider;
// 
//     public HierarchyViewConverter() {
//         hierarchyViewProvider = HierarchyViewer.injector().getHierarchyViewProvider();
//         gson = HierarchyViewer.injector().getGson();
//         convertersContainer = HierarchyViewer.injector().getConvertersContainer();
//         fileUtilsProvider = HierarchyViewer.injector().getFileUtilsProvider();
//     }
// 
//     public String getHierarchyViewJson() {
//         try {
//             List<View> list = hierarchyViewProvider.getViewList();
//             return toJson(list);
//         } catch (Exception e) {
//             ThrowableModel throwableModel = new ThrowableModel();
//             throwableModel.setDataFromException(e);
//             return gson.toJson(throwableModel);
//         }
//     }
// 
//     private String toJson(final List<View> viewList) {
//         final HierarchyViewModel hierarchyView = new HierarchyViewModel();
//         for (final View view : viewList) {
//             ModelInfo modelInfo = convertersContainer.getModelInfoForClass(view.getClass());
//             modelInfo.setDataFromView(view, convertersContainer);
//             String pathToFile = UUID.randomUUID().toString();
//             if (fileUtilsProvider.saveViewInFile(view, pathToFile)) {
//                 ((ViewModelInfo) modelInfo).setPathToFile(pathToFile);
//             }
//             hierarchyView.add(modelInfo);
//         }
//         return gson.toJson(hierarchyView);
//     }
// }


import android.content.Context;
import com.polidea.hierarchyviewer.HierarchyViewer;
import com.polidea.hierarchyviewer.internal.logic.HierarchyViewConverter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import fi.iki.elonen.NanoHTTPD;
import static fi.iki.elonen.NanoHTTPD.Response.Status.OK;
package com.polidea.hierarchyviewer.internal.provider;






public class WebServer extends NanoHTTPD {

    private static final String
            MIME_PLAINTEXT = "text/plain",
            MIME_HTML = "text/html",
            MIME_JS = "application/javascript",
            MIME_CSS = "text/css",
            MIME_PNG = "image/png",
            MIME_JSON = "application/json",
            MIME_DEFAULT_BINARY = "application/octet-stream",
            MIME_XML = "text/xml",
            API_HIERARCHY = "/api/hierarchy",
            API_SCREEN = "/api/screen/";
    private static final String WEBAPP_PATH = "webapp";
    private final Context context;
// Path: hierarchyviewer/src/main/java/com/polidea/hierarchyviewer/HierarchyViewer.java
// public class HierarchyViewer {
// 
//     private static Injector injector;
// 
//     public static Injector injector() {
//         return injector;
//     }
// 
//     public static boolean isInjector() {
//         return injector != null;
//     }
// 
//     public static void start(Context context) {
//         start(context, new Config.Builder().build());
//     }
// 
//     public static void start(Context context, Config config) {
//         if (HierarchyViewerService.isRunning()) {
//             return;
//         }
// 
//         injector = new Injector(context, config);
// 
//         context.startService(new Intent(context, HierarchyViewerService.class));
//     }
// }
// 
// Path: hierarchyviewer/src/main/java/com/polidea/hierarchyviewer/internal/logic/HierarchyViewConverter.java
// public class HierarchyViewConverter {
// 
//     private HierarchyViewProvider hierarchyViewProvider;
//     private Gson gson;
//     private ConvertersContainer convertersContainer;
//     private FileUtilsProvider fileUtilsProvider;
// 
//     public HierarchyViewConverter() {
//         hierarchyViewProvider = HierarchyViewer.injector().getHierarchyViewProvider();
//         gson = HierarchyViewer.injector().getGson();
//         convertersContainer = HierarchyViewer.injector().getConvertersContainer();
//         fileUtilsProvider = HierarchyViewer.injector().getFileUtilsProvider();
//     }
// 
//     public String getHierarchyViewJson() {
//         try {
//             List<View> list = hierarchyViewProvider.getViewList();
//             return toJson(list);
//         } catch (Exception e) {
//             ThrowableModel throwableModel = new ThrowableModel();
//             throwableModel.setDataFromException(e);
//             return gson.toJson(throwableModel);
//         }
//     }
// 
//     private String toJson(final List<View> viewList) {
//         final HierarchyViewModel hierarchyView = new HierarchyViewModel();
//         for (final View view : viewList) {
//             ModelInfo modelInfo = convertersContainer.getModelInfoForClass(view.getClass());
//             modelInfo.setDataFromView(view, convertersContainer);
//             String pathToFile = UUID.randomUUID().toString();
//             if (fileUtilsProvider.saveViewInFile(view, pathToFile)) {
//                 ((ViewModelInfo) modelInfo).setPathToFile(pathToFile);
//             }
//             hierarchyView.add(modelInfo);
//         }
//         return gson.toJson(hierarchyView);
//     }
// }


// Path: hierarchyviewer/src/main/java/com/polidea/hierarchyviewer/internal/provider/WebServer.java
import android.content.Context;
import com.polidea.hierarchyviewer.HierarchyViewer;
import com.polidea.hierarchyviewer.internal.logic.HierarchyViewConverter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import fi.iki.elonen.NanoHTTPD;
import static fi.iki.elonen.NanoHTTPD.Response.Status.OK;

package com.polidea.hierarchyviewer.internal.provider;






public class WebServer extends NanoHTTPD {

    private static final String
            MIME_PLAINTEXT = "text/plain",
            MIME_HTML = "text/html",
            MIME_JS = "application/javascript",
            MIME_CSS = "text/css",
            MIME_PNG = "image/png",
            MIME_JSON = "application/json",
            MIME_DEFAULT_BINARY = "application/octet-stream",
            MIME_XML = "text/xml",
            API_HIERARCHY = "/api/hierarchy",
            API_SCREEN = "/api/screen/";
    private static final String WEBAPP_PATH = "webapp";
    private final Context context;
    private HierarchyViewConverter hierarchyViewConverter;