diff options
Diffstat (limited to 'reportbuilder/java/com/sun/star/report/util')
4 files changed, 227 insertions, 236 deletions
diff --git a/reportbuilder/java/com/sun/star/report/util/DefaultJobProperties.java b/reportbuilder/java/com/sun/star/report/util/DefaultJobProperties.java index 9cd70b1c69f0..096882a29c02 100644 --- a/reportbuilder/java/com/sun/star/report/util/DefaultJobProperties.java +++ b/reportbuilder/java/com/sun/star/report/util/DefaultJobProperties.java @@ -27,8 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.util; import java.util.HashMap; @@ -40,44 +38,45 @@ import java.util.Map; public class DefaultJobProperties implements JobProperties { - private final ReportEngineMetaData metaData; - private final Map properties; - public DefaultJobProperties (final ReportEngineMetaData metaData) - { - if (metaData == null) + private final ReportEngineMetaData metaData; + private final Map properties; + + public DefaultJobProperties(final ReportEngineMetaData metaData) { - throw new NullPointerException(); + if (metaData == null) + { + throw new NullPointerException(); + } + this.properties = new HashMap(); + this.metaData = metaData; } - this.properties = new HashMap(); - this.metaData = metaData; - } - public Object getProperty (final String key) - { - return properties.get(key); - } - - public void setProperty (final String key, final Object value) - throws JobDefinitionException - { - final Class type = metaData.getParameterType(key); - if (type == null) + public Object getProperty(final String key) { - throw new JobDefinitionException("The parameter name is not known: " + key); + return properties.get(key); } - if (!type.isInstance(value)) + + public void setProperty(final String key, final Object value) + throws JobDefinitionException { - throw new JobDefinitionException("The parameter value is not understood"); - } + final Class type = metaData.getParameterType(key); + if (type == null) + { + throw new JobDefinitionException("The parameter name is not known: " + key); + } + if (!type.isInstance(value)) + { + throw new JobDefinitionException("The parameter value is not understood"); + } - this.properties.put(key, value); - } + this.properties.put(key, value); + } - public JobProperties copy() - { - final DefaultJobProperties props = new DefaultJobProperties(metaData); - props.properties.putAll(properties); - return props; - } + public JobProperties copy() + { + final DefaultJobProperties props = new DefaultJobProperties(metaData); + props.properties.putAll(properties); + return props; + } } diff --git a/reportbuilder/java/com/sun/star/report/util/DefaultParameterMap.java b/reportbuilder/java/com/sun/star/report/util/DefaultParameterMap.java index 29ee586d5075..f6766a53f1a9 100644 --- a/reportbuilder/java/com/sun/star/report/util/DefaultParameterMap.java +++ b/reportbuilder/java/com/sun/star/report/util/DefaultParameterMap.java @@ -27,8 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.util; import java.util.HashMap; @@ -38,92 +36,90 @@ import java.util.Map; public class DefaultParameterMap implements ParameterMap { - private final Map backend; - - public DefaultParameterMap () - { - backend = new HashMap(); - } - public void clear () - { - backend.clear(); - } + private final Map backend; - /** - * Retrieves the value stored for a key in this properties collection. - * - * @param key the property key. - * @return The stored value, or <code>null</code> if the key does not exist in this - * collection. - */ - public Object get (final String key) - { - if (key == null) + public DefaultParameterMap() { - throw new NullPointerException - ("DefaultParameterMap.get (..): Parameter 'key' must not be null"); + backend = new HashMap(); } - return backend.get(key); - } - /** - * Retrieves the value stored for a key in this properties collection, and returning the - * default value if the key was not stored in this properties collection. - * - * @param key the property key. - * @param defaultValue the default value to be returned when the key is not stored in - * this properties collection. - * @return The stored value, or the default value if the key does not exist in this - * collection. - */ - public Object get (final String key, final Object defaultValue) - { - if (key == null) + public void clear() { - throw new NullPointerException - ("DefaultParameterMap.get (..): Parameter 'key' must not be null"); + backend.clear(); } - final Object o = this.backend.get(key); - if (o == null) + + /** + * Retrieves the value stored for a key in this properties collection. + * + * @param key the property key. + * @return The stored value, or <code>null</code> if the key does not exist in this + * collection. + */ + public Object get(final String key) { - return defaultValue; + if (key == null) + { + throw new NullPointerException("DefaultParameterMap.get (..): Parameter 'key' must not be null"); + } + return backend.get(key); } - return o; - } - - public String[] keys () - { - return (String[]) this.backend.keySet().toArray(new String[backend.size()]); - } - /** - * Adds a property to this properties collection. If a property with the given name - * exist, the property will be replaced with the new value. If the value is null, the - * property will be removed. - * - * @param key the property key. - * @param value the property value. - */ - public void put (final String key, final Object value) - { - if (key == null) + /** + * Retrieves the value stored for a key in this properties collection, and returning the + * default value if the key was not stored in this properties collection. + * + * @param key the property key. + * @param defaultValue the default value to be returned when the key is not stored in + * this properties collection. + * @return The stored value, or the default value if the key does not exist in this + * collection. + */ + public Object get(final String key, final Object defaultValue) { - throw new NullPointerException - ("ReportProperties.put (..): Parameter 'key' must not be null"); + if (key == null) + { + throw new NullPointerException("DefaultParameterMap.get (..): Parameter 'key' must not be null"); + } + final Object o = this.backend.get(key); + if (o == null) + { + return defaultValue; + } + return o; } - if (value == null) + + public String[] keys() { - this.backend.remove(key); + return (String[]) this.backend.keySet().toArray(new String[backend.size()]); } - else + + /** + * Adds a property to this properties collection. If a property with the given name + * exist, the property will be replaced with the new value. If the value is null, the + * property will be removed. + * + * @param key the property key. + * @param value the property value. + */ + public void put(final String key, final Object value) { - this.backend.put(key, value); + if (key == null) + { + throw new NullPointerException("ReportProperties.put (..): Parameter 'key' must not be null"); + } + if (value == null) + { + this.backend.remove(key); + } + else + { + this.backend.put(key, value); + } } - } - public int size () - { - return this.backend.size(); - } + public int size() + { + return this.backend.size(); + } } diff --git a/reportbuilder/java/com/sun/star/report/util/DefaultReportJobDefinition.java b/reportbuilder/java/com/sun/star/report/util/DefaultReportJobDefinition.java index f9e7420d600a..83ea4eb0eedc 100644 --- a/reportbuilder/java/com/sun/star/report/util/DefaultReportJobDefinition.java +++ b/reportbuilder/java/com/sun/star/report/util/DefaultReportJobDefinition.java @@ -27,8 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.util; import com.sun.star.report.DataSourceFactory; @@ -43,81 +41,79 @@ import com.sun.star.report.ReportJobDefinition; public class DefaultReportJobDefinition implements ReportJobDefinition { - public static final String OUTPUT_TYPE = "output-type"; - - private final DefaultParameterMap parameters; - private final DefaultJobProperties properties; - - public DefaultReportJobDefinition (final ReportEngineMetaData metaData) - { - this.parameters = new DefaultParameterMap(); - this.properties = new DefaultJobProperties(metaData); - } - - public void setDataSourceFactory (final DataSourceFactory dataSourceFactory) - throws JobDefinitionException - { - this.properties.setProperty(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY, dataSourceFactory); - } - - public DataSourceFactory getDataSourceFactory () - { - return (DataSourceFactory) this.properties.getProperty(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY); - } - - public InputRepository getInputRepository () - { - return (InputRepository) - this.properties.getProperty(ReportEngineParameterNames.INPUT_REPOSITORY); - } - - public void setInputRepository (final InputRepository inputRepository) - throws JobDefinitionException - { - this.properties.setProperty(ReportEngineParameterNames.INPUT_REPOSITORY, inputRepository); - } - - public OutputRepository getOutputRepository () - { - return (OutputRepository) - this.properties.getProperty(ReportEngineParameterNames.OUTPUT_REPOSITORY); - } - - public void setOutputRepository (final OutputRepository outputRepository) - throws JobDefinitionException - { - this.properties.setProperty(ReportEngineParameterNames.OUTPUT_REPOSITORY, outputRepository); - } - - /** - * The parameters of the root report definition. The parameters for the subreports are - * defined using mappings, it would not make sense to define them here. - * - * @return a map container for query parameters. - */ - public ParameterMap getQueryParameters () - { - return parameters; - } - - public void setReportDefinitionName (final String reportDefinitionName) - throws JobDefinitionException - { - this.properties.setProperty(ReportEngineParameterNames.INPUT_NAME, reportDefinitionName); - } - - /** - * The name under which we can load the report definition. - * - * @return the report definition's name. - */ - public String getReportDefinitionName () - { - return (String) this.properties.getProperty(ReportEngineParameterNames.INPUT_NAME); - } - public JobProperties getProcessingParameters () - { - return properties; - } + public static final String OUTPUT_TYPE = "output-type"; + private final DefaultParameterMap parameters; + private final DefaultJobProperties properties; + + public DefaultReportJobDefinition(final ReportEngineMetaData metaData) + { + this.parameters = new DefaultParameterMap(); + this.properties = new DefaultJobProperties(metaData); + } + + public void setDataSourceFactory(final DataSourceFactory dataSourceFactory) + throws JobDefinitionException + { + this.properties.setProperty(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY, dataSourceFactory); + } + + public DataSourceFactory getDataSourceFactory() + { + return (DataSourceFactory) this.properties.getProperty(ReportEngineParameterNames.INPUT_DATASOURCE_FACTORY); + } + + public InputRepository getInputRepository() + { + return (InputRepository) this.properties.getProperty(ReportEngineParameterNames.INPUT_REPOSITORY); + } + + public void setInputRepository(final InputRepository inputRepository) + throws JobDefinitionException + { + this.properties.setProperty(ReportEngineParameterNames.INPUT_REPOSITORY, inputRepository); + } + + public OutputRepository getOutputRepository() + { + return (OutputRepository) this.properties.getProperty(ReportEngineParameterNames.OUTPUT_REPOSITORY); + } + + public void setOutputRepository(final OutputRepository outputRepository) + throws JobDefinitionException + { + this.properties.setProperty(ReportEngineParameterNames.OUTPUT_REPOSITORY, outputRepository); + } + + /** + * The parameters of the root report definition. The parameters for the subreports are + * defined using mappings, it would not make sense to define them here. + * + * @return a map container for query parameters. + */ + public ParameterMap getQueryParameters() + { + return parameters; + } + + public void setReportDefinitionName(final String reportDefinitionName) + throws JobDefinitionException + { + this.properties.setProperty(ReportEngineParameterNames.INPUT_NAME, reportDefinitionName); + } + + /** + * The name under which we can load the report definition. + * + * @return the report definition's name. + */ + public String getReportDefinitionName() + { + return (String) this.properties.getProperty(ReportEngineParameterNames.INPUT_NAME); + } + + public JobProperties getProcessingParameters() + { + return properties; + } } diff --git a/reportbuilder/java/com/sun/star/report/util/ManifestWriter.java b/reportbuilder/java/com/sun/star/report/util/ManifestWriter.java index 9fab3246ae8f..c07e7ae0e262 100644 --- a/reportbuilder/java/com/sun/star/report/util/ManifestWriter.java +++ b/reportbuilder/java/com/sun/star/report/util/ManifestWriter.java @@ -27,7 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - package com.sun.star.report.util; import java.util.HashMap; @@ -52,71 +51,72 @@ import com.sun.star.report.OutputRepository; public class ManifestWriter { // need this two strings other it breaks the ooo build :-( - public static final String MANIFEST_NS = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"; - public static final String TAG_DEF_PREFIX = "com.sun.star.report.pentaho.output."; - private final Map entries; - public ManifestWriter() - { - entries = new HashMap(); - } + public static final String MANIFEST_NS = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"; + public static final String TAG_DEF_PREFIX = "com.sun.star.report.pentaho.output."; + private final Map entries; - public void addEntry(final String fullPath, final String mimeType) - { - if (fullPath == null) + public ManifestWriter() { - throw new NullPointerException(); + entries = new HashMap(); } - if (mimeType == null) + + public void addEntry(final String fullPath, final String mimeType) { - throw new NullPointerException(); + if (fullPath == null) + { + throw new NullPointerException(); + } + if (mimeType == null) + { + throw new NullPointerException(); + } + if ("META-INF/manifest.xml".equals(fullPath)) + { + return; + } + entries.put(fullPath, mimeType); } - if ("META-INF/manifest.xml".equals(fullPath)) + + public boolean isEmpty() { - return; + return entries.isEmpty(); } - entries.put(fullPath, mimeType); - } - - public boolean isEmpty() - { - return entries.isEmpty(); - } - public void write(final OutputRepository outputRepository) throws IOException - { - if (isEmpty()) + public void write(final OutputRepository outputRepository) throws IOException { - return; - } + if (isEmpty()) + { + return; + } - final DefaultTagDescription tagDescription = new DefaultTagDescription(); - tagDescription.configure(JFreeReportBoot.getInstance().getGlobalConfig(), - TAG_DEF_PREFIX); + final DefaultTagDescription tagDescription = new DefaultTagDescription(); + tagDescription.configure(JFreeReportBoot.getInstance().getGlobalConfig(), + TAG_DEF_PREFIX); - final OutputStream manifestOutputStream = - outputRepository.createOutputStream("META-INF/manifest.xml", "text/xml"); + final OutputStream manifestOutputStream = + outputRepository.createOutputStream("META-INF/manifest.xml", "text/xml"); - final OutputStreamWriter writer = new OutputStreamWriter(manifestOutputStream, "UTF-8"); - final XmlWriter xmlWriter = new XmlWriter(writer, tagDescription); - xmlWriter.setAlwaysAddNamespace(true); - xmlWriter.writeXmlDeclaration("UTF-8"); + final OutputStreamWriter writer = new OutputStreamWriter(manifestOutputStream, "UTF-8"); + final XmlWriter xmlWriter = new XmlWriter(writer, tagDescription); + xmlWriter.setAlwaysAddNamespace(true); + xmlWriter.writeXmlDeclaration("UTF-8"); - final AttributeList rootAttributes = new AttributeList(); - rootAttributes.addNamespaceDeclaration("manifest", MANIFEST_NS); - xmlWriter.writeTag(MANIFEST_NS, "manifest", rootAttributes, XmlWriterSupport.OPEN); + final AttributeList rootAttributes = new AttributeList(); + rootAttributes.addNamespaceDeclaration("manifest", MANIFEST_NS); + xmlWriter.writeTag(MANIFEST_NS, "manifest", rootAttributes, XmlWriterSupport.OPEN); - final Iterator iterator = entries.entrySet().iterator(); - while (iterator.hasNext()) - { - final Map.Entry entry = (Map.Entry) iterator.next(); - final AttributeList entryAttrs = new AttributeList(); - entryAttrs.setAttribute(MANIFEST_NS, "media-type", (String) entry.getValue()); - entryAttrs.setAttribute(MANIFEST_NS, "full-path", (String) entry.getKey()); - xmlWriter.writeTag(MANIFEST_NS, "file-entry", entryAttrs, XmlWriterSupport.CLOSE); - } + final Iterator iterator = entries.entrySet().iterator(); + while (iterator.hasNext()) + { + final Map.Entry entry = (Map.Entry) iterator.next(); + final AttributeList entryAttrs = new AttributeList(); + entryAttrs.setAttribute(MANIFEST_NS, "media-type", (String) entry.getValue()); + entryAttrs.setAttribute(MANIFEST_NS, "full-path", (String) entry.getKey()); + xmlWriter.writeTag(MANIFEST_NS, "file-entry", entryAttrs, XmlWriterSupport.CLOSE); + } - xmlWriter.writeCloseTag(); - xmlWriter.close(); - } + xmlWriter.writeCloseTag(); + xmlWriter.close(); + } } |