Class ConfigDescriptionModel
- java.lang.Object
-
- javax.swing.AbstractListModel
-
- org.pentaho.reporting.tools.configeditor.model.ConfigDescriptionModel
-
- All Implemented Interfaces:
Serializable
,ListModel
public class ConfigDescriptionModel extends AbstractListModel
This list model implementation collects all config description entries defined in JFreeReport. This model is used to create a configuration key definition; it directly manipulates the metadata for the keys as stored in the config-description.xml file.- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.swing.AbstractListModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description ConfigDescriptionModel()
Creates a new, initially empty ConfigDescriptionModel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(ConfigDescriptionEntry entry)
Adds the given entry to the end of the list.boolean
contains(ConfigDescriptionEntry entry)
Checks whether the given entry is already contained in this list.ConfigDescriptionEntry
get(int pos)
Returns the entry stored on the given list position.Object
getElementAt(int index)
Returns the value at the specified index.int
getSize()
Returns the length of the list.void
importFromConfig(org.pentaho.reporting.libraries.base.config.Configuration config)
Imports all entries from the given report configuration.int
indexOf(ConfigDescriptionEntry entry)
Returns the index of the given entry or -1, if the entry is not in the list.void
load(InputStream in)
Loads the entries from the given xml file.void
remove(ConfigDescriptionEntry entry)
Removes the given entry from the list.void
removeAll(int[] indices)
void
save(OutputStream out, String encoding)
Saves the model into an xml file.void
sort()
Sorts the entries of the list.ConfigDescriptionEntry[]
toArray()
Returns the contents of this model as object array.void
updated()
Fires an contents changed event for all elements in the list.-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
-
-
-
Method Detail
-
add
public void add(ConfigDescriptionEntry entry)
Adds the given entry to the end of the list.- Parameters:
entry
- the new entry.
-
remove
public void remove(ConfigDescriptionEntry entry)
Removes the given entry from the list.- Parameters:
entry
- the entry that should be removed.
-
removeAll
public void removeAll(int[] indices)
-
get
public ConfigDescriptionEntry get(int pos)
Returns the entry stored on the given list position.- Parameters:
pos
- the position- Returns:
- the entry
- Throws:
IndexOutOfBoundsException
- if the position is invalid.
-
updated
public void updated()
Fires an contents changed event for all elements in the list.
-
indexOf
public int indexOf(ConfigDescriptionEntry entry)
Returns the index of the given entry or -1, if the entry is not in the list.- Parameters:
entry
- the entry whose position should be searched.- Returns:
- the position of the entry
-
contains
public boolean contains(ConfigDescriptionEntry entry)
Checks whether the given entry is already contained in this list.- Parameters:
entry
- the entry that should be checked.- Returns:
- true, if the entry is already added, false otherwise.
-
sort
public void sort()
Sorts the entries of the list. Be aware that calling this method does not fire an updat event; you have to do this manually.
-
toArray
public ConfigDescriptionEntry[] toArray()
Returns the contents of this model as object array.- Returns:
- the contents of the model as array.
-
getSize
public int getSize()
Returns the length of the list.- Returns:
- the length of the list
-
getElementAt
public Object getElementAt(int index)
Returns the value at the specified index.- Parameters:
index
- the requested index- Returns:
- the value at
index
-
importFromConfig
public void importFromConfig(org.pentaho.reporting.libraries.base.config.Configuration config)
Imports all entries from the given report configuration. Only new entries will be added to the list. This does not add report properties supplied via the System.properties.- Parameters:
config
- the report configuration from where to add the entries.
-
load
public void load(InputStream in) throws IOException, SAXException, ParserConfigurationException
Loads the entries from the given xml file. The file must be in the format of the config-description.xml file.- Parameters:
in
- the inputstream from where to read the file- Throws:
IOException
- if an error occured while reading the fileSAXException
- if an XML parse error occurs.ParserConfigurationException
- if the XML parser could not be initialized.
-
save
public void save(OutputStream out, String encoding) throws IOException
Saves the model into an xml file.- Parameters:
out
- the target output stream.encoding
- the encoding of the content.- Throws:
IOException
- if an error occurs.
-
-