Class WebsiteProject

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.String>

    public class WebsiteProject
    extends java.lang.Object
    implements java.lang.Iterable<java.lang.String>
    Directory layout of a website project. Allows easy access to groups, document sets, and the generation of relative paths among them.
    • Constructor Summary

      Constructors 
      Constructor Description
      WebsiteProject​(java.io.File rootDirectory)
      Create a project summary object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String documentSetGroup​(java.lang.String documentSet)
      The name of the group to which a document set belongs.
      java.io.File documentSetLocation​(java.lang.String documentSet)
      The location of a document set.
      java.io.File documentSource​(java.lang.String documentName)
      Source file from which we obtain a named document.
      java.lang.String getCourseName()
      A short name for this course.
      java.lang.String getDocumentTitle​(java.lang.String documentName)
      Title within a named document.
      java.lang.String getExternalSite​(java.lang.String siteName)  
      java.io.File getRootDir()
      Get the root directory.
      java.util.Iterator<java.lang.String> iterator()
      Iterate through all document sets.
      java.nio.file.Path relativePathToDocumentSet​(java.io.File from, java.lang.String documentSet)
      Compute a relative path from a file to the directory containing some document set.
      java.nio.file.Path relativePathToRoot​(java.io.File from)
      Determine the relative path from some file to the project root.
      void setCourseName​(java.lang.String cname)
      Save a short name for the course, after replacing any non-URL-safe characters.
      void setImports​(java.util.Map<java.lang.String,​java.lang.String> importedSites)  
      java.lang.String toString()
      Printable summary of project.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • WebsiteProject

        public WebsiteProject​(java.io.File rootDirectory)
        Create a project summary object.
        Parameters:
        rootDirectory - location of this project's root
    • Method Detail

      • relativePathToRoot

        public final java.nio.file.Path relativePathToRoot​(java.io.File from)
        Determine the relative path from some file to the project root.
        Parameters:
        from - a file that is a descendant of the project root.
        Returns:
        the relative path from some file to the project root or null if no such relation can be determined.
      • relativePathToDocumentSet

        public final java.nio.file.Path relativePathToDocumentSet​(java.io.File from,
                                                                  java.lang.String documentSet)
        Compute a relative path from a file to the directory containing some document set.
        Parameters:
        from - a file that is descended from the project root.
        documentSet - any document set
        Returns:
        the relative path, or null if no such path can be determined (the file is not descended from the project root or the document set does not exist).
      • documentSetLocation

        public final java.io.File documentSetLocation​(java.lang.String documentSet)
        The location of a document set.
        Parameters:
        documentSet - The name of a document set.
        Returns:
        the location or null if the document set does not exit
      • documentSetGroup

        public final java.lang.String documentSetGroup​(java.lang.String documentSet)
        The name of the group to which a document set belongs.
        Parameters:
        documentSet - name of a document set
        Returns:
        the group name or null if the document set does not exist.
      • iterator

        public final java.util.Iterator<java.lang.String> iterator()
        Iterate through all document sets.
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.String>
        Returns:
        iterator over the document set names.
      • getRootDir

        public final java.io.File getRootDir()
        Get the root directory.
        Returns:
        the root directory.
      • toString

        public final java.lang.String toString()
        Printable summary of project.
        Overrides:
        toString in class java.lang.Object
        Returns:
        summary
      • documentSource

        public java.io.File documentSource​(java.lang.String documentName)
        Source file from which we obtain a named document.
        Parameters:
        documentName - the identifier for the document (primary or secondary)
        Returns:
        the .md or .mmd file containing the document source
      • getDocumentTitle

        public java.lang.String getDocumentTitle​(java.lang.String documentName)
        Title within a named document.
        Parameters:
        documentName - the identifier for the document (primary or secondary)
        Returns:
        the contents of the "Title:" metadata line or null if no such line
      • setImports

        public void setImports​(java.util.Map<java.lang.String,​java.lang.String> importedSites)
      • getExternalSite

        public java.lang.String getExternalSite​(java.lang.String siteName)
      • setCourseName

        public void setCourseName​(java.lang.String cname)
        Save a short name for the course, after replacing any non-URL-safe characters.
        Parameters:
        cname - a short name for this course.
      • getCourseName

        public java.lang.String getCourseName()
        A short name for this course.
        Returns:
        the course name