Package edu.odu.cs.cowem.documents
Class WebsiteProject
- java.lang.Object
-
- edu.odu.cs.cowem.documents.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.StringdocumentSetGroup(java.lang.String documentSet)The name of the group to which a document set belongs.java.io.FiledocumentSetLocation(java.lang.String documentSet)The location of a document set.java.io.FiledocumentSource(java.lang.String documentName)Source file from which we obtain a named document.java.lang.StringgetCourseName()A short name for this course.java.lang.StringgetDocumentTitle(java.lang.String documentName)Title within a named document.java.lang.StringgetExternalSite(java.lang.String siteName)java.io.FilegetRootDir()Get the root directory.java.util.Iterator<java.lang.String>iterator()Iterate through all document sets.java.nio.file.PathrelativePathToDocumentSet(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.PathrelativePathToRoot(java.io.File from)Determine the relative path from some file to the project root.voidsetCourseName(java.lang.String cname)Save a short name for the course, after replacing any non-URL-safe characters.voidsetImports(java.util.Map<java.lang.String,java.lang.String> importedSites)java.lang.StringtoString()Printable summary of project.
-
-
-
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:
iteratorin interfacejava.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:
toStringin classjava.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
-
-