LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / reportbuilder / java / org / libreoffice / report / util / DefaultJobProperties.java
blobce0ea8dce1313735271cdadc5e56b06a53d43e41
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package org.libreoffice.report.util;
20 import org.libreoffice.report.JobDefinitionException;
21 import org.libreoffice.report.JobProperties;
22 import org.libreoffice.report.ReportEngineMetaData;
24 import java.util.HashMap;
25 import java.util.Map;
28 public class DefaultJobProperties implements JobProperties
31 private final ReportEngineMetaData metaData;
32 private final Map<String,Object> properties;
34 public DefaultJobProperties(final ReportEngineMetaData metaData)
36 if (metaData == null)
38 throw new NullPointerException();
40 this.properties = new HashMap<String,Object>();
41 this.metaData = metaData;
44 public Object getProperty(final String key)
46 return properties.get(key);
49 public void setProperty(final String key, final Object value)
50 throws JobDefinitionException
52 final Class type = metaData.getParameterType(key);
53 if (type == null)
55 throw new JobDefinitionException("The parameter name is not known: " + key);
57 if (!type.isInstance(value))
59 throw new JobDefinitionException("The parameter value is not understood");
62 this.properties.put(key, value);
65 public JobProperties copy()
67 final DefaultJobProperties props = new DefaultJobProperties(metaData);
68 props.properties.putAll(properties);
69 return props;