/* * Copyright (C) 2013 by MHC SoftWare GmbH, All Rights Reserved. * * 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. * */ package com.MHC.propertyManager; /** * Abstrakte Klasse für Instanzzierung von "MhcProperties" *
*
* Beispiel: *
* {@code * public class appProperties extends MhcAppProperties * { * // Overrid * public void definePrpoerties() * { * setFileName("DateiName"); * * p().add("user",String.class,""); * p().add("pass",String.class,""); * p().add("unterbenutzer",Boolean.class,false); * p().add("load",Boolean.class,true); * * p().load(); * } * } * } ** * @see MhcProperties * * @author MHC SoftWare GmbH */ public abstract class MhcAppProperties { private static String fileName = null; private static MhcProperties properties = null; public Object clone() throws CloneNotSupportedException { throw new CloneNotSupportedException(); } /** * Setzt den Dateinamen des Propertyfiles, dieser ist ohne Endung * anzugeben * * @param pFileName Dateiname */ public static void setFileName(String pFileName) { fileName = pFileName; } /** * Lifert Referenz auf die eigentliche Properties-Klasse * * @return Referenz auf die Properties-Klasse */ public static MhcProperties p() { if(fileName == null) { throw new PropertiesFileNotSet("Properies file name not set."); } if(properties == null) { properties = new MhcProperties(fileName); } return properties; } /** Uncheckd RuntimeExceptions um die Methoden in default Construktoren verwendbar zu machen */ /** * RuntimeException: Wird geworfen wenn der Dateiname nicht gesetzt wurde */ public static class PropertiesFileNotSet extends RuntimeException { public PropertiesFileNotSet() { super(); } public PropertiesFileNotSet(Exception e) { super(); } public PropertiesFileNotSet(String s) { super(s); } } }