Class NatureHelper.ProjectHandler

  • Enclosing class:
    NatureHelper

    private static class NatureHelper.ProjectHandler
    extends java.lang.Object
    Implements core functionality accessing the project file. May also be implemented in NatureHelper but shall exhibit now the responsibilities.
    Author:
    Holger Eichelberger
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.xml.parsers.DocumentBuilder dBuilder  
      private org.w3c.dom.Document doc  
      private java.io.File file  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ProjectHandler​(java.io.File project)
      Creates a handler.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private org.w3c.dom.Node addNature​(org.w3c.dom.Node node, java.lang.String nature)
      Adds a nature to node regardless whether it already exists.
      private org.w3c.dom.Node addNatureSection()
      Add nature-section regardless whether it exists.
      private org.w3c.dom.NodeList getNatures()
      Returns the natures node.
      private void writeBack()
      Writes back a modified file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • file

        private java.io.File file
      • dBuilder

        private javax.xml.parsers.DocumentBuilder dBuilder
      • doc

        private org.w3c.dom.Document doc
    • Constructor Detail

      • ProjectHandler

        private ProjectHandler​(java.io.File project)
                        throws java.io.IOException
        Creates a handler.
        Parameters:
        project - the project folder
        Throws:
        java.io.IOException - in case that opening the project file fails for some reason
    • Method Detail

      • getNatures

        private org.w3c.dom.NodeList getNatures()
        Returns the natures node.
        Returns:
        the natures node
      • writeBack

        private void writeBack()
                        throws java.io.IOException
        Writes back a modified file.
        Throws:
        java.io.IOException - in case that writing back the file fails
      • addNatureSection

        private org.w3c.dom.Node addNatureSection()
        Add nature-section regardless whether it exists.
        Returns:
        the node representing the new nature section
      • addNature

        private org.w3c.dom.Node addNature​(org.w3c.dom.Node node,
                                           java.lang.String nature)
        Adds a nature to node regardless whether it already exists.
        Parameters:
        node - the node to add the nature to
        nature - the nature
        Returns:
        the node representing the nature entry