de.vc.jfo

## Class FormattingObject

- java.lang.Object
- - de.vc.xml.AbstractNode
  - - de.vc.xml.AbstractNodeWithAttributes
    - - de.vc.jfo.FormattingObject

- All Implemented Interfaces:
    Node, NodeElement, java.io.Serializable, java.lang.Cloneable
  Direct Known Subclasses:
    ColorProfile, Declarations, Document, FlowObject, LayoutMasterSet, PageMasterReference, PageSequence, PageSequenceMaster, RegionAfter, RegionBefore, RegionBody, RegionEnd, RegionStart, RepeatablePageMasterAlternatives, SimplePageMaster, SwappingFObj, Title

      public abstract class FormattingObject
      extends AbstractNodeWithAttributes

  This is the super class of all formatting objects.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static FormattingObject[]` | `EMPTY_ARRAY`

    - ### Fields inherited from class de.vc.xml.AbstractNodeWithAttributes

      `MAP_TYPE_FLYWEIGHT, MAP_TYPE_HASH`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `FormattingObject(java.lang.String tag)`
    `protected` | `FormattingObject(java.lang.String tag, FormattingObject parent)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addElement(int index, java.lang.Object e)` Adds a node element at `index` to this node.
    `void` | `addElement(java.lang.Object e)` Adds a node element to this node.
    `boolean` | `addUnsafe(int idx, java.lang.Object element)` Adds a NodeElement to this FormattingObject at a given index.
    `boolean` | `addUnsafe(java.lang.Object element)` Adds a NodeElement to this FormattingObject.
    `java.lang.Object` | `clone()` Clones this element.
    `protected static FormattingObject` | `cloned(FormattingObject o, Node cloneParent)` Clones a formatting object and sets it's parent node.
    `protected java.util.List` | `clonedList(java.util.List list, Node parent)` Clones a list of nodes and formatting objects and sets the parent of cloned nodes.
    `java.lang.String` | `createUniqueID()` Creates and sets an unique ID for this formatting object.
    `protected java.lang.Object` | `doGetAttribute(java.lang.String name)` Overrides doGetAttribute of AbstractNode.
    `protected boolean` | `doSetAttribute(java.lang.String name, java.lang.Object value)` Overrides doSetAttribute of AbstractNode.
    `int` | `elementCount()` Gets the number of elements in content.
    `java.lang.Object` | `get(int idx)` Gets an element of the content.
    `protected AbsolutePosition` | `getAbsolutePosition()` Gets the absolute position of this fo.
    `protected Accessibility` | `getAccessibility()` Gets the accessibilty of this fo.
    `java.util.Map<java.lang.String,java.lang.Object>` | `getAttributeMap()` Gets a map of all defined attributes.
    `protected Background` | `getBackground()` Gets the background of this fo.
    `protected Border` | `getBorder()` Gets the border of this fo.
    `java.util.Set<java.lang.String>` | `getDefinedAttributes()`
    `Document` | `getDocument()` Returns the document that contains this formatting object or NULL if this object is not assigned to a document.
    `FontSupport` | `getFont()` Gets the font-support of this fo.
    `java.lang.String` | `getID()` Gets the ID of this formatting object.
    `java.lang.String` | `getLanguage()`
    `protected org.apache.commons.logging.Log` | `getLogger()` Gets the core logger of jFO.
    `protected Margin` | `getMargin()` Gets the margin of this fo.
    `protected Measure` | `getMeasureValue(java.lang.String name)` Gets a value as a measure.
    `protected java.lang.Object` | `getObjectValue(java.lang.String key, boolean deep, java.lang.Class<?> objClass)`
    `protected java.lang.Object` | `getObjectValue(java.lang.String key, boolean deep, java.lang.Class<?> objClass, java.lang.Object defaultObject)`
    `protected java.lang.Object` | `getObjectValue(java.lang.String key, java.lang.Class<?> objClass)`
    `protected java.lang.Object` | `getObjectValue(java.lang.String key, java.lang.Class<?> objClass, java.lang.Object defaultObject)`
    `int` | `getOrphans()` Gets the number of orphans.
    `protected Padding` | `getPadding()` Gets the padding of this fo.
    `FormattingObject` | `getParentFO()` Gets the parent formatting object of this.
    `protected RelativePosition` | `getRelativePosition()` Gets the relative position of this fo.
    `int` | `getWidows()` Gets the number of widows.
    `protected boolean` | `hasBorder()` Returns true if at least one border attribute is set.
    `boolean` | `hasID()` Determinates, if this formatting object. has an ID.
    `protected boolean` | `hasPadding()` Returns true if at least one padding attribute is set.
    `boolean` | `isEmpty()` Tests, if the content is empty (has no elements).
    `boolean` | `isHyphenation()`
    `java.lang.Object` | `removeElement(int i)` Removes an element from this node.
    `boolean` | `removeElement(java.lang.Object e)` Removes an element from this node.
    `boolean` | `replaceElement(java.lang.Object oldElement, java.lang.Object newElement)` Replaces an element.
    `protected void` | `setAbsolutePosition(AbsolutePosition pos)` Sets the absolute position of this fo.
    `protected void` | `setAccessibility(Accessibility access)` Sets the accessibility of this fo.
    `protected void` | `setAttribute(boolean enabled, java.lang.String name, java.lang.String value)`
    `void` | `setAttribute(java.lang.String name, boolean value)` Sets a value.
    `void` | `setAttribute(java.lang.String name, java.awt.Color value)` Sets a value.
    `void` | `setAttribute(java.lang.String name, double value)` Sets an attribute.
    `void` | `setAttribute(java.lang.String name, int value)` Sets an attribute.
    `protected void` | `setBackground(Background bg)` Sets the background of this fo.
    `protected void` | `setBorder(Border border)` Sets the border of this fo.
    `java.lang.Object` | `setElement(int index, java.lang.Object e)` Replaces a node element at `index` of this node.
    `void` | `setFont(FontSupport fs)` Sets the FontSupport of this fo.
    `void` | `setHyphenation(boolean hyphenate)`
    `void` | `setID(java.lang.String id)` Sets the ID of this formatting object.
    `void` | `setLanguage(java.util.Locale locale)`
    `void` | `setLanguage(java.lang.String lang)`
    `protected void` | `setMargin(Margin margin)` Sets the margin of this fo.
    `void` | `setOrphans(int orphans)` Sets the number of orphans.
    `protected void` | `setPadding(Padding padding)` Sets the padding of this fo.
    `protected void` | `setRelativePosition(RelativePosition pos)` Sets the relative position of this fo.
    `void` | `setWidows(int widows)` Sets the number of widows.

    - ### Methods inherited from class de.vc.xml.AbstractNodeWithAttributes

      `getDefaultMapType, setDefaultMapType`

    - ### Methods inherited from class de.vc.xml.AbstractNode

      `addAttributeChangeListener, addElements, addElements, clearEqualAttributes, clearInheratedAttribute, clearInheratedAttributes, clearValue, contains, contains, copyAttributes, createID, findFirstNodeWithText, findNode, findNodesWithText, fire, fireSaxEvents, firstElement, getAttrAsBoolean, getAttrAsInteger, getAttrAsString, getAttrAsString, getAttribute, getAttribute, getAttributeMap, getContentText, getContentText, getDefinedAttributes, getElements, getElements, getElements, getElements, getFirstElement, getIndex, getLocalName, getNamespacePrefix, getNamespacePrefixes, getNamespaceURI, getParent, getParent, getParent, getParentOrThis, getQName, getRoot, hasEqualAttrs, indexOf, lastElement, liftInheritedAttribute, removeAttributeChangeListener, setAttribute, setAttributes, setAttrIfNotNull, setEnableAttributeChangeEvent, setNamespace, setParent, setQName, setUndefinedAttributes, writeTo, writeTo, writeTo, writeTo`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### EMPTY_ARRAY

          public static final FormattingObject[] EMPTY_ARRAY

  - ### Constructor Detail

    - #### FormattingObject

          protected FormattingObject(java.lang.String tag)

    - #### FormattingObject

          protected FormattingObject(java.lang.String tag,
                          FormattingObject parent)

  - ### Method Detail

    - #### getDefinedAttributes

          public java.util.Set<java.lang.String> getDefinedAttributes()

      Overrides:
        `getDefinedAttributes` in class `AbstractNodeWithAttributes`

    - #### getAttributeMap

          public java.util.Map<java.lang.String,java.lang.Object> getAttributeMap()

      Description copied from class: `AbstractNode`
      Gets a map of all defined attributes.
      Specified by:
        `getAttributeMap` in interface `Node`
      Overrides:
        `getAttributeMap` in class `AbstractNodeWithAttributes`
      Returns:
        Map of attributes.

    - #### isEmpty

          public boolean isEmpty()

      Tests, if the content is empty (has no elements).
      Specified by:
        `isEmpty` in interface `Node`
      Overrides:
        `isEmpty` in class `AbstractNode`
      Returns:
        true, if content is empty.

    - #### elementCount

          public int elementCount()

      Gets the number of elements in content.
      Returns:
        Number of elements.

    - #### get

          public java.lang.Object get(int idx)

      Gets an element of the content.
      Parameters:
        `idx` - Index of element.
      Returns:
        Element or NULL, if idx out of range.

    - #### getParentFO

          public FormattingObject getParentFO()

      Gets the parent formatting object of this.
      Returns:
        Parent FO.

    - #### setAttribute

          public void setAttribute(java.lang.String name,
                          double value)

      Sets an attribute.
      Parameters:
        `name` - Name of Attribute.
        `value` - Value.

    - #### setAttribute

          public void setAttribute(java.lang.String name,
                          int value)

      Sets an attribute.
      Parameters:
        `name` - Name of Attribute.
        `value` - Value.

    - #### setAttribute

          public void setAttribute(java.lang.String name,
                          boolean value)

      Sets a value.
      Parameters:
        `name` - Name of Attribute.
        `value` - Value.

    - #### setAttribute

          public void setAttribute(java.lang.String name,
                          java.awt.Color value)

      Sets a value.
      Parameters:
        `name` - Name of Attribute.
        `value` - Value.

    - #### hasID

          public boolean hasID()

      Determinates, if this formatting object. has an ID.
      Returns:
        true, if has an ID.

    - #### getID

          public java.lang.String getID()

      Gets the ID of this formatting object. That may be NULL.
      Returns:
        ID of this formatting object.

    - #### setID

          public void setID(java.lang.String id)

      Sets the ID of this formatting object.
      Parameters:
        `id` - New ID.

    - #### createUniqueID

          public java.lang.String createUniqueID()

      Creates and sets an unique ID for this formatting object.
      Returns:
        New ID of this formatting object.

    - #### addElement

          public void addElement(java.lang.Object e)

      Adds a node element to this node.
      Parameters:
        `e` - Node element.
      Throws:
        `java.lang.UnsupportedOperationException` - is throws if no childreen are allowed.
        `java.lang.NullPointerException` - is thrown if `e==null`

    - #### addElement

          public void addElement(int index,
                        java.lang.Object e)

      Adds a node element at `index` to this node.
      Parameters:
        `index` - Index of element.
        `e` - Node element.
      Throws:
        `java.lang.IndexOutOfBoundsException` - is thrown if `index` is out of bounds.
        `java.lang.UnsupportedOperationException` - is throws if no childreen are allowed.
        `java.lang.NullPointerException` - is thrown if `e==null`

    - #### setElement

          public java.lang.Object setElement(int index,
                                    java.lang.Object e)

      Replaces a node element at `index` of this node.
      Parameters:
        `index` - Index of element.
        `e` - Node element.
      Returns:
        Replaced element.
      Throws:
        `java.lang.IndexOutOfBoundsException` - is thrown if `index` is out of bounds.
        `java.lang.UnsupportedOperationException` - is throws if no childreen are allowed.
        `java.lang.NullPointerException` - is thrown if `e==null`

    - #### removeElement

          public boolean removeElement(java.lang.Object e)

      Removes an element from this node.
      Parameters:
        `e` - NodeElement
      Returns:
        `true` if this node contained the specified element.

    - #### removeElement

          public java.lang.Object removeElement(int i)

      Removes an element from this node.
      Parameters:
        `i` - Index of element.
      Returns:
        Removed node element.
      Throws:
        `java.lang.IndexOutOfBoundsException` - is thrown if `index` is out of bounds.

    - #### replaceElement

          public boolean replaceElement(java.lang.Object oldElement,
                               java.lang.Object newElement)

      Replaces an element.
      Parameters:
        `oldElement` - Old element.
        `newElement` - New element.
      Returns:
        `true` if this node contained `oldElement`

    - #### addUnsafe

          public boolean addUnsafe(java.lang.Object element)

      Adds a NodeElement to this FormattingObject. You must ensure, that this FormattingObject can contain given element.
      Parameters:
        `element` - Element.
      Returns:
        `false` if this FO is unable to add object.
      Throws:
        `java.lang.UnsupportedOperationException` - if not supported by this object.

    - #### addUnsafe

          public boolean addUnsafe(int idx,
                          java.lang.Object element)

      Adds a NodeElement to this FormattingObject at a given index. You must ensure, that this FormattingObject can contain given element.
      Parameters:
        `idx` - Index.
        `element` - Element.
      Returns:
        `false` if this FO is unable to add object.
      Throws:
        `java.lang.UnsupportedOperationException` - if not supported by this object.

    - #### getDocument

          public Document getDocument()

      Returns the document that contains this formatting object or NULL if this object is not assigned to a document.
      Returns:
        Document

    - #### setLanguage

          public void setLanguage(java.lang.String lang)

    - #### setLanguage

          public void setLanguage(java.util.Locale locale)

    - #### getLanguage

          public java.lang.String getLanguage()

    - #### setHyphenation

          public void setHyphenation(boolean hyphenate)

    - #### isHyphenation

          public boolean isHyphenation()

    - #### setOrphans

          public void setOrphans(int orphans)

      Sets the number of orphans. If number of orphans is <1 this attribute is cleared.
      Parameters:
        `orphans` - Number of orphans.
      See Also:
        `Attributes.ORPHANS`

    - #### getOrphans

          public int getOrphans()

      Gets the number of orphans.
      Returns:
        Number of orphans (default 2).
      See Also:
        `Attributes.ORPHANS`

    - #### setWidows

          public void setWidows(int widows)

      Sets the number of widows. If number of widows is <1 this attribute is cleared.
      Parameters:
        `widows` - Number of widows.
      See Also:
        `Attributes.WIDOWS`

    - #### getWidows

          public int getWidows()

      Gets the number of widows.
      Returns:
        Number of widows (default 2).
      See Also:
        `Attributes.WIDOWS`

    - #### getFont

          public final FontSupport getFont()

      Gets the font-support of this fo. Is never null.
      Returns:
        Font-Support.

    - #### setFont

          public final void setFont(FontSupport fs)

      Sets the FontSupport of this fo. If fs is NULL, the default or inherated font properties are used.
      Parameters:
        `fs` - FontSupport.

    - #### clone

          public java.lang.Object clone()
                                 throws java.lang.CloneNotSupportedException

      Description copied from interface: `NodeElement`
      Clones this element. Should return a deep copy!
      Specified by:
        `clone` in interface `NodeElement`
      Overrides:
        `clone` in class `AbstractNodeWithAttributes`
      Returns:
        Clone.
      Throws:
        `java.lang.CloneNotSupportedException`

    - #### setAttribute

          protected void setAttribute(boolean enabled,
                          java.lang.String name,
                          java.lang.String value)

    - #### getObjectValue

          protected java.lang.Object getObjectValue(java.lang.String key,
                                        boolean deep,
                                        java.lang.Class<?> objClass)

    - #### getObjectValue

          protected java.lang.Object getObjectValue(java.lang.String key,
                                        java.lang.Class<?> objClass)

    - #### getObjectValue

          protected java.lang.Object getObjectValue(java.lang.String key,
                                        java.lang.Class<?> objClass,
                                        java.lang.Object defaultObject)

    - #### getObjectValue

          protected java.lang.Object getObjectValue(java.lang.String key,
                                        boolean deep,
                                        java.lang.Class<?> objClass,
                                        java.lang.Object defaultObject)

    - #### getMeasureValue

          protected Measure getMeasureValue(java.lang.String name)

      Gets a value as a measure.
      Parameters:
        `name` - Name of value.
      Returns:
        Measure.

    - #### doSetAttribute

          protected final boolean doSetAttribute(java.lang.String name,
                               java.lang.Object value)

      Overrides doSetAttribute of AbstractNode.
      Overrides:
        `doSetAttribute` in class `AbstractNodeWithAttributes`
      Parameters:
        `name` - Name of value.
        `value` - Value.
      Returns:
        `true`, if value was set.

    - #### doGetAttribute

          protected final java.lang.Object doGetAttribute(java.lang.String name)

      Overrides doGetAttribute of AbstractNode.
      Overrides:
        `doGetAttribute` in class `AbstractNodeWithAttributes`
      Parameters:
        `name` - Name of attribute.
      Returns:
        Value or NULL.

    - #### getBorder

          protected Border getBorder()

      Gets the border of this fo. Is never null.
      Returns:
        Border.

    - #### setBorder

          protected void setBorder(Border border)

      Sets the border of this fo.
      Parameters:
        `border` - Border.

    - #### hasBorder

          protected boolean hasBorder()

      Returns true if at least one border attribute is set.
      Returns:
        True if at least one border attribute is set.

    - #### getPadding

          protected Padding getPadding()

      Gets the padding of this fo. Is never null.
      Returns:
        Padding.

    - #### hasPadding

          protected boolean hasPadding()

      Returns true if at least one padding attribute is set.
      Returns:
        True if at least one padding attribute is set.

    - #### setPadding

          protected void setPadding(Padding padding)

      Sets the padding of this fo.
      Parameters:
        `padding` - Padding.

    - #### getMargin

          protected Margin getMargin()

      Gets the margin of this fo. Is never null.
      Returns:
        Margin.

    - #### setMargin

          protected void setMargin(Margin margin)

      Sets the margin of this fo.
      Parameters:
        `margin` - Margin.

    - #### getAbsolutePosition

          protected AbsolutePosition getAbsolutePosition()

      Gets the absolute position of this fo. Is never null.
      Returns:
        AbsolutePosition.

    - #### getRelativePosition

          protected RelativePosition getRelativePosition()

      Gets the relative position of this fo. Is never null.
      Returns:
        RelativePosition.

    - #### getBackground

          protected Background getBackground()

      Gets the background of this fo. Is never null.
      Returns:
        Background.

    - #### setBackground

          protected void setBackground(Background bg)

      Sets the background of this fo.
      Parameters:
        `bg` - Background.

    - #### setAccessibility

          protected void setAccessibility(Accessibility access)

      Sets the accessibility of this fo.
      Parameters:
        `access` - Accessibility.

    - #### getAccessibility

          protected Accessibility getAccessibility()

      Gets the accessibilty of this fo. Is never null.
      Returns:
        Accessibility.

    - #### setAbsolutePosition

          protected void setAbsolutePosition(AbsolutePosition pos)

      Sets the absolute position of this fo.
      Parameters:
        `pos` - AbsolutePosition.

    - #### setRelativePosition

          protected void setRelativePosition(RelativePosition pos)

      Sets the relative position of this fo.
      Parameters:
        `pos` - RelativePosition.

    - #### getLogger

          protected org.apache.commons.logging.Log getLogger()

      Gets the core logger of jFO.
      Returns:
        Core logger.

    - #### cloned

          protected static FormattingObject cloned(FormattingObject o,
                                Node cloneParent)

      Clones a formatting object and sets it's parent node.
      Parameters:
        `o` - Formatting object.
        `cloneParent` - Parent of formatting object.
      Returns:
        Clone or NULL if formatting object was NULL.

    - #### clonedList

          protected java.util.List clonedList(java.util.List list,
                                  Node parent)
                                       throws java.lang.CloneNotSupportedException

      Clones a list of nodes and formatting objects and sets the parent of cloned nodes.
      Parameters:
        `list` - List.
        `parent` - Parent of cloned nodes.
      Returns:
        Cloned list.
      Throws:
        `java.lang.CloneNotSupportedException`

© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.