Package org.apache.maven.doxia.index
Class IndexEntry
- java.lang.Object
-
- org.apache.maven.doxia.index.IndexEntry
-
public class IndexEntry extends java.lang.ObjectRepresenting the index tree within a document with the most important metadata per entry. Currently this only contains entries for sections, but in the future may be extended, therefore it is recommended to usegetType()to filter out irrelevant entries.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIndexEntry.Type
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<IndexEntry>childEntriesThe child entries.private booleanhasAnchortrue if there is already an anchor for thisprivate java.lang.StringidThe id of the entry.private IndexEntryparentThe parent entry.private java.lang.StringtitleThe entry title.private IndexEntry.TypetypeThe type of the entry, one of the types defined byIndexingSink
-
Constructor Summary
Constructors Constructor Description IndexEntry(java.lang.String newId)Constructor for root entry.IndexEntry(IndexEntry newParent, java.lang.String newId)Constructor.IndexEntry(IndexEntry newParent, java.lang.String newId, IndexEntry.Type type)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.util.List<IndexEntry>getChildEntries()Returns an unmodifiableList of the child entries.IndexEntrygetFirstEntry()Returns the first entry.java.lang.StringgetId()Returns the id.IndexEntrygetLastEntry()Returns the last entry.IndexEntrygetNextEntry()Returns the next entry.IndexEntrygetParent()Returns the parent entry.IndexEntrygetPrevEntry()Returns the previous entry.IndexEntrygetRootEntry()Returns the root entry.java.lang.StringgetTitle()Returns the title.IndexEntry.TypegetType()Returns the type of this entry.booleanhasAnchor()Returns if the entry's id already has an anchor in the underlying document.inthashCode()booleanhasId()Returns if the entry has an id.voidsetAnchor(boolean hasAnchor)Set if the entry's id already has an anchor in the underlying document.voidsetChildEntries(java.util.List<IndexEntry> entries)Sets the child entries or creates a new ArrayList if entries == null.protected voidsetId(java.lang.String id)Set the id.voidsetTitle(java.lang.String newTitle)Sets the title.java.lang.StringtoString()Returns a string representation of the object.java.lang.StringtoString(int depth)Returns a string representation of all objects to the given depth.
-
-
-
Field Detail
-
parent
private final IndexEntry parent
The parent entry.
-
id
private java.lang.String id
The id of the entry.
-
hasAnchor
private boolean hasAnchor
true if there is already an anchor for this
-
title
private java.lang.String title
The entry title.
-
childEntries
private java.util.List<IndexEntry> childEntries
The child entries.
-
type
private final IndexEntry.Type type
The type of the entry, one of the types defined byIndexingSink
-
-
Constructor Detail
-
IndexEntry
public IndexEntry(java.lang.String newId)
Constructor for root entry.- Parameters:
newId- The id. May be null.
-
IndexEntry
public IndexEntry(IndexEntry newParent, java.lang.String newId)
Constructor.- Parameters:
newParent- The parent. May be null.newId- The id. May be null.
-
IndexEntry
public IndexEntry(IndexEntry newParent, java.lang.String newId, IndexEntry.Type type)
Constructor.- Parameters:
newParent- The parent. May be null.newId- The id. May be null.type- The type. Cannot be null.
-
-
Method Detail
-
getParent
public IndexEntry getParent()
Returns the parent entry.- Returns:
- the parent entry.
-
getId
public java.lang.String getId()
Returns the id.- Returns:
- the id.
-
hasId
public boolean hasId()
Returns if the entry has an id.- Returns:
trueif the entry has a valid id, otherwise it can be considered invalid/empty.
-
setId
protected void setId(java.lang.String id)
Set the id.- Parameters:
id- the id- Since:
- 1.1.2
-
getType
public IndexEntry.Type getType()
Returns the type of this entry. Is one of the types defined byIndexingSink.- Returns:
- the type of this entry
- Since:
- 2.0.0
-
setAnchor
public void setAnchor(boolean hasAnchor)
Set if the entry's id already has an anchor in the underlying document.- Parameters:
hasAnchor-trueif the id already has an anchor.- Since:
- 2.0.0
-
hasAnchor
public boolean hasAnchor()
Returns if the entry's id already has an anchor in the underlying document.- Returns:
trueif the id already has an anchor otherwisefalse.- Since:
- 2.0.0
-
getTitle
public java.lang.String getTitle()
Returns the title.- Returns:
- the title (may be
null).
-
setTitle
public void setTitle(java.lang.String newTitle)
Sets the title.- Parameters:
newTitle- the title.
-
getChildEntries
public java.util.List<IndexEntry> getChildEntries()
Returns an unmodifiableList of the child entries.- Returns:
- child entries.
-
setChildEntries
public void setChildEntries(java.util.List<IndexEntry> entries)
Sets the child entries or creates a new ArrayList if entries == null.- Parameters:
entries- the entries.
-
getNextEntry
public IndexEntry getNextEntry()
Returns the next entry.- Returns:
- the next entry, or null if there is none.
-
getPrevEntry
public IndexEntry getPrevEntry()
Returns the previous entry.- Returns:
- the previous entry, or null if there is none.
-
getFirstEntry
public IndexEntry getFirstEntry()
Returns the first entry.- Returns:
- the first entry, or null if there is none.
-
getLastEntry
public IndexEntry getLastEntry()
Returns the last entry.- Returns:
- the last entry, or null if there is none.
-
getRootEntry
public IndexEntry getRootEntry()
Returns the root entry.- Returns:
- the root entry, or null if there is none.
-
toString
public java.lang.String toString()
Returns a string representation of the object.- Overrides:
toStringin classjava.lang.Object- Returns:
- Returns a string representation of all objects
-
toString
public java.lang.String toString(int depth)
Returns a string representation of all objects to the given depth.- Parameters:
depth- The depth to descent to.- Returns:
- A string.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-