## com.lowagie.text
Class Phrase

    java.lang.Object
      java.util.AbstractCollection
          java.util.AbstractList
              java.util.ArrayList
                  com.lowagie.text.Phrase

All Implemented Interfaces:
  Cloneable, Collection, Element, List, MarkupAttributes, RandomAccess, Serializable, TextElementArray

Direct Known Subclasses:
  Anchor, Paragraph

public class Phrase
extends ArrayList
implements TextElementArray, MarkupAttributes

A `Phrase` is a series of `Chunk`s.

A `Phrase` has a main `Font`, but some chunks within the phrase can have a `Font` that differs from the main `Font`. All the `Chunk`s in a `Phrase` have the same `leading`.

Example:

>      // When no parameters are passed, the default leading = 16
>      Phrase phrase0 = new Phrase();
>      Phrase phrase1 = new Phrase("this is a phrase");
>      // In this example the leading is passed as a parameter
>      Phrase phrase2 = new Phrase(16, "this is a phrase with leading 16");
>      // When a Font is passed (explicitely or embedded in a chunk), the default leading = 1.5 * size of the font
>      Phrase phrase3 = new Phrase("this is a phrase with a red, normal font Courier, size 12", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, new Color(255, 0, 0)));
>      Phrase phrase4 = new Phrase(new Chunk("this is a phrase"));
>      Phrase phrase5 = new Phrase(18, new Chunk("this is a phrase", FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD, new Color(255, 0, 0)));

See Also:
  `Element`, `Chunk`, `Paragraph`, `Anchor`, Serialized Form

Nested Class Summary

Nested classes inherited from class java.util.AbstractList
``

Field Summary
`protected Font` `font` This is the font of this phrase.
`protected float` `leading` This is the leading of this phrase.
`protected Properties` `markupAttributes` Contains extra markupAttributes

Fields inherited from class java.util.ArrayList
``

Fields inherited from class java.util.AbstractList
`modCount`

Fields inherited from interface com.lowagie.text.Element

`ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_JUSTIFIED, ALIGN_JUSTIFIED_ALL, ALIGN_LEFT, ALIGN_MIDDLE, ALIGN_RIGHT, ALIGN_TOP, ALIGN_UNDEFINED, ANCHOR, ANNOTATION, AUTHOR, CCITT_BLACKIS1, CCITT_ENCODEDBYTEALIGN, CCITT_ENDOFBLOCK, CCITT_ENDOFLINE, CCITTG3_1D, CCITTG3_2D, CCITTG4, CELL, CHAPTER, CHUNK, CREATIONDATE, CREATOR, GRAPHIC, HEADER, IMGRAW, IMGTEMPLATE, JPEG, KEYWORDS, LIST, LISTITEM, MULTI_COLUMN_TEXT, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, ROW, SECTION, SUBJECT, TABLE, TITLE`

Constructor Summary
`` `Phrase()` Constructs a `Phrase` without specifying a leading.
`private` `Phrase(boolean dummy)` Constructs a Phrase that can be used in the static getInstance() method.
`` `Phrase(Chunk chunk)` Constructs a `Phrase` with a certain `Chunk`.
`` `Phrase(float leading)` Constructs a `Phrase` with a certain leading.
`` `Phrase(float leading, Chunk chunk)` Constructs a `Phrase` with a certain `Chunk` and a certain leading.
`` `Phrase(float leading, String string)` Constructs a `Phrase` with a certain leading and a certain `String`.
`` `Phrase(float leading, String string, Font font)` Constructs a `Phrase` with a certain leading, a certain `String` and a certain `Font`.
`` `Phrase(Properties attributes)` Returns a `Phrase` that has been constructed taking in account the value of some attributes.
`` `Phrase(String string)` Constructs a `Phrase` with a certain `String`.
`` `Phrase(String string, Font font)` Constructs a `Phrase` with a certain `String` and a certain `Font`.

Method Summary
`void` `add(int index, Object o)` Adds a `Chunk`, an `Anchor` or another `Phrase` to this `Phrase`.
`boolean` `add(Object o)` Adds a `Chunk`, `Anchor` or another `Phrase` to this `Phrase`.
`boolean` `addAll(Collection collection)` Adds a collection of `Chunk`s to this `Phrase`.
`private boolean` `addChunk(Chunk chunk)` Adds a Chunk.
`protected void` `addSpecial(Object object)` Adds a `Object` to the `Paragraph`.
`Font` `font()` Gets the font of the first `Chunk` that appears in this `Phrase`.
`ArrayList` `getChunks()` Gets all the chunks in this element.
`static Phrase` `getInstance(int leading, String string)` Gets a special kind of Phrase that changes some characters into corresponding symbols.
`static Phrase` `getInstance(int leading, String string, Font font)` Gets a special kind of Phrase that changes some characters into corresponding symbols.
`static Phrase` `getInstance(String string)` Gets a special kind of Phrase that changes some characters into corresponding symbols.
`String` `getMarkupAttribute(String name)` Returns the value of the specified attribute.
`Set` `getMarkupAttributeNames()` Returns a `Set` of `String` attribute names for the `MarkupAttributes` implementor.
`Properties` `getMarkupAttributes()` Return a `Properties`-object containing all the markupAttributes.
`boolean` `isEmpty()` Checks is this `Phrase` contains no or 1 empty `Chunk`.
`static boolean` `isTag(String tag)` Checks if a given tag corresponds with this object.
`float` `leading()` Gets the leading of this phrase.
`boolean` `leadingDefined()` Checks you if the leading of this phrase is defined.
`boolean` `process(ElementListener listener)` Processes the element by adding it (or the different parts) to an `ElementListener`.
`void` `setLeading(float leading)` Sets the leading of this phrase.
`void` `setMarkupAttribute(String name, String value)` Sets the specified attribute.
`void` `setMarkupAttributes(Properties markupAttributes)` Sets the markupAttributes.
`int` `type()` Gets the type of the text element.

Methods inherited from class java.util.ArrayList
`addAll, clear, clone, contains, ensureCapacity, get, indexOf, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize`

Methods inherited from class java.util.AbstractList
`equals, hashCode, iterator, listIterator, listIterator, subList`

Methods inherited from class java.util.AbstractCollection
`containsAll, remove, removeAll, retainAll, toString`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.lowagie.text.Element
`toString`

Methods inherited from interface java.util.List
`containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList`

Field Detail

### leading

    protected float leading

  This is the leading of this phrase.

### font

    protected Font font

  This is the font of this phrase.

### markupAttributes

    protected Properties markupAttributes

  Contains extra markupAttributes

Constructor Detail

### Phrase

    private Phrase(boolean dummy)

  Constructs a Phrase that can be used in the static getInstance() method.

Parameters:
  `dummy` - a dummy parameter

### Phrase

    public Phrase()

  Constructs a `Phrase` without specifying a leading.

### Phrase

    public Phrase(float leading)

  Constructs a `Phrase` with a certain leading.

Parameters:
  `leading` - the leading

### Phrase

    public Phrase(Chunk chunk)

  Constructs a `Phrase` with a certain `Chunk`.

Parameters:
  `chunk` - a `Chunk`

### Phrase

    public Phrase(float leading,
                  Chunk chunk)

  Constructs a `Phrase` with a certain `Chunk` and a certain leading.

Parameters:
  `leading` - the leading
  `chunk` - a `Chunk`

### Phrase

    public Phrase(String string)

  Constructs a `Phrase` with a certain `String`.

Parameters:
  `string` - a `String`

### Phrase

    public Phrase(String string,
                  Font font)

  Constructs a `Phrase` with a certain `String` and a certain `Font`.

Parameters:
  `string` - a `String`
  `font` - a `Font`

### Phrase

    public Phrase(float leading,
                  String string)

  Constructs a `Phrase` with a certain leading and a certain `String`.

Parameters:
  `leading` - the leading
  `string` - a `String`

### Phrase

    public Phrase(float leading,
                  String string,
                  Font font)

  Constructs a `Phrase` with a certain leading, a certain `String` and a certain `Font`.

Parameters:
  `leading` - the leading
  `string` - a `String`
  `font` - a `Font`

### Phrase

    public Phrase(Properties attributes)

  Returns a `Phrase` that has been constructed taking in account the value of some attributes.

Parameters:
  `attributes` - Some attributes

Method Detail

### getInstance

    public static final Phrase getInstance(String string)

  Gets a special kind of Phrase that changes some characters into corresponding symbols.

  Parameters:
    `string` -
  Returns:
    a newly constructed Phrase

### getInstance

    public static final Phrase getInstance(int leading,
                                           String string)

  Gets a special kind of Phrase that changes some characters into corresponding symbols.

  Parameters:
    `leading` -
    `string` -
  Returns:
    a newly constructed Phrase

### getInstance

    public static final Phrase getInstance(int leading,
                                           String string,
                                           Font font)

  Gets a special kind of Phrase that changes some characters into corresponding symbols.

  Parameters:
    `leading` -
    `string` -
    `font` -
  Returns:
    a newly constructed Phrase

### process

    public boolean process(ElementListener listener)

  Processes the element by adding it (or the different parts) to an `ElementListener`.

  Specified by:
    `process` in interface `Element`
  Parameters:
    `listener` - an `ElementListener`
  Returns:
    `true` if the element was processed successfully

### type

    public int type()

  Gets the type of the text element.

  Specified by:
    `type` in interface `Element`
  Returns:
    a type

### getChunks

    public ArrayList getChunks()

  Gets all the chunks in this element.

  Specified by:
    `getChunks` in interface `Element`
  Returns:
    an `ArrayList`

### add

    public void add(int index,
                    Object o)

  Adds a `Chunk`, an `Anchor` or another `Phrase` to this `Phrase`.

  Specified by:
    `add` in interface `List`
  Parameters:
    `index` - index at which the specified element is to be inserted
    `o` - an object of type `Chunk`, `Anchor` or `Phrase`
  Throws:
    `ClassCastException` - when you try to add something that isn't a `Chunk`, `Anchor` or `Phrase`

### add

    public boolean add(Object o)

  Adds a `Chunk`, `Anchor` or another `Phrase` to this `Phrase`.

  Specified by:
    `add` in interface `TextElementArray`
  Parameters:
    `o` - an object of type `Chunk`, `Anchor` or `Phrase`
  Returns:
    a boolean
  Throws:
    `ClassCastException` - when you try to add something that isn't a `Chunk`, `Anchor` or `Phrase`

### addChunk

    private boolean addChunk(Chunk chunk)

  Adds a Chunk.

  This method is a hack to solve a problem I had with phrases that were split between chunks in the wrong place.

  Parameters:
    `chunk` - a Chunk to add to the Phrase
  Returns:
    true if adding the Chunk succeeded

### addAll

    public boolean addAll(Collection collection)

  Adds a collection of `Chunk`s to this `Phrase`.

  Specified by:
    `addAll` in interface `List`
  Parameters:
    `collection` - a collection of `Chunk`s, `Anchor`s and `Phrase`s.
  Returns:
    `true` if the action succeeded, `false` if not.
  Throws:
    `ClassCastException` - when you try to add something that isn't a `Chunk`, `Anchor` or `Phrase`

### addSpecial

    protected void addSpecial(Object object)

  Adds a `Object` to the `Paragraph`.

  Parameters:
    `object` - the object to add.

### setLeading

    public void setLeading(float leading)

  Sets the leading of this phrase.

  Parameters:
    `leading` - the new leading

### isEmpty

    public boolean isEmpty()

  Checks is this `Phrase` contains no or 1 empty `Chunk`.

  Specified by:
    `isEmpty` in interface `List`
  Returns:
    `false` if the `Phrase` contains more than one or more non-empty`Chunk`s.

### leadingDefined

    public boolean leadingDefined()

  Checks you if the leading of this phrase is defined.

  Returns:
    true if the leading is defined

### leading

    public float leading()

  Gets the leading of this phrase.

  Returns:
    the linespacing

### font

    public Font font()

  Gets the font of the first `Chunk` that appears in this `Phrase`.

  Returns:
    a `Font`

### isTag

    public static boolean isTag(String tag)

  Checks if a given tag corresponds with this object.

  Parameters:
    `tag` - the given tag
  Returns:
    true if the tag corresponds

### setMarkupAttribute

    public void setMarkupAttribute(String name,
                                   String value)

  Description copied from interface: `MarkupAttributes`
  Sets the specified attribute.

  Specified by:
    `setMarkupAttribute` in interface `MarkupAttributes`
  Parameters:
    `name` - `String` attribute name.
    `value` - `String` attribute value.
  See Also:
    `MarkupAttributes.setMarkupAttribute(java.lang.String, java.lang.String)`

### setMarkupAttributes

    public void setMarkupAttributes(Properties markupAttributes)

  Description copied from interface: `MarkupAttributes`
  Sets the markupAttributes.

  Specified by:
    `setMarkupAttributes` in interface `MarkupAttributes`
  Parameters:
    `markupAttributes` - a `Properties`-object containing markupattributes
  See Also:
    `MarkupAttributes.setMarkupAttributes(java.util.Properties)`

### getMarkupAttribute

    public String getMarkupAttribute(String name)

  Description copied from interface: `MarkupAttributes`
  Returns the value of the specified attribute.

  Specified by:
    `getMarkupAttribute` in interface `MarkupAttributes`
  Parameters:
    `name` - `String` attribute name.
  Returns:
    `String`.
  See Also:
    `MarkupAttributes.getMarkupAttribute(java.lang.String)`

### getMarkupAttributeNames

    public Set getMarkupAttributeNames()

  Description copied from interface: `MarkupAttributes`
  Returns a `Set` of `String` attribute names for the `MarkupAttributes` implementor.

  Specified by:
    `getMarkupAttributeNames` in interface `MarkupAttributes`
  Returns:
    `Set`.
  See Also:
    `MarkupAttributes.getMarkupAttributeNames()`

### getMarkupAttributes

    public Properties getMarkupAttributes()

  Description copied from interface: `MarkupAttributes`
  Return a `Properties`-object containing all the markupAttributes.

  Specified by:
    `getMarkupAttributes` in interface `MarkupAttributes`
  Returns:
    `Properties`
  See Also:
    `MarkupAttributes.getMarkupAttributes()`