com.itextpdf.text
Class List

java.lang.Object
  extended by com.itextpdf.text.List
All Implemented Interfaces:
Indentable, Element, IAccessibleElement, TextElementArray
Direct Known Subclasses:
GreekList, RomanList, ZapfDingbatsList, ZapfDingbatsNumberList

public class List
extends Object
implements TextElementArray, Indentable, IAccessibleElement

A List contains several ListItems.

Example 1:

 List list = new List(true, 20);
 list.add(new ListItem("First line"));
 list.add(new ListItem("The second line is longer to see what happens once the end of the line is reached. Will it start on a new line?"));
 list.add(new ListItem("Third line"));
 
The result of this code looks like this:
  1. First line
  2. The second line is longer to see what happens once the end of the line is reached. Will it start on a new line?
  3. Third line
Example 2:
 List overview = new List(false, 10);
 overview.add(new ListItem("This is an item"));
 overview.add("This is another item");
 
The result of this code looks like this:

See Also:
Element, ListItem

Field Summary
protected  HashMap<PdfName,PdfObject> accessibleAttributes
           
protected  boolean alignindent
          Indicates if the indentation of all the items has to be aligned.
static boolean ALPHABETICAL
          a possible value for the lettered parameter
protected  boolean autoindent
          Indicates if the indentation has to be set automatically.
protected  int first
          This variable indicates the first number of a numbered list.
protected  float indentationLeft
          The indentation of this list on the left side.
protected  float indentationRight
          The indentation of this list on the right side.
protected  boolean lettered
          Indicates if the listsymbols are numerical or alphabetical.
protected  ArrayList<Element> list
          This is the ArrayList containing the different ListItems.
protected  boolean lowercase
          Indicates if the listsymbols are lowercase or uppercase.
static boolean LOWERCASE
          a possible value for the lettered parameter
protected  boolean numbered
          Indicates if the list has to be numbered.
static boolean NUMERICAL
          a possible value for the lettered parameter
static boolean ORDERED
          a possible value for the numbered parameter
protected  String postSymbol
          In case you are using numbered/lettered lists, this String is added after the number/letter.
protected  String preSymbol
          In case you are using numbered/lettered lists, this String is added before the number/letter.
protected  PdfName role
           
protected  Chunk symbol
          This is the listsymbol of a list that is not numbered.
protected  float symbolIndent
          The indentation of the listitems.
static boolean UNORDERED
          a possible value for the numbered parameter
static boolean UPPERCASE
          a possible value for the lettered parameter
 
Fields inherited from interface com.itextpdf.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, CHAPTER, CHUNK, CREATIONDATE, CREATOR, DIV, HEADER, IMGRAW, IMGTEMPLATE, JBIG2, JPEG, JPEG2000, KEYWORDS, LANGUAGE, LIST, LISTITEM, MARKED, PARAGRAPH, PHRASE, PRODUCER, PTABLE, RECTANGLE, SECTION, SUBJECT, TITLE, WRITABLE_DIRECT, YMARK
 
Constructor Summary
List()
          Constructs a List.
List(boolean numbered)
          Constructs a List.
List(boolean numbered, boolean lettered)
          Constructs a List.
List(boolean numbered, boolean lettered, float symbolIndent)
          Creates a list
List(boolean numbered, float symbolIndent)
          Constructs a List.
List(float symbolIndent)
          Constructs a List with a specific symbol indentation.
 
Method Summary
 boolean add(Element o)
          Adds an Element to the List.
 boolean add(String s)
          Adds a String to the List.
 PdfObject getAccessibleAttribute(PdfName key)
          Get the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).
 HashMap<PdfName,PdfObject> getAccessibleAttributes()
          Gets all the properties of accessible element.
 List<Chunk> getChunks()
          Gets all the chunks in this element.
 int getFirst()
          Gets the first number .
 ListItem getFirstItem()
           
 UUID getId()
           
 float getIndentationLeft()
          Gets the indentation of this paragraph on the left side.
 float getIndentationRight()
          Gets the indentation of this paragraph on the right side.
 ArrayList<Element> getItems()
          Gets all the items in the list.
 ListItem getLastItem()
           
 String getPostSymbol()
          Returns the String that is after a number or letter in the list symbol.
 String getPreSymbol()
          Returns the String that is before a number or letter in the list symbol.
 PdfName getRole()
          Gets the role of the accessible element.
 Chunk getSymbol()
          Gets the Chunk containing the symbol.
 float getSymbolIndent()
          Gets the symbol indentation.
 float getTotalLeading()
          Gets the leading of the first listitem.
 boolean isAlignindent()
          Checks if all the listitems should be aligned.
 boolean isAutoindent()
          Checks if the indentation of list items is done automatically.
 boolean isContent()
          Checks if this element is a content object.
 boolean isEmpty()
          Returns true if the list is empty.
 boolean isLettered()
          Checks if the list is lettered.
 boolean isLowercase()
          Checks if the list lettering is lowercase.
 boolean isNestable()
          Checks if this element is nestable.
 boolean isNumbered()
          Checks if the list is numbered.
 void normalizeIndentation()
          Makes sure all the items in the list have the same indentation.
 boolean process(ElementListener listener)
          Processes the element by adding it (or the different parts) to an ElementListener.
 void setAccessibleAttribute(PdfName key, PdfObject value)
          Set the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).
 void setAlignindent(boolean alignindent)
           
 void setAutoindent(boolean autoindent)
           
 void setFirst(int first)
          Sets the number that has to come first in the list.
 void setId(UUID id)
           
 void setIndentationLeft(float indentation)
          Sets the indentation of this paragraph on the left side.
 void setIndentationRight(float indentation)
          Sets the indentation of this paragraph on the right side.
 void setLettered(boolean lettered)
           
 void setListSymbol(Chunk symbol)
          Sets the listsymbol.
 void setListSymbol(String symbol)
          Sets the listsymbol.
 void setLowercase(boolean uppercase)
           
 void setNumbered(boolean numbered)
           
 void setPostSymbol(String postSymbol)
          Sets the String that has to be added after a number or letter in the list symbol.
 void setPreSymbol(String preSymbol)
          Sets the String that has to be added before a number or letter in the list symbol.
 void setRole(PdfName role)
          Sets the role of the accessiblee element.
 void setSymbolIndent(float symbolIndent)
           
 int size()
          Gets the size of the list.
 int type()
          Gets the type of the text element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.itextpdf.text.Element
toString
 

Field Detail

ORDERED

public static final boolean ORDERED
a possible value for the numbered parameter

See Also:
Constant Field Values

UNORDERED

public static final boolean UNORDERED
a possible value for the numbered parameter

See Also:
Constant Field Values

NUMERICAL

public static final boolean NUMERICAL
a possible value for the lettered parameter

See Also:
Constant Field Values

ALPHABETICAL

public static final boolean ALPHABETICAL
a possible value for the lettered parameter

See Also:
Constant Field Values

UPPERCASE

public static final boolean UPPERCASE
a possible value for the lettered parameter

See Also:
Constant Field Values

LOWERCASE

public static final boolean LOWERCASE
a possible value for the lettered parameter

See Also:
Constant Field Values

list

protected ArrayList<Element> list
This is the ArrayList containing the different ListItems.


numbered

protected boolean numbered
Indicates if the list has to be numbered.


lettered

protected boolean lettered
Indicates if the listsymbols are numerical or alphabetical.


lowercase

protected boolean lowercase
Indicates if the listsymbols are lowercase or uppercase.


autoindent

protected boolean autoindent
Indicates if the indentation has to be set automatically.


alignindent

protected boolean alignindent
Indicates if the indentation of all the items has to be aligned.


first

protected int first
This variable indicates the first number of a numbered list.


symbol

protected Chunk symbol
This is the listsymbol of a list that is not numbered.


preSymbol

protected String preSymbol
In case you are using numbered/lettered lists, this String is added before the number/letter.

Since:
iText 2.1.1

postSymbol

protected String postSymbol
In case you are using numbered/lettered lists, this String is added after the number/letter.

Since:
iText 2.1.1

indentationLeft

protected float indentationLeft
The indentation of this list on the left side.


indentationRight

protected float indentationRight
The indentation of this list on the right side.


symbolIndent

protected float symbolIndent
The indentation of the listitems.


role

protected PdfName role

accessibleAttributes

protected HashMap<PdfName,PdfObject> accessibleAttributes
Constructor Detail

List

public List()
Constructs a List.


List

public List(float symbolIndent)
Constructs a List with a specific symbol indentation.

Parameters:
symbolIndent - the symbol indentation
Since:
iText 2.0.8

List

public List(boolean numbered)
Constructs a List.

Parameters:
numbered - a boolean

List

public List(boolean numbered,
            boolean lettered)
Constructs a List.

Parameters:
numbered - a boolean
lettered - has the list to be 'numbered' with letters

List

public List(boolean numbered,
            float symbolIndent)
Constructs a List.

Remark: the parameter symbolIndent is important for instance when generating PDF-documents; it indicates the indentation of the listsymbol. It is not important for HTML-documents.

Parameters:
numbered - a boolean
symbolIndent - the indentation that has to be used for the listsymbol

List

public List(boolean numbered,
            boolean lettered,
            float symbolIndent)
Creates a list

Parameters:
numbered - has the list to be numbered?
lettered - has the list to be 'numbered' with letters
symbolIndent - the indentation of the symbol
Method Detail

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 List<Chunk> getChunks()
Gets all the chunks in this element.

Specified by:
getChunks in interface Element
Returns:
an ArrayList

add

public boolean add(String s)
Adds a String to the List.

Parameters:
s - the element to add.
Returns:
true if adding the object succeeded
Since:
5.0.1

add

public boolean add(Element o)
Adds an Element to the List.

Specified by:
add in interface TextElementArray
Parameters:
o - the element to add.
Returns:
true if adding the object succeeded
Since:
5.0.1 (signature changed to use Element)

normalizeIndentation

public void normalizeIndentation()
Makes sure all the items in the list have the same indentation.


setNumbered

public void setNumbered(boolean numbered)
Parameters:
numbered - the numbered to set

setLettered

public void setLettered(boolean lettered)
Parameters:
lettered - the lettered to set

setLowercase

public void setLowercase(boolean uppercase)
Parameters:
uppercase - the uppercase to set

setAutoindent

public void setAutoindent(boolean autoindent)
Parameters:
autoindent - the autoindent to set

setAlignindent

public void setAlignindent(boolean alignindent)
Parameters:
alignindent - the alignindent to set

setFirst

public void setFirst(int first)
Sets the number that has to come first in the list.

Parameters:
first - a number

setListSymbol

public void setListSymbol(Chunk symbol)
Sets the listsymbol.

Parameters:
symbol - a Chunk

setListSymbol

public void setListSymbol(String symbol)
Sets the listsymbol.

This is a shortcut for setListSymbol(Chunk symbol).

Parameters:
symbol - a String

setIndentationLeft

public void setIndentationLeft(float indentation)
Sets the indentation of this paragraph on the left side.

Specified by:
setIndentationLeft in interface Indentable
Parameters:
indentation - the new indentation

setIndentationRight

public void setIndentationRight(float indentation)
Sets the indentation of this paragraph on the right side.

Specified by:
setIndentationRight in interface Indentable
Parameters:
indentation - the new indentation

setSymbolIndent

public void setSymbolIndent(float symbolIndent)
Parameters:
symbolIndent - the symbolIndent to set

getItems

public ArrayList<Element> getItems()
Gets all the items in the list.

Returns:
an ArrayList containing ListItems.

size

public int size()
Gets the size of the list.

Returns:
a size

isEmpty

public boolean isEmpty()
Returns true if the list is empty.

Returns:
true if the list is empty

getTotalLeading

public float getTotalLeading()
Gets the leading of the first listitem.

Returns:
a leading

isNumbered

public boolean isNumbered()
Checks if the list is numbered.

Returns:
true if the list is numbered, false otherwise.

isLettered

public boolean isLettered()
Checks if the list is lettered.

Returns:
true if the list is lettered, false otherwise.

isLowercase

public boolean isLowercase()
Checks if the list lettering is lowercase.

Returns:
true if it is lowercase, false otherwise.

isAutoindent

public boolean isAutoindent()
Checks if the indentation of list items is done automatically.

Returns:
the autoindent

isAlignindent

public boolean isAlignindent()
Checks if all the listitems should be aligned.

Returns:
the alignindent

getFirst

public int getFirst()
Gets the first number .

Returns:
a number

getSymbol

public Chunk getSymbol()
Gets the Chunk containing the symbol.

Returns:
a Chunk with a symbol

getIndentationLeft

public float getIndentationLeft()
Gets the indentation of this paragraph on the left side.

Specified by:
getIndentationLeft in interface Indentable
Returns:
the indentation

getIndentationRight

public float getIndentationRight()
Gets the indentation of this paragraph on the right side.

Specified by:
getIndentationRight in interface Indentable
Returns:
the indentation

getSymbolIndent

public float getSymbolIndent()
Gets the symbol indentation.

Returns:
the symbol indentation

isContent

public boolean isContent()
Description copied from interface: Element
Checks if this element is a content object. If not, it's a metadata object.

Specified by:
isContent in interface Element
Returns:
true if this is a 'content' element; false if this is a 'metadata' element
Since:
iText 2.0.8
See Also:
Element.isContent()

isNestable

public boolean isNestable()
Description copied from interface: Element
Checks if this element is nestable.

Specified by:
isNestable in interface Element
Returns:
true if this element can be nested inside other elements.
Since:
iText 2.0.8
See Also:
Element.isNestable()

getPostSymbol

public String getPostSymbol()
Returns the String that is after a number or letter in the list symbol.

Returns:
the String that is after a number or letter in the list symbol
Since:
iText 2.1.1

setPostSymbol

public void setPostSymbol(String postSymbol)
Sets the String that has to be added after a number or letter in the list symbol.

Parameters:
postSymbol - the String that has to be added after a number or letter in the list symbol.
Since:
iText 2.1.1

getPreSymbol

public String getPreSymbol()
Returns the String that is before a number or letter in the list symbol.

Returns:
the String that is before a number or letter in the list symbol
Since:
iText 2.1.1

setPreSymbol

public void setPreSymbol(String preSymbol)
Sets the String that has to be added before a number or letter in the list symbol.

Parameters:
preSymbol - the String that has to be added before a number or letter in the list symbol.
Since:
iText 2.1.1

getFirstItem

public ListItem getFirstItem()

getLastItem

public ListItem getLastItem()

getAccessibleAttribute

public PdfObject getAccessibleAttribute(PdfName key)
Description copied from interface: IAccessibleElement
Get the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).

Specified by:
getAccessibleAttribute in interface IAccessibleElement
Returns:

setAccessibleAttribute

public void setAccessibleAttribute(PdfName key,
                                   PdfObject value)
Description copied from interface: IAccessibleElement
Set the attribute of accessible element (everything in A dictionary + Lang, Alt, ActualText, E).

Specified by:
setAccessibleAttribute in interface IAccessibleElement

getAccessibleAttributes

public HashMap<PdfName,PdfObject> getAccessibleAttributes()
Description copied from interface: IAccessibleElement
Gets all the properties of accessible element.

Specified by:
getAccessibleAttributes in interface IAccessibleElement
Returns:

getRole

public PdfName getRole()
Description copied from interface: IAccessibleElement
Gets the role of the accessible element.

Specified by:
getRole in interface IAccessibleElement
Returns:

setRole

public void setRole(PdfName role)
Description copied from interface: IAccessibleElement
Sets the role of the accessiblee element. Set role to null if you don't want to tag this element. Note that all child elements won't also be tagged.

Specified by:
setRole in interface IAccessibleElement

getId

public UUID getId()
Specified by:
getId in interface IAccessibleElement

setId

public void setId(UUID id)
Specified by:
setId in interface IAccessibleElement


Copyright © 2013. All Rights Reserved.