Class JsonMLUtil

java.lang.Object
com.google.javascript.jscomp.jsonml.JsonMLUtil

public class JsonMLUtil extends Object
JsonMLUtil contains utilities for the JsonML object.
  • Constructor Details

    • JsonMLUtil

      public JsonMLUtil()
  • Method Details

    • isExpression

      public static boolean isExpression(JsonML element)
      Checks if the specified JsonML element represents an expression.
    • parseString

      public static JsonML parseString(String jsonml) throws Exception
      Parses JSON string which contains serialized JsonML content.
      Parameters:
      jsonml - string representation of JsonML
      Returns:
      root element of a JsonML tree
      Throws:
      Exception
    • compare

      public static String compare(JsonML tree1, JsonML tree2)
      Compares two specified JsonML trees. Two JsonML nodes are considered to be equal when the following conditions are met: - have the same type - have the same attributes from the list of attributes to compare - have the same number of children - nodes in each pair of corresponding children are equal Two JsonML trees are equal, if their roots are equal. When two nodes are compared, only the following attributes are taken into account: TagAttr.BODY, TagAttr.FLAGS, TagAttr.IS_PREFIX, TagAttr.LABEL, TagAttr.NAME, TagAttr.OP, TagAttr.TYPE, TagAttr.VALUE Generally, the comparator does not care about debugging attributes.
      Returns:
      Returns string describing the inequality in the following format: The trees are not equal: Tree1: -- string representation of Tree1 Tree2: -- string representation of Tree2 Subtree1: -- string representation of the subtree of the Tree1 which is not -- equal to the corresponding subtree of the Tree2 Subtree2: -- see Subtree1 If the trees are equal, null is returned.