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

com.vectorprint.configuration.EnhancedMap Maven / Gradle / Ivy

Go to download

This project is about configuration of applications and about parameterization of Objects. This library offers annotations (and annotation processors), parsers, typing, observing changes, serialization, cloning and more when working with settings and/or object parameters. Settings and its features can be declared using an xml format. The library offers syntax support for settings and parameters in a loosely coupled manner. You are not restricted to built in syntax, you can provide your own. At runtime this library tracks keys for which a default is used because they are not found in settings. Also it tracks unused keys. You can stack features for settings such as caching, preparing keys and values, readonlyness, threadsafety, helpsupport, reading / parsing from input. You can easily develop your own features for settings.

There is a newer version: 12.2
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.vectorprint.configuration;

/*
 * #%L
 * VectorPrintConfig3.0
 * %%
 * Copyright (C) 2011 - 2013 VectorPrint
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
import com.vectorprint.configuration.decoration.AbstractPropertiesDecorator;
import com.vectorprint.configuration.binding.settings.EnhancedMapBindingFactory;
import java.awt.Color;
import java.io.File;
import java.io.PrintStream;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * This interface is a suggested way to store values for settings as arrays of String and retrieve settings
 * in the type needed by applications. Values are arrays because support for multiple values will not require splitting intelligence.
 * 
 * @see Settings
 * @see AbstractPropertiesDecorator
 * @see EnhancedMapBindingFactory
 * @author Eduard Drenth at VectorPrint.nl
 */
public interface EnhancedMap extends Map, Cloneable, Serializable {

   boolean getBooleanProperty(Boolean defaultValue, String... keys);

   Class getClassProperty(Class defaultValue, String... keys) throws ClassNotFoundException;
   
   Class[] getClassProperties(Class[] defaultValue, String... keys) throws ClassNotFoundException;

   Pattern getRegexProperty(Pattern defaultValue, String... keys);
   
   Pattern[] getRegexProperties(Pattern[] defaultValue, String... keys);

   Color getColorProperty(Color defaultValue, String... keys);

   double getDoubleProperty(Double defaultValue, String... keys);

   short getShortProperty(Short defaultValue, String... keys);

   char getCharProperty(Character defaultValue, String... keys);

   byte getByteProperty(Byte defaultValue, String... keys);

   short[] getShortProperties(short[] defaultValue, String... keys);

   char[] getCharProperties(char[] defaultValue, String... keys);

   byte[] getByteProperties(byte[] defaultValue, String... keys);

   float getFloatProperty(Float defaultValue, String... keys);

   int getIntegerProperty(Integer defaultValue, String... keys);

   long getLongProperty(Long defaultValue, String... keys);

   String getProperty(String defaultValue, String... keys);

   URL getURLProperty(URL defaultValue, String... keys) throws MalformedURLException;
   
   File getFileProperty(File defaultValue, String... keys);

   File[] getFileProperties(File[] defaultValue, String... keys);

   String[] getStringProperties(String[] defaultValue, String... keys);

   URL[] getURLProperties(URL[] defaultValue, String... keys) throws MalformedURLException;

   float[] getFloatProperties(float[] defaultValue, String... keys);

   double[] getDoubleProperties(double[] defaultValue, String... keys);

   int[] getIntegerProperties(int[] defaultValue, String... keys);

   long[] getLongProperties(long[] defaultValue, String... keys);

   boolean[] getBooleanProperties(boolean[] defaultValue, String... keys);

   Color[] getColorProperties(Color[] defaultValue, String... keys);

   Date getDateProperty(Date defaultValue, String... keys);

   Date[] getDateProperties(Date[] defaultValue, String... keys);
   
   /**
    * look for a setting, if one of the keys is found return its value.
    * @param 
    * @param defaultValue
    * @param clazz
    * @param keys
    * @return 
    */
    T getGenericProperty(T defaultValue, Class clazz, String... keys);

   PropertyHelp getHelp(String key);

   Map getHelp();

   String printHelp();

   void listProperties(PrintStream ps);

   public void setHelp(Map h);

   public EnhancedMap clone() throws CloneNotSupportedException;

   /**
    * return a collection of keys not used sofar in the settings.
    *
    * @return
    */
   public Collection getUnusedKeys();

   /**
    * return a collection of keys not present in the settings, for which defaults where used instead.
    *
    * @return
    */
   public Collection getKeysNotPresent();

   /**
    * each set of properties is suggested to have a unique id
    *
    * @return
    */
   String getId();
   void setId(String id);

   String[] put(String key, String value);
   
   void put(Map m);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy