diff --git a/build.gradle.kts b/build.gradle.kts index 5131a05..1ab5896 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,10 +32,6 @@ dependencies { // Use the Kotlin JUnit integration. testImplementation("org.jetbrains.kotlin:kotlin-test-junit") - // Use HEML manipulator for matrix printer - implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.1") - implementation("org.jetbrains.kotlinx:kotlinx-html-js:0.7.1") - implementation("com.google.code.gson:gson:2.8.5") antlr("org.antlr:antlr4:4.8") @@ -146,4 +142,4 @@ task("build-all-tools", type = Jar::class) { configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) } }) baseName = project.name -} \ No newline at end of file +} diff --git a/src/main/kotlin/tasks/AllTools.kt b/src/main/kotlin/tasks/AllTools.kt index 8b02673..5a53034 100644 --- a/src/main/kotlin/tasks/AllTools.kt +++ b/src/main/kotlin/tasks/AllTools.kt @@ -35,10 +35,8 @@ fun main(args: Array) { val matrix = MatrixPrinter(datamap) matrix.populateMatrix(irNode.ir) - // generates HTML and JSON - var matrixOutputFile = changeExtension(filepath, "html") - matrix.generateHtmlFile(matrixOutputFile) - matrixOutputFile = changeExtension(filepath, "json") + // generates JSON + val matrixOutputFile = changeExtension(filepath, "json") matrix.generateJsonFile(matrixOutputFile) // generates .dot files diff --git a/src/main/kotlin/tasks/MatrixPrinter.kt b/src/main/kotlin/tasks/MatrixPrinter.kt index 0eacfb3..86317c4 100644 --- a/src/main/kotlin/tasks/MatrixPrinter.kt +++ b/src/main/kotlin/tasks/MatrixPrinter.kt @@ -8,9 +8,6 @@ import java.io.FileOutputStream import java.io.File import java.io.FileWriter -import kotlinx.html.* -import kotlinx.html.dom.* - import javax.xml.transform.TransformerFactory import javax.xml.transform.OutputKeys import javax.xml.parsers.DocumentBuilderFactory @@ -23,16 +20,15 @@ import com.google.gson.GsonBuilder * The class responsible for the matrix representation of a Hapi policy. *

* It implements the Kotlin matrix representation, as well as routines to - * generate its respective serialized formats, namely HTML and JSON. + * generate its JSON version. * Usage example: *

  *     // generate matrix
  *     val matrix = MatrixPrinter(actorsDataMap.elements(),
  *                                resourcesDataMap.elements())
  *     matrix.populateMatrix(irNode.ir)
- *     // HTML and JSON
+ *     // Generate JSON
  *     matrix.generateHtmlFile("Output.html")
- *     matrix.generateJsonFile("Output.json")
  * 
*/ class MatrixPrinter { @@ -112,80 +108,6 @@ class MatrixPrinter { } } - /** - * Generates and fills the target HTML serialized file with the properly - * formatted contents of the Hapi matrix. - *

- * Makes use of the Kotlin DSL for HTML - * kotlinx.html - * to easily create the java object. - * @param htmFileName target file - */ - public fun generateHtmlFile(htmFileName: String) { - val document = DocumentBuilderFactory.newInstance(). - newDocumentBuilder().newDocument() - - //kotlinx.html notation to generate a html page - val html = document.create.html { - head { - title("Lattice Matrix") - style { - unsafe { - raw( - """ - table, th, td { - border: 1px solid black; - border-collapse: collapse; - } - th, td { - padding: 8px 4px; - text-align: left; - } - p { - margin: 4px 0; - } - """ - ) - } - } - } - body { - table { - tr { - th {+" "} - for (resource_name in indexedResources) { - th {+resource_name} - } - } - for (i in 0..(matrix.size)-1) { - tr { - th {+indexedActors[i]} - for (j in 0..(matrix[i].size)-1) { - val cell = matrix[i][j] - td { - // Format something like "Reads: 0" - indexedActions.forEach { action -> - p {+(action + ": ${cell[action]}")} - } - } - } - } - } - } - } - } - - with(TransformerFactory.newInstance().newTransformer()) { - setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no") - setOutputProperty(OutputKeys.METHOD, "xml") - setOutputProperty(OutputKeys.INDENT, "yes") - setOutputProperty(OutputKeys.ENCODING, "UTF-8") - setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4") - transform(DOMSource(html), - StreamResult(OutputStreamWriter(FileOutputStream(htmFileName), "UTF-8"))) - } - } - /** * Generates and fills the target JSON serialized file with the properly * formatted contents of the Hapi matrix. @@ -222,7 +144,7 @@ class MatrixPrinter { } /** - * Builds the matrix and generates both HTML and JSON output files. + * Builds the matrix and generates JSON output file. * This is called by the gradle task "matrix". * * @param args the Hapi policy file name. The output serialized files shall have @@ -247,10 +169,6 @@ fun main(args: Array) { val matrix = MatrixPrinter(datamap) matrix.populateMatrix(irNode.ir) - // Generate output files - var matrixOutputFile = changeExtension(filepath, "html") - matrix.generateHtmlFile(matrixOutputFile) - - matrixOutputFile = changeExtension(filepath, "json") + val matrixOutputFile = changeExtension(filepath, "json") matrix.generateJsonFile(matrixOutputFile); }