jdbreport.model
Class ReportBook

java.lang.Object
  extended by jdbreport.model.ReportBook
All Implemented Interfaces:
Iterable<ReportModel>, EventListener, TableRowModelListener
Direct Known Subclasses:
TemplateBook

public class ReportBook
extends Object
implements Iterable<ReportModel>, TableRowModelListener

Version:
2.0 18.05.2011
Author:
Andrey Kholmanskih

Field Summary
static String CURRENT_VERSION
           
protected static DateFormat dateFormatter
           
static String DOCX
           
static boolean enableSVG
           
static String EXCEL
           
static String HTML
           
static String HTML_BODY
           
static String JRPT
           
protected  EventListenerList listenerList
           
static String ODS
           
static String ODT
           
static String PDF
           
protected static TreeMap<Object,String> READERS_MAP
           
static String RPT
           
protected static TreeMap<Object,String> WRITERS_MAP
           
static String XLS
           
static String XLSX
           
static String XML
           
 
Constructor Summary
ReportBook()
           
 
Method Summary
 int add()
          Appends the default ReportModel to the end of the list of the ReportModel
 void add(int index, ReportModel reportModel)
          Inserts the element representing the ReportModel at the specified position in the list of the ReportModel
 void add(ReportBook book)
          Appends the other reportbook
 void add(ReportBook book, int index)
          Appends the other reportbook
 int add(ReportModel reportModel)
          Appends the ReportModel to the end of the list of the ReportModel
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
           
 void addReportListListener(ReportListListener x)
           
 Object addStyle(CellStyle style)
          Looks for style in the list of styles if doesn't find, adds it to the list otherwise returns the id of the founded style If style's id is null, a new id is appropriated to the style
 Object appendStyle(CellStyle style)
          Adds the style to the list of styles.
 void clear()
          Removes all the report models.
protected  ReportModel createDefaultModel()
           
protected  void doAfterLoad()
           
protected  ReportModel doCreateDefaultModel()
           
static boolean fileTypeExists(String key)
           
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
           
protected  void fireReportAdded(ReportListEvent e)
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireReportMoved(ReportListEvent e)
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireReportRemoved(ReportListEvent e)
          Notifies all listeners that have registered interest for notification on this event type.
 Date getCreationDate()
          Returns the date of report's creating
 String getCreator()
          Returns the name of the report's creator
static DateFormat getDateFormatter()
           
protected  String getDefaultReaderKey()
           
protected  String getDefaultWriterKey()
           
static FileType getFileTypeClass(String key)
           
 String getKeyByFile(String filename)
          Returns ReportReader's or ReportWriter's key by extension of the file
 String getMimeType()
           
 ReportReader getReaderClass(Object key)
          Returns the value that represents the superclass of the ReportReader by key
 String getReaderClassName(Object key)
          Returns the name of the class representing the superclass of the ReportReader by key
 Collection<String> getReaderNames()
          Returns collection of names of classes representing the superclass of the ReportReader
protected  Map<Object,String> getReaders()
           
 String getReportCaption()
          Returns the report's title
 ReportListListener[] getReportListListeners()
           
 JReportModel getReportModel(int index)
          Returns the ReportModel at the specified position in this list.
 String getSourceTemplate()
           
 Map<Object,CellStyle> getStyleList()
          Returns the styles' map
 CellStyle getStyles(Object index)
          Returns the CellStyle by the index
 int getStylesCount()
          Returns the styles' count
 ReportWriter getWriterClass(Object key)
          Returns the value that represents the superclass of the ReportWriter by key
 String getWriterClassName(Object key)
          Returns the name of class representing the superclass of the ReportWriter by key
 Collection<String> getWriterNames()
          Returns collection of the names of classes representing the superclass of the ReportWriter
protected  Map<Object,String> getWriters()
           
static boolean isEnableSVG()
           
 boolean isGlobalPageNumber()
          Returns type of numbering of pages
protected  boolean isLocked()
           
 boolean isPrintThroughPdf()
          Printing through conversion to PDF
 boolean isShowGrid()
          Returns true if the report draws lines between cells, false if it doesn't.
 Iterator<ReportModel> iterator()
          Returns an iterator over the ReportModel
protected  void lockUpdate()
           
 void move(int fromIndex, int toIndex)
          Moves the ReportModel from fromIndex to the position toIndex
 void newReport()
          Creates a new report
 void open(byte[] buf, String readerId)
          Opens the report from the bytes
 void open(File file)
          Opens the report by the file The ReportReader is determined by extension of the file
 void open(File file, ReportReader reader)
          Opens the report from the file
 void open(InputStream stream, ReportReader reader)
          Opens the report from the stream
 void open(String fileName)
          Opens the report by the fileName
 void open(URL url)
          Opens the report from the URL The ReportReader is determined by extension of the file
 void open(URL url, ReportReader reader)
          Opens the report from URL
static boolean pdfExists()
           
 void putReaderClassName(Object key, String className)
          Puts the name of the class that represents the superclass of the ReportReader to READERS_MAP
 void putWriterClassName(Object key, String className)
          Puts the name of the class that represents the superclass of the ReportWriter to WRITERS_MAP
 ReportModel remove(int index)
          Removes the ReportModel
 boolean remove(ReportModel model)
          Removes the ReportModel
 void removeDoubleBorders(ReportModel model)
           
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
           
 void removeReportListListener(ReportListListener x)
           
 void replaceStyles(Object oldId, Object newId)
           
protected  void revalidatePageNumbers()
          Revalidate numbers of pages
 void rowAdded(TableRowModelEvent e)
          Tells listeners that a row was added to the model.
 void rowMarginChanged(ChangeEvent e)
          Tells listeners that a row was moved due to a margin change.
 void rowMoved(TableRowModelEvent e)
          Tells listeners that a row was repositioned.
 void rowRemoved(TableRowModelEvent e)
          Tells listeners that a row was removed from the model.
 void rowResized(TableRowModelEvent e)
          Tells listeners that a row was resized.
 void rowSelectionChanged(ListSelectionEvent e)
          Tells listeners that the selection model of the TableRowModel changed.
 void rowUpdated(TableRowModelEvent e)
          Tells listeners that a rows was change.
 void save(File file)
          Saves the report in the file
 void save(File file, ReportWriter writer)
          Saves the report in the file
 void setCreationDate(Date date)
          Sets the date of report's creating
 void setCreator(String creator)
          Sets the name of the report's creator
 void setGlobalPageNumber(boolean globalPageNumber)
          Sets type of numbering of pages If globalPageNumber - it is true, the common indexing of pages in all report is set, differently in each sheet numbering starts with 1
 void setPrintThroughPdf(boolean printThroughPdf)
          Printing through conversion to PDF
 void setReportCaption(String value)
          Sets the report's title
 void setShowGrid(boolean b)
          Sets whether the report draws lines between cells.
 void setShowPageNumber(boolean show)
           
 void setSourceTemplate(String sourceTemplate)
           
 int size()
          Returns count of the ReportModel in the list
protected  void unlockUpdate()
           
 void updateRowAndPageHeight(HeighCalculator hCalc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTML

public static final String HTML
See Also:
Constant Field Values

HTML_BODY

public static final String HTML_BODY
See Also:
Constant Field Values

ODS

public static final String ODS
See Also:
Constant Field Values

ODT

public static final String ODT
See Also:
Constant Field Values

RPT

public static final String RPT
See Also:
Constant Field Values

JRPT

public static final String JRPT
See Also:
Constant Field Values

EXCEL

public static final String EXCEL
See Also:
Constant Field Values

XML

public static final String XML
See Also:
Constant Field Values

PDF

public static final String PDF
See Also:
Constant Field Values

XLS

public static final String XLS
See Also:
Constant Field Values

XLSX

public static final String XLSX
See Also:
Constant Field Values

DOCX

public static final String DOCX
See Also:
Constant Field Values

enableSVG

public static boolean enableSVG

dateFormatter

protected static DateFormat dateFormatter

WRITERS_MAP

protected static TreeMap<Object,String> WRITERS_MAP

READERS_MAP

protected static TreeMap<Object,String> READERS_MAP

CURRENT_VERSION

public static final String CURRENT_VERSION
See Also:
Constant Field Values

listenerList

protected EventListenerList listenerList
Constructor Detail

ReportBook

public ReportBook()
Method Detail

isEnableSVG

public static boolean isEnableSVG()

pdfExists

public static boolean pdfExists()

getDateFormatter

public static DateFormat getDateFormatter()

getReaders

protected Map<Object,String> getReaders()

getWriters

protected Map<Object,String> getWriters()

fileTypeExists

public static boolean fileTypeExists(String key)
Parameters:
key -
Returns:
true if exists FileType by key
Since:
1.3

getFileTypeClass

public static FileType getFileTypeClass(String key)
Parameters:
key -
Returns:
FileType by key
Since:
1.3

getReaderClass

public ReportReader getReaderClass(Object key)
Returns the value that represents the superclass of the ReportReader by key

Parameters:
key - key whose associated ReportReader is to be returned. It is usually extension of Report file
Returns:
ReportReader

getWriterClass

public ReportWriter getWriterClass(Object key)
Returns the value that represents the superclass of the ReportWriter by key

Parameters:
key - key whose associated ReportWriter is to be returned. It is usually extension of Report file
Returns:
ReportWriter

putReaderClassName

public void putReaderClassName(Object key,
                               String className)
Puts the name of the class that represents the superclass of the ReportReader to READERS_MAP

Parameters:
key - key whose associated ReportReader is to be returned. it is usually extension of Report file
className - ReportReader class name

putWriterClassName

public void putWriterClassName(Object key,
                               String className)
Puts the name of the class that represents the superclass of the ReportWriter to WRITERS_MAP

Parameters:
key - ReportWriter key it is usually extension of Report file
className - ReportWriter class name

getReaderClassName

public String getReaderClassName(Object key)
Returns the name of the class representing the superclass of the ReportReader by key

Parameters:
key - ReportReader key it is usually extension of Report file
Returns:
ReportReader class name

getWriterClassName

public String getWriterClassName(Object key)
Returns the name of class representing the superclass of the ReportWriter by key

Parameters:
key - ReportWriter key it is usually extension of Report file
Returns:
the name of class

getReaderNames

public Collection<String> getReaderNames()
Returns collection of names of classes representing the superclass of the ReportReader

Returns:
collection of names of classes

getWriterNames

public Collection<String> getWriterNames()
Returns collection of the names of classes representing the superclass of the ReportWriter

Returns:
collection of names of classes

getDefaultReaderKey

protected String getDefaultReaderKey()

getDefaultWriterKey

protected String getDefaultWriterKey()

lockUpdate

protected void lockUpdate()

unlockUpdate

protected void unlockUpdate()

isLocked

protected boolean isLocked()

add

public int add(ReportModel reportModel)
Appends the ReportModel to the end of the list of the ReportModel

Parameters:
reportModel - ReportModel instance
Returns:
the index of the last element in the list of the ReportModel

add

public int add()
Appends the default ReportModel to the end of the list of the ReportModel

Returns:
the index of the last element in the list of the ReportModel

add

public void add(int index,
                ReportModel reportModel)
Inserts the element representing the ReportModel at the specified position in the list of the ReportModel

Parameters:
index - index at which the reportModel is to be inserted.
reportModel - element instance of the ReportModel to be inserted

add

public void add(ReportBook book)
Appends the other reportbook

Parameters:
book -
Since:
2.0

add

public void add(ReportBook book,
                int index)
Appends the other reportbook

Parameters:
book -
index -
Since:
2.0

remove

public ReportModel remove(int index)
Removes the ReportModel

Parameters:
index - the index of the ReportModel to removed.
Returns:
the removed ReportModel

remove

public boolean remove(ReportModel model)
Removes the ReportModel

Parameters:
model - to be removed from list.
Returns:
true if list contained the specified model.

revalidatePageNumbers

protected void revalidatePageNumbers()
Revalidate numbers of pages


isGlobalPageNumber

public boolean isGlobalPageNumber()
Returns type of numbering of pages

Returns:
true if pages have the common numbering of pages
Since:
1.4

setGlobalPageNumber

public void setGlobalPageNumber(boolean globalPageNumber)
Sets type of numbering of pages If globalPageNumber - it is true, the common indexing of pages in all report is set, differently in each sheet numbering starts with 1

Parameters:
globalPageNumber -
Since:
1.4

getReportModel

public JReportModel getReportModel(int index)
Returns the ReportModel at the specified position in this list.

Parameters:
index - index of ReportModel to return.
Returns:
the ReportModel at the specified position in this list.

size

public int size()
Returns count of the ReportModel in the list

Returns:
count of the ReportModel in the list

move

public void move(int fromIndex,
                 int toIndex)
Moves the ReportModel from fromIndex to the position toIndex

Parameters:
fromIndex - the index of ReportModel to be moved
toIndex - the new index of the ReportModel

getStyles

public CellStyle getStyles(Object index)
Returns the CellStyle by the index

Parameters:
index - the id of the CellStyle
Returns:
the CellStyle

clear

public void clear()
Removes all the report models. Removes all the styles


replaceStyles

public void replaceStyles(Object oldId,
                          Object newId)

getKeyByFile

public String getKeyByFile(String filename)
Returns ReportReader's or ReportWriter's key by extension of the file

Parameters:
filename - the file's name
Returns:
the ReportReader's or ReportWriter's key

save

public void save(File file)
          throws IOException
Saves the report in the file

Parameters:
file - the file in which the report will be saved
Throws:
IOException

save

public void save(File file,
                 ReportWriter writer)
          throws IOException
Saves the report in the file

Parameters:
file - the file in which the report will be saved
writer - the ReportWriter that is used to save the report
Throws:
IOException

open

public void open(String fileName)
          throws LoadReportException
Opens the report by the fileName

Parameters:
fileName - the file's name
Throws:
LoadReportException

newReport

public void newReport()
Creates a new report


open

public void open(File file)
          throws LoadReportException
Opens the report by the file The ReportReader is determined by extension of the file

Parameters:
file - the report's file
Throws:
LoadReportException

open

public void open(File file,
                 ReportReader reader)
          throws LoadReportException
Opens the report from the file

Parameters:
file - the report's file
reader - the ReportReader that is used to read the report
Throws:
LoadReportException

open

public void open(URL url)
          throws LoadReportException
Opens the report from the URL The ReportReader is determined by extension of the file

Parameters:
url - the report's URL
Throws:
LoadReportException

open

public void open(URL url,
                 ReportReader reader)
          throws LoadReportException
Opens the report from URL

Parameters:
url - the report's URL
reader - the ReportReader that is used to read the report
Throws:
LoadReportException

open

public void open(InputStream stream,
                 ReportReader reader)
          throws LoadReportException
Opens the report from the stream

Parameters:
stream - the report's stream
reader - the ReportReader that is used to read the report
Throws:
LoadReportException
IOException

doAfterLoad

protected void doAfterLoad()
Since:
1.4

open

public void open(byte[] buf,
                 String readerId)
          throws LoadReportException
Opens the report from the bytes

Parameters:
buf - the bytes' array
readerId - the ReportReader's id
Throws:
LoadReportException

doCreateDefaultModel

protected ReportModel doCreateDefaultModel()

createDefaultModel

protected ReportModel createDefaultModel()

addReportListListener

public void addReportListListener(ReportListListener x)

removeReportListListener

public void removeReportListListener(ReportListListener x)

getReportListListeners

public ReportListListener[] getReportListListeners()

fireReportAdded

protected void fireReportAdded(ReportListEvent e)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Parameters:
e - the event received
See Also:
EventListenerList

fireReportRemoved

protected void fireReportRemoved(ReportListEvent e)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Parameters:
e - the event received
See Also:
EventListenerList

fireReportMoved

protected void fireReportMoved(ReportListEvent e)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Parameters:
e - the event received

getReportCaption

public String getReportCaption()
Returns the report's title

Returns:
the report's title

setReportCaption

public void setReportCaption(String value)
Sets the report's title

Parameters:
value - the new report's title

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)

getStylesCount

public int getStylesCount()
Returns the styles' count

Returns:
the styles' count

addStyle

public Object addStyle(CellStyle style)
Looks for style in the list of styles if doesn't find, adds it to the list otherwise returns the id of the founded style If style's id is null, a new id is appropriated to the style

Parameters:
style - adding style
Returns:
the style's id

appendStyle

public Object appendStyle(CellStyle style)
Adds the style to the list of styles. If style's id is null or style's id exists in the list, a new id is appropriated to the style

Parameters:
style - adding style
Returns:
a new style's id

getStyleList

public Map<Object,CellStyle> getStyleList()
Returns the styles' map

Returns:
the styles' map

iterator

public Iterator<ReportModel> iterator()
Returns an iterator over the ReportModel

Specified by:
iterator in interface Iterable<ReportModel>
Returns:
an iterator over the ReportModel

getCreator

public String getCreator()
Returns the name of the report's creator

Returns:
report's creator

setCreator

public void setCreator(String creator)
Sets the name of the report's creator

Parameters:
creator - report's creator

getCreationDate

public Date getCreationDate()
Returns the date of report's creating

Returns:
the date of report's creating

setCreationDate

public void setCreationDate(Date date)
Sets the date of report's creating

Parameters:
date - the date of report's creating

setShowGrid

public void setShowGrid(boolean b)
Sets whether the report draws lines between cells. If show is true it does; if it is false it doesn't.

Parameters:
b - true if report view should draw lines

isShowGrid

public boolean isShowGrid()
Returns true if the report draws lines between cells, false if it doesn't. The default is true.

Returns:
true if the report draws lines between cells, false if it doesn't

removeDoubleBorders

public void removeDoubleBorders(ReportModel model)

rowAdded

public void rowAdded(TableRowModelEvent e)
Description copied from interface: TableRowModelListener
Tells listeners that a row was added to the model.

Specified by:
rowAdded in interface TableRowModelListener

rowMarginChanged

public void rowMarginChanged(ChangeEvent e)
Description copied from interface: TableRowModelListener
Tells listeners that a row was moved due to a margin change.

Specified by:
rowMarginChanged in interface TableRowModelListener

rowMoved

public void rowMoved(TableRowModelEvent e)
Description copied from interface: TableRowModelListener
Tells listeners that a row was repositioned.

Specified by:
rowMoved in interface TableRowModelListener

rowRemoved

public void rowRemoved(TableRowModelEvent e)
Description copied from interface: TableRowModelListener
Tells listeners that a row was removed from the model.

Specified by:
rowRemoved in interface TableRowModelListener

rowResized

public void rowResized(TableRowModelEvent e)
Description copied from interface: TableRowModelListener
Tells listeners that a row was resized.

Specified by:
rowResized in interface TableRowModelListener

rowSelectionChanged

public void rowSelectionChanged(ListSelectionEvent e)
Description copied from interface: TableRowModelListener
Tells listeners that the selection model of the TableRowModel changed.

Specified by:
rowSelectionChanged in interface TableRowModelListener

rowUpdated

public void rowUpdated(TableRowModelEvent e)
Description copied from interface: TableRowModelListener
Tells listeners that a rows was change.

Specified by:
rowUpdated in interface TableRowModelListener

setShowPageNumber

public void setShowPageNumber(boolean show)

getMimeType

public String getMimeType()

updateRowAndPageHeight

public void updateRowAndPageHeight(HeighCalculator hCalc)

getSourceTemplate

public String getSourceTemplate()

setSourceTemplate

public void setSourceTemplate(String sourceTemplate)

isPrintThroughPdf

public boolean isPrintThroughPdf()
Printing through conversion to PDF

Returns:
true if the sets printing through conversion to PDF
Since:
2.0

setPrintThroughPdf

public void setPrintThroughPdf(boolean printThroughPdf)
Printing through conversion to PDF

Parameters:
printThroughPdf -
Since:
2.0