org.eclipse.mylyn.wikitext.core.parser.outline
Class OutlineItem

java.lang.Object
  extended by org.eclipse.mylyn.wikitext.core.parser.outline.OutlineItem
Direct Known Subclasses:
SplitOutlineItem

public class OutlineItem
extends Object

An item in a document outline. A document outline reflects the heading structure of the document. Generally there is always a root item that represents the document itself. Every level-1 heading becomes a child item of the root.

Since:
1.0
Author:
David Green

Nested Class Summary
static interface OutlineItem.Visitor
           
 
Constructor Summary
OutlineItem(OutlineItem parent, int level, String id, int offset, int length, String label)
           
 
Method Summary
 void accept(OutlineItem.Visitor visitor)
           
 void clear()
           
 boolean contains(OutlineItem item)
          Indicate if this outline item contains the given outline item.
 int distance(int offset)
           
 boolean equals(Object obj)
           
 OutlineItem findItemById(String id)
           
 OutlineItem findNearestMatchingOffset(int offset)
           
 List<OutlineItem> getChildren()
           
 String getId()
          the id of the heading, which is typically (though not guaranteed to be) unique within a document.
 String getKind()
           
 String getLabel()
          the text of the heading which could be truncated
 int getLength()
          get the length of the outline item, which corresponds to the length of the heading text.
 int getLevel()
          the level of the document which is positive and usually <= 6 except for the root item where the value is undefined.
 int getOffset()
           
 OutlineItem getParent()
           
 OutlineItem getPrevious()
          Get the previous item.
 String getResourcePath()
          the resource path to the resource of this outline item
 int getSectionLength()
          get the length of the section, which is the length of the heading text plus the length of any following content up to the next peer-leveled heading or the parent's following sibling.
 String getTooltip()
           
 int hashCode()
           
 boolean isRootItem()
          indicate if this is the root item (that is, the item representing the whole document)
 void moveChildren(OutlineItem otherParent)
          move children from the given outline item to this
 void setKind(String kind)
           
 void setLabel(String label)
           
 void setResourcePath(String resourcePath)
          the resource path to the resource of this outline item
 void setTooltip(String tooltip)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OutlineItem

public OutlineItem(OutlineItem parent,
                   int level,
                   String id,
                   int offset,
                   int length,
                   String label)
Method Detail

getLength

public int getLength()
get the length of the outline item, which corresponds to the length of the heading text. The length does not include content following the heading text itself.

See Also:
getSectionLength()

getSectionLength

public int getSectionLength()
get the length of the section, which is the length of the heading text plus the length of any following content up to the next peer-leveled heading or the parent's following sibling.

See Also:
getLength()

getKind

public String getKind()

setKind

public void setKind(String kind)

getLabel

public String getLabel()
the text of the heading which could be truncated


getId

public String getId()
the id of the heading, which is typically (though not guaranteed to be) unique within a document. Heading ids may be used as the target of document-relative anchors


getLevel

public int getLevel()
the level of the document which is positive and usually <= 6 except for the root item where the value is undefined.


setLabel

public void setLabel(String label)

getParent

public OutlineItem getParent()

isRootItem

public boolean isRootItem()
indicate if this is the root item (that is, the item representing the whole document)


getPrevious

public OutlineItem getPrevious()
Get the previous item. The order of the items is determined via document order traversal of all nodes in the outline.

Returns:
the previous item or null if there is no previous (ie: the root item).

getChildren

public List<OutlineItem> getChildren()

getOffset

public int getOffset()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

clear

public void clear()

findNearestMatchingOffset

public OutlineItem findNearestMatchingOffset(int offset)

findItemById

public OutlineItem findItemById(String id)

distance

public int distance(int offset)

accept

public void accept(OutlineItem.Visitor visitor)

setTooltip

public void setTooltip(String tooltip)

getTooltip

public String getTooltip()

getResourcePath

public String getResourcePath()
the resource path to the resource of this outline item

Returns:
the resource path, or null if it's unknown.

setResourcePath

public void setResourcePath(String resourcePath)
the resource path to the resource of this outline item

Parameters:
resourcePath - the resource path, or null if it's unknown.

moveChildren

public void moveChildren(OutlineItem otherParent)
move children from the given outline item to this


contains

public boolean contains(OutlineItem item)
Indicate if this outline item contains the given outline item. The computation uses outline item offsets (the offset and section length.

Returns:
true if and only if the offsets of the provided item lie within the offsets of this outline item.

toString

public String toString()
Overrides:
toString in class Object
Since:
1.1


Copyright © 2011 FuseSource, Corp.. All Rights Reserved.