All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mapfish.print.attribute.PrimitiveAttribute Maven / Gradle / Ivy

package org.mapfish.print.attribute;

import org.json.JSONException;
import org.json.JSONWriter;
import org.mapfish.print.config.Configuration;
import org.mapfish.print.config.Template;

import java.util.List;

/**
 * A type of attribute whose value is a primitive type.
 * 
    *
  • {@link java.lang.String}
  • *
  • {@link java.lang.String[]}
  • *
  • {@link java.lang.Integer}
  • *
  • {@link java.lang.Double}
  • *
  • {@link java.lang.Boolean}
  • *
* * @param The value type of the attribute */ public abstract class PrimitiveAttribute implements Attribute { private Class valueClass; /** The default value. */ protected Value defaultValue; private String configName; /** * Constructor. * * @param valueClass the type of the value of this attribute */ public PrimitiveAttribute(final Class valueClass) { this.valueClass = valueClass; } public final Class getValueClass() { return this.valueClass; } /** *

A default value for this attribute.

* @param value The default value. */ public abstract void setDefault(final Value value); public final Value getDefault() { return this.defaultValue; } @Override public final void setConfigName(final String configName) { this.configName = configName; } @Override public void validate(final List validationErrors, final Configuration configuration) { // no checks required } /** * Validation of the value from a request. * @param value The value from a request. */ public void validateValue(final Object value) { } @Override public final void printClientConfig(final JSONWriter json, final Template template) throws JSONException { json.key(ReflectiveAttribute.JSON_NAME).value(this.configName); json.key(ReflectiveAttribute.JSON_ATTRIBUTE_TYPE).value(clientConfigTypeDescription()); if (getDefault() != null) { json.key(ReflectiveAttribute.JSON_ATTRIBUTE_DEFAULT).value(getDefault()); } } /** * Returns a string that is a technical description of the type. In other words, a string that the client software * (user of the capabilities response) can use to create a request or UI. */ protected String clientConfigTypeDescription() { return this.valueClass.getSimpleName(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy