/**
   * Initializes the super category.
   *
   * @param p0 the category
   * @param p1 the super category list
   */
  static void initialize_super_category(java.lang.Object p0, java.lang.Object p1)
      throws java.lang.Exception {

    org.apache.xerces.dom.DeepNodeListImpl l = (org.apache.xerces.dom.DeepNodeListImpl) p1;

    if (l != null) {

      org.apache.xerces.dom.NodeImpl n = (org.apache.xerces.dom.NodeImpl) l.item(0);

      if (n != null) {

        LogHandler.log(LogHandler.INFO_LOG_LEVEL, "Initialize super category.");
        java.lang.Object s =
            CategoryHandler.read_attribute(
                (org.apache.xerces.dom.NamedNodeMapImpl) n.getAttributes(),
                CategoryHandler.CATEGORY);
        CategoryHandler.initialize_category(p0, s);

      } else {

        LogHandler.log(
            LogHandler.WARNING_LOG_LEVEL,
            "Could not initialize super category. The super category node is null.");
      }

    } else {

      LogHandler.log(
          LogHandler.WARNING_LOG_LEVEL,
          "Could not initialize super category. The super category list is null.");
    }
  }
  /**
   * Initializes the attributes.
   *
   * @param p0 the attribute items
   * @param p1 the attributes map
   */
  static void initialize_attributes(java.lang.Object p0, java.lang.Object p1) {

    LogHandler.log(LogHandler.INFO_LOG_LEVEL, "Initialize attributes.");
    java.lang.Object a = null;

    a = CategoryHandler.read_attribute(p1, CategoryHandler.NAME);
    MapHandler.set_map_element(p0, CategoryHandler.NAME, a);

    a = CategoryHandler.read_attribute(p1, CategoryHandler.ITEM_CATEGORY);
    MapHandler.set_map_element(p0, CategoryHandler.ITEM_CATEGORY, a);

    a = CategoryHandler.read_attribute(p1, CategoryHandler.ITEM_ABSTRACTION);
    MapHandler.set_map_element(p0, CategoryHandler.ITEM_ABSTRACTION, a);

    a = CategoryHandler.read_attribute(p1, CategoryHandler.POSITION_CATEGORY);
    MapHandler.set_map_element(p0, CategoryHandler.POSITION_CATEGORY, a);

    a = CategoryHandler.read_attribute(p1, CategoryHandler.POSITION_ABSTRACTION);
    MapHandler.set_map_element(p0, CategoryHandler.POSITION_ABSTRACTION, a);

    a = CategoryHandler.read_attribute(p1, CategoryHandler.INSTANCE_CATEGORY);
    MapHandler.set_map_element(p0, CategoryHandler.INSTANCE_CATEGORY, a);

    a = CategoryHandler.read_attribute(p1, CategoryHandler.INSTANCE_ABSTRACTION);
    MapHandler.set_map_element(p0, CategoryHandler.INSTANCE_ABSTRACTION, a);

    a = CategoryHandler.read_attribute(p1, CategoryHandler.INTERACTION_CATEGORY);
    MapHandler.set_map_element(p0, CategoryHandler.INTERACTION_CATEGORY, a);

    a = CategoryHandler.read_attribute(p1, CategoryHandler.INTERACTION_ABSTRACTION);
    MapHandler.set_map_element(p0, CategoryHandler.INTERACTION_ABSTRACTION, a);
  }
  /**
   * Initializes the java objects.
   *
   * @param p0 the category
   * @param p1 the category java objects list
   */
  static void initialize_java_objects(java.lang.Object p0, java.lang.Object p1) {

    org.apache.xerces.dom.DeepNodeListImpl l = (org.apache.xerces.dom.DeepNodeListImpl) p1;

    if (l != null) {

      LogHandler.log(LogHandler.INFO_LOG_LEVEL, "Initialize java objects.");
      org.apache.xerces.dom.NodeImpl n = (org.apache.xerces.dom.NodeImpl) l.item(0);

      if (n != null) {

        Item c = (Item) p0;

        if (c != null) {

          Item o = null;

          // Sometimes, a super category sets a java object that is not
          // wanted in a sub category. In this case, it can be set to null:
          // <javaobject category="null"/>
          if (CategoryHandler.is_java_object_null(n) == false) {

            o = new Item();
            ItemHandler.initialize_item_containers(o);
            CategoryHandler.initialize_java_object(o, n);

          } else {

            o = null;
          }

          c.java_object = o;

        } else {

          LogHandler.log(
              LogHandler.ERROR_LOG_LEVEL,
              "Could not initialize java objects. The category is null.");
        }

      } else {

        LogHandler.log(
            LogHandler.INFO_LOG_LEVEL,
            "Could not initialize java objects. The java object node is null.");
      }

    } else {

      LogHandler.log(
          LogHandler.ERROR_LOG_LEVEL,
          "Could not initialize java objects. The java objects list is null.");
    }
  }
  /**
   * Initializes the item.
   *
   * @param p0 the item
   * @param p1 the item node
   */
  static void initialize_item(java.lang.Object p0, java.lang.Object p1) {

    Item i = (Item) p0;

    if (i != null) {

      org.apache.xerces.dom.NodeImpl n = (org.apache.xerces.dom.NodeImpl) p1;

      if (n != null) {

        LogHandler.log(LogHandler.INFO_LOG_LEVEL, "Initialize item.");
        CategoryHandler.initialize_attributes(
            i.items, (org.apache.xerces.dom.NamedNodeMapImpl) n.getAttributes());

      } else {

        LogHandler.log(
            LogHandler.WARNING_LOG_LEVEL, "Could not initialize item. The item node is null.");
      }

    } else {

      LogHandler.log(LogHandler.WARNING_LOG_LEVEL, "Could not initialize item. The item is null.");
    }
  }
  /**
   * Checks if java object is null.
   *
   * @param p0 the category items
   * @return true if the java object is null; false otherwise
   */
  static boolean is_java_object_null(java.lang.Object p0) {

    boolean b = false;
    org.apache.xerces.dom.NodeImpl n = (org.apache.xerces.dom.NodeImpl) p0;

    if (n != null) {

      LogHandler.log(LogHandler.INFO_LOG_LEVEL, "Check if java object is null.");
      org.apache.xerces.dom.NamedNodeMapImpl m =
          (org.apache.xerces.dom.NamedNodeMapImpl) n.getAttributes();
      java.lang.String a =
          (java.lang.String) CategoryHandler.read_attribute(m, CategoryHandler.CATEGORY);

      if (a.equals(CategoryHandler.NULL)) {

        b = true;
      }

    } else {

      LogHandler.log(
          LogHandler.WARNING_LOG_LEVEL,
          "Could not initialize java object. The java object node is null.");
    }

    return b;
  }
  /**
   * Initializes the items.
   *
   * @param p0 the category items
   * @param p1 the category items list
   */
  static void initialize_items(java.lang.Object p0, java.lang.Object p1) {

    org.apache.xerces.dom.DeepNodeListImpl l = (org.apache.xerces.dom.DeepNodeListImpl) p1;

    if (l != null) {

      LogHandler.log(LogHandler.INFO_LOG_LEVEL, "Initialize items.");
      int count = 0;
      int size = l.getLength();
      org.apache.xerces.dom.NodeImpl n = null;
      Item i = null;
      java.lang.Object name = null;

      while (count < size) {

        n = (org.apache.xerces.dom.NodeImpl) l.item(count);

        if (n != null) {

          i = new Item();
          ItemHandler.initialize_item_containers(i);
          CategoryHandler.initialize_item(i, n);

          if (i != null) {

            name = MapHandler.get_map_element(i.items, CategoryHandler.NAME);
            MapHandler.set_map_element(p0, name, i);

            /*??
                                    // Initialize serialized item.
                                    i = n.getNodeValue();
            */

          } else {

            LogHandler.log(
                LogHandler.ERROR_LOG_LEVEL, "Could not initialize items. An item is null.");
          }

        } else {

          LogHandler.log(
              LogHandler.INFO_LOG_LEVEL,
              "Could not initialize items. The category item node is null.");
        }

        count++;
      }

    } else {

      LogHandler.log(
          LogHandler.ERROR_LOG_LEVEL,
          "Could not initialize items. The category items list is null.");
    }
  }
  /**
   * Initializes the java object attributes.
   *
   * @param p0 the attribute items
   * @param p1 the attributes map
   */
  static void initialize_java_object_attributes(java.lang.Object p0, java.lang.Object p1) {

    LogHandler.log(LogHandler.INFO_LOG_LEVEL, "Initialize java object attributes.");
    java.lang.Object a = null;

    a = CategoryHandler.read_attribute(p1, CategoryHandler.CATEGORY);
    MapHandler.set_map_element(p0, CategoryHandler.CATEGORY, a);

    a = CategoryHandler.read_attribute(p1, JavaObjectHandler.NAME);
    MapHandler.set_map_element(p0, JavaObjectHandler.NAME, a);

    a = CategoryHandler.read_attribute(p1, JavaObjectHandler.WIDTH);
    MapHandler.set_map_element(p0, JavaObjectHandler.WIDTH, a);

    a = CategoryHandler.read_attribute(p1, JavaObjectHandler.HEIGHT);
    MapHandler.set_map_element(p0, JavaObjectHandler.HEIGHT, a);

    a = CategoryHandler.read_attribute(p1, JavaObjectHandler.KEY_BINDING);
    MapHandler.set_map_element(p0, JavaObjectHandler.KEY_BINDING, a);
  }
  /**
   * Reads the document.
   *
   * @param p0 the category
   * @param p1 the document
   */
  static void read_document(java.lang.Object p0, java.lang.Object p1) throws java.lang.Exception {

    org.apache.xerces.dom.DocumentImpl doc = (org.apache.xerces.dom.DocumentImpl) p1;

    if (doc != null) {

      LogHandler.log(LogHandler.INFO_LOG_LEVEL, "Read document.");
      doc.normalize();
      org.apache.xerces.dom.DeepNodeListImpl l = null;

      if (p0 != null) {

        l =
            (org.apache.xerces.dom.DeepNodeListImpl)
                doc.getElementsByTagName(CategoryHandler.SUPER_CATEGORY);
        CategoryHandler.initialize_super_category(p0, l);

        l =
            (org.apache.xerces.dom.DeepNodeListImpl)
                doc.getElementsByTagName(CategoryHandler.JAVA_OBJECT);
        CategoryHandler.initialize_java_objects(p0, l);

        l = (org.apache.xerces.dom.DeepNodeListImpl) doc.getElementsByTagName(CategoryHandler.ITEM);
        CategoryHandler.initialize_items(((Item) p0).items, l);

      } else {

        LogHandler.log(
            LogHandler.ERROR_LOG_LEVEL, "Could not read document. The category is null.");
      }

    } else {

      LogHandler.log(LogHandler.ERROR_LOG_LEVEL, "Could not read document. The document is null.");
    }
  }
  /**
   * Initializes the category.
   *
   * <p>Reads the file of the given category.
   *
   * @param p0 the category
   * @param p1 the category name
   */
  static void initialize_category(java.lang.Object p0, java.lang.Object p1)
      throws java.lang.Exception {

    org.apache.xerces.parsers.DOMParser p =
        (org.apache.xerces.parsers.DOMParser) CategoryHandler.xml_parser;

    if (p != null) {

      LogHandler.log(LogHandler.INFO_LOG_LEVEL, "Initialize category: " + p1);
      p.parse(CategoryHandler.PATH + p1 + CategoryHandler.CYBOL);
      CategoryHandler.read_document(p0, (org.apache.xerces.dom.DocumentImpl) p.getDocument());

    } else {

      LogHandler.log(
          LogHandler.ERROR_LOG_LEVEL,
          "Could not initialize category elements. The xml parser is null.");
    }
  }