Keep (Apache FOP Core 2.11 API)
Date: 2025-04-24

org.apache.fop.layoutmgr

## Class Keep

- java.lang.Object
- - org.apache.fop.layoutmgr.Keep

-     public final class Keep
      extends Object

  Object representing a keep constraint, corresponding to the XSL-FO keep properties.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Keep` | `KEEP_ALWAYS` keep always
    `static Keep` | `KEEP_AUTO` keep auto

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Keep` | `compare(Keep other)` Compare this Keep instance to another one, and return the stronger one if the context is the same
    `int` | `getContext()` Returns the context of this keep.
    `static Keep` | `getKeep(KeepProperty keepProperty)` Obtain a Keep instance corresponding to the given `KeepProperty`
    `int` | `getPenalty()`
    `boolean` | `isAuto()`
    `String` | `toString()`

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

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

- - ### Field Detail

    - #### KEEP_AUTO

          public static final Keep KEEP_AUTO

      keep auto

    - #### KEEP_ALWAYS

          public static final Keep KEEP_ALWAYS

      keep always

  - ### Method Detail

    - #### getKeep

          public static Keep getKeep(KeepProperty keepProperty)

      Obtain a Keep instance corresponding to the given `KeepProperty`
      Parameters:
        `keepProperty` - the `KeepProperty`
      Returns:
        a new instance corresponding to the given property

    - #### isAuto

          public boolean isAuto()

      Returns:
        `true` if the keep property was specified as "auto"

    - #### getContext

          public int getContext()

      Returns the context of this keep.
      Returns:
        one of `Constants.EN_LINE`, `Constants.EN_COLUMN` or `Constants.EN_PAGE`

    - #### getPenalty

          public int getPenalty()

      Returns:
        the penalty value corresponding to the strength of this Keep

    - #### compare

          public Keep compare(Keep other)

      Compare this Keep instance to another one, and return the stronger one if the context is the same
      Parameters:
        `other` - the instance to compare to
      Returns:
        the winning Keep instance

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2025 Apache Software Foundation. All rights reserved.