|  |  | @ -10,15 +10,14 @@ import java.util.Set; | 
			
		
	
		
		
			
				
					
					|  |  |  | /** |  |  |  | /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  * The table of contents of the book. |  |  |  |  * 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. |  |  |  |  * 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. |  |  |  |  * 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. |  |  |  |  * 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 the spine for the complete list of sections in the order in which they should be read. | 
			
		
	
		
		
			
				
					
					|  |  |  |  * |  |  |  |  * | 
			
		
	
		
		
			
				
					
					|  |  |  |  * @see Spine |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |  * |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |  * @author paul |  |  |  |  * @author paul | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  * @see Spine | 
			
		
	
		
		
			
				
					
					|  |  |  |  */ |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  | public class TableOfContents implements Serializable { |  |  |  | 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. |  |  |  |      * Calls addTOCReferenceAtLocation after splitting the path using the DEFAULT_PATH_SEPARATOR. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @return the new TOCReference |  |  |  |      * @return the new TOCReference | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     @SuppressWarnings("unused") |  |  |  |     @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. |  |  |  |      * Adds the given Resources to the TableOfContents at the location specified by the pathElements. | 
			
		
	
		
		
			
				
					
					|  |  |  |    * |  |  |  |      * <p> | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |      * Example: |  |  |  |      * Example: | 
			
		
	
		
		
			
				
					
					|  |  |  |      * Calling this method with a Resource and new String[] {"chapter1", "paragraph1"} will result in the following: |  |  |  |      * Calling this method with a Resource and new String[] {"chapter1", "paragraph1"} will result in the following: | 
			
		
	
		
		
			
				
					
					|  |  |  |      * <ul> |  |  |  |      * <ul> | 
			
		
	
	
		
		
			
				
					|  |  | @ -120,7 +120,7 @@ public class TableOfContents implements Serializable { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |      * Adds the given Resources to the TableOfContents at the location specified by the pathElements. |  |  |  |      * Adds the given Resources to the TableOfContents at the location specified by the pathElements. | 
			
		
	
		
		
			
				
					
					|  |  |  |    * |  |  |  |      * <p> | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |      * Example: |  |  |  |      * Example: | 
			
		
	
		
		
			
				
					
					|  |  |  |      * Calling this method with a Resource and new int[] {0, 0} will result in the following: |  |  |  |      * Calling this method with a Resource and new int[] {0, 0} will result in the following: | 
			
		
	
		
		
			
				
					
					|  |  |  |      * <ul> |  |  |  |      * <ul> | 
			
		
	
	
		
		
			
				
					|  |  | @ -209,8 +209,11 @@ public class TableOfContents implements Serializable { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return result; |  |  |  |         return result; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   private static void getAllUniqueResources(Set<String> uniqueHrefs, |  |  |  |     private static void getAllUniqueResources( | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       List<Resource> result, List<TOCReference> tocReferences) { |  |  |  |             Set<String> uniqueHrefs, | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             List<Resource> result, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             List<TOCReference> tocReferences | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     ) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         for (TOCReference tocReference : tocReferences) { |  |  |  |         for (TOCReference tocReference : tocReferences) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             Resource resource = tocReference.getResource(); |  |  |  |             Resource resource = tocReference.getResource(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (resource != null && !uniqueHrefs.contains(resource.getHref())) { |  |  |  |             if (resource != null && !uniqueHrefs.contains(resource.getHref())) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -240,6 +243,7 @@ public class TableOfContents implements Serializable { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |      * The maximum depth of the reference tree |  |  |  |      * The maximum depth of the reference tree | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @return The maximum depth of the reference tree |  |  |  |      * @return The maximum depth of the reference tree | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     public int calculateDepth() { |  |  |  |     public int calculateDepth() { | 
			
		
	
	
		
		
			
				
					|  |  | 
 |