/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.nplusc.izc.tools.baseTools;

import java.util.prefs.Preferences;

/**
 *
 * @author LH
 */
public class HLTools
{
    public static void DebugHelperPrint(String msg,boolean dbgonly,String debugEnablePreference)
    {
        if(dbgonly)
            if(!Boolean.valueOf(Preferences.userRoot().get(debugEnablePreference, "false")))
            return;
        System.err.println(msg);
    }
    
    @SuppressWarnings("ManualArrayToCollectionCopy")//Quick and Dirty Hack
    public static Object[] truncateArray(Object[] toTrunc, int number, boolean fromBack)
    {
        //number++;//fucked up error!
        if (toTrunc.length - number < 1)//Error bei Zahlen <0
        {
            throw new IllegalArgumentException("Shortened Array to zero or lower!!!");
        }
        Object[] out = new Object[toTrunc.length - number];
        if (fromBack == true)//Hinten weg
        {
            for (int i = 0; i < toTrunc.length - number; i++)
            {
                out[i] = toTrunc[i];
            }
        }
        else
        {
            for (int i = 0; i > toTrunc.length - number; i++)
            {
                int j = i + number;
                out[i] = toTrunc[j];
            }
        }
        return out;
    }
}
