Class FormulaElement
java.lang.Object
org.pentaho.openformula.ui.model2.FormulaElement
- All Implemented Interfaces:
Element
- Direct Known Subclasses:
FormulaClosingParenthesisElement,FormulaOpenParenthesisElement,FormulaOperatorElement,FormulaRootElement,FormulaSemicolonElement,FormulaTextElement
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFormulaElement(FormulaDocument document, FormulaRootElement parentElement) -
Method Summary
Modifier and TypeMethodDescriptionFetches the collection of attributes this element contains.Fetches the document associated with this element.getElement(int index) Fetches the child element at the given index.intGets the number of child elements contained by this element.intgetElementIndex(int offset) Gets the child element index closest to the given offset.intFetches the offset from the beginning of the document that this element ends at.Fetches the parent element.intFetches the offset from the beginning of the document that this element begins at.abstract StringgetText()booleanisLeaf()Is this element a leaf element? An element that may have children, even if it currently has no children, would returnfalse.voidsetEndOffset(int endOffset) voidsetStartOffset(int startOffset)
-
Constructor Details
-
FormulaElement
-
-
Method Details
-
setEndOffset
public void setEndOffset(int endOffset) -
setStartOffset
public void setStartOffset(int startOffset) -
getText
-
getDocument
Fetches the document associated with this element.- Specified by:
getDocumentin interfaceElement- Returns:
- the document
-
getParentElement
Fetches the parent element. If the element is a root level element returnsnull.- Specified by:
getParentElementin interfaceElement- Returns:
- the parent element
-
getAttributes
Fetches the collection of attributes this element contains.- Specified by:
getAttributesin interfaceElement- Returns:
- the attributes for the element
-
getStartOffset
public int getStartOffset()Fetches the offset from the beginning of the document that this element begins at. If this element has children, this will be the offset of the first child. As a document position, there is an implied forward bias.- Specified by:
getStartOffsetin interfaceElement- Returns:
- the starting offset >= 0 and < getEndOffset();
- See Also:
-
getEndOffset
public int getEndOffset()Fetches the offset from the beginning of the document that this element ends at. If this element has children, this will be the end offset of the last child. As a document position, there is an implied backward bias. All the defaultDocumentimplementations descend fromAbstractDocument.AbstractDocumentmodels an implied break at the end of the document. As a result of this, it is possible for this to return a value greater than the length of the document.- Specified by:
getEndOffsetin interfaceElement- Returns:
- the ending offset > getStartOffset() and <= getDocument().getLength() + 1
- See Also:
-
getElementIndex
public int getElementIndex(int offset) Gets the child element index closest to the given offset. The offset is specified relative to the beginning of the document. Returns-1if theElementis a leaf, otherwise returns the index of theElementthat best represents the given location. Returns0if the location is less than the start offset. ReturnsgetElementCount() - 1if the location is greater than or equal to the end offset.- Specified by:
getElementIndexin interfaceElement- Parameters:
offset- the specified offset >= 0- Returns:
- the element index >= 0
-
getElementCount
public int getElementCount()Gets the number of child elements contained by this element. If this element is a leaf, a count of zero is returned.- Specified by:
getElementCountin interfaceElement- Returns:
- the number of child elements >= 0
-
getElement
Fetches the child element at the given index.- Specified by:
getElementin interfaceElement- Parameters:
index- the specified index >= 0- Returns:
- the child element
-
isLeaf
public boolean isLeaf()Is this element a leaf element? An element that may have children, even if it currently has no children, would returnfalse.
-