|
|
|
@ -10,15 +10,14 @@ import java.util.Set; |
|
|
|
|
/** |
|
|
|
|
* The table of contents of the book. |
|
|
|
|
* The TableOfContents is a tree structure at the root it is a list of TOCReferences, each if which may have as children another list of TOCReferences. |
|
|
|
|
* |
|
|
|
|
* <p> |
|
|
|
|
* The table of contents is used by epub as a quick index to chapters and sections within chapters. |
|
|
|
|
* It may contain duplicate entries, may decide to point not to certain chapters, etc. |
|
|
|
|
* |
|
|
|
|
* <p> |
|
|
|
|
* See the spine for the complete list of sections in the order in which they should be read. |
|
|
|
|
* |
|
|
|
|
* @see Spine |
|
|
|
|
* |
|
|
|
|
* @author paul |
|
|
|
|
* @see Spine |
|
|
|
|
*/ |
|
|
|
|
public class TableOfContents implements Serializable { |
|
|
|
|
|
|
|
|
@ -46,6 +45,7 @@ public class TableOfContents implements Serializable { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Calls addTOCReferenceAtLocation after splitting the path using the DEFAULT_PATH_SEPARATOR. |
|
|
|
|
* |
|
|
|
|
* @return the new TOCReference |
|
|
|
|
*/ |
|
|
|
|
@SuppressWarnings("unused") |
|
|
|
@ -86,7 +86,7 @@ public class TableOfContents implements Serializable { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Adds the given Resources to the TableOfContents at the location specified by the pathElements. |
|
|
|
|
* |
|
|
|
|
* <p> |
|
|
|
|
* Example: |
|
|
|
|
* Calling this method with a Resource and new String[] {"chapter1", "paragraph1"} will result in the following: |
|
|
|
|
* <ul> |
|
|
|
@ -120,7 +120,7 @@ public class TableOfContents implements Serializable { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Adds the given Resources to the TableOfContents at the location specified by the pathElements. |
|
|
|
|
* |
|
|
|
|
* <p> |
|
|
|
|
* Example: |
|
|
|
|
* Calling this method with a Resource and new int[] {0, 0} will result in the following: |
|
|
|
|
* <ul> |
|
|
|
@ -209,8 +209,11 @@ public class TableOfContents implements Serializable { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void getAllUniqueResources(Set<String> uniqueHrefs, |
|
|
|
|
List<Resource> result, List<TOCReference> tocReferences) { |
|
|
|
|
private static void getAllUniqueResources( |
|
|
|
|
Set<String> uniqueHrefs, |
|
|
|
|
List<Resource> result, |
|
|
|
|
List<TOCReference> tocReferences |
|
|
|
|
) { |
|
|
|
|
for (TOCReference tocReference : tocReferences) { |
|
|
|
|
Resource resource = tocReference.getResource(); |
|
|
|
|
if (resource != null && !uniqueHrefs.contains(resource.getHref())) { |
|
|
|
@ -240,6 +243,7 @@ public class TableOfContents implements Serializable { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* The maximum depth of the reference tree |
|
|
|
|
* |
|
|
|
|
* @return The maximum depth of the reference tree |
|
|
|
|
*/ |
|
|
|
|
public int calculateDepth() { |
|
|
|
|