/** * Constructor * When using this constructor , * {@link #getGroup(int)} will return the corresponding Object depends on heads. * The return value of {@link #hasGroupfoot(int)} and {@link #getGroupfoot(int)} * are depends on foots. * * @param data a 2 dimension array to represent groups data * @param heads an array to represent head data of group * @param foots an array to represent foot data of group, if an element in this array is null, then * {@link #hasGroupfoot(int)} will return false in corresponding index. */ public SimpleGroupsModel(D[][] data, H[] heads, F[] foots) { this(data != null ? ArraysX.asList(data) : (List<List<D>>) null, heads != null ? ArraysX.asList(heads) : (List<H>) null, foots != null ? ArraysX.asList(foots) : (List<F>) null); }
/** * Concatenates the two specified generic array. * * <p>The array could be an array of objects or primitives. * * @param ary the array * @param ary1 the array * @return an array concatenating the ary and ary1 * @exception IllegalArgumentException if ary and ary1 component types are not compatible * @since 6.0.0 */ @SuppressWarnings("unchecked") public static final <T> T[] concat(T[] ary, T[] ary1) { return (T[])concat((Object)ary, (Object)ary1); }
/** * Duplicates the specified generic array. * @param ary the array * @return an array duplicated from ary * @exception IllegalArgumentException if ary is not any array * @exception IndexOutOfBoundsException if out of bounds * @since 6.0.0 */ public static final <T> T[] duplicate(T[] ary) { return duplicate(ary, 0, ary.length); }
private static Component[] merge(Component[] cs, Component c) { if (c != null) { cs = ArraysX.resize(cs, cs.length + 1); cs[cs.length - 1] = c; } return cs; }
/** * Shrink the specified array. It is similar to duplicate, except * it returns the previous instance if je==length && jb==0. * * @param ary the array * @param jb the beginning index (included) * @param je the ending index (excluded) * @return ary or an array duplicated from ary * @exception IllegalArgumentException if ary is not any array * @exception IndexOutOfBoundsException if out of bounds * @since 6.0.0 */ @SuppressWarnings("unchecked") public static final <T> T[] shrink(T[] ary, int jb, int je) { return (T[])shrink((Object)ary, jb, je); }
/** * Returns the octal String representation of a byte array with optional * prefix. The String is formed by making value[0] the leftmost three digits * and value[value.length-1] the rightmost three digits. * * @param array the byte array */ public final static String toOctalString(byte[] array, String prefix) { StringBuffer sb = new StringBuffer(array.length* (3 + (prefix == null ? 0 : prefix.length())) + 8); if (prefix == null) { for (int i=0; i< array.length; i++) { appendOctalDigits(sb, array[i]); } } else { for (int i=0; i< array.length; i++) { sb.append(prefix); appendOctalDigits(sb, array[i]); } } return sb.toString(); } /**
return ArraysX.toString((Object[])o); if (o instanceof int[]) return ArraysX.toString((int[])o); if (o instanceof short[]) return ArraysX.toString((short[])o); if (o instanceof long[]) return ArraysX.toString((long[])o); if (o instanceof double[]) return ArraysX.toString((double[])o); if (o instanceof byte[]) return ArraysX.toString((byte[])o); if (o instanceof boolean[]) return ArraysX.toString((boolean[])o); if (o instanceof char[]) return ArraysX.toString((char[])o); if (o instanceof float[]) return ArraysX.toString((float[])o);
/** Adds an object. */ synchronized public void add(T val) { Object[] ary = (Object[])ArraysX.resize(_ary, _ary.length + 1); ary[_ary.length] = val; _ary = ary; } /** Removes an object.
/** * @deprecated As of release 6.0.0, replaced with {@link #duplicate(Object)}. */ public static final Object clone(Object ary) { return duplicate(ary); }
/** * Constructor * When using this constructor , * {@link #getGroup(int)} will return the corresponding Object depends on heads. * The return value of {@link #hasGroupfoot(int)} and {@link #getGroupfoot(int)} * are depends on foots. * * <p>Notice that, for backward compatibility, the last argument is <code>closes</code>. * * @param data a 2 dimension array to represent groups data * @param heads an array to represent head data of group * @param foots an array to represent foot data of group, if an element in this array is null, then * {@link #hasGroupfoot(int)} will return false in corresponding index. * @param closes an array of boolean to represent close status of group. If not specified, then * {@link #isClose(int)} will return false in corresponding index(i.e. group is default to open) */ public SimpleGroupsModel(D[][] data, H[] heads, F[] foots, boolean[] closes) { this(data != null ? ArraysX.asList(data) : (List<List<D>>) null, heads != null ? ArraysX.asList(heads) : (List<H>) null, foots != null ? ArraysX.asList(foots) : (List<F>) null, closes); }
/** * Resizes the specified generic array. * @since 6.0.0 */ @SuppressWarnings("unchecked") public static final <T> T[] resize(T[] ary, int size) { return (T[])resize((Object)ary, size); }
/** Adds the specified attribute to the annotation. * * @param name the attribute name. "value" is assumed if name is null or empty. * @param value the attribute value. If null, "" is assumed (not removal). */ private void addAttribute(String name, String[] value) { if (name == null || name.length() == 0) name = "value"; if (value == null) value = new String[0]; if (_attrs == null) { _attrs = new LinkedHashMap<String, String[]>(4); } else { final String[] oldval = _attrs.get(name); if (oldval != null) value = ArraysX.concat(oldval, value); } _attrs.put(name, value); }
/** * Constructor. * It makes a copy of the specified array (i.e., not live). * * <p>Notice that if the data is static or not shared, it is better to * use <code>ListModelArray(array, true)</code> instead, since * making a copy is slower. */ public ListModelArray(E[] array) { _array = ArraysX.duplicate(array); }
/** * Returns a two dimensional mutable list. * <p> Never be null. * @param ary the two dimensional data array * @return a two dimensional list view of the specified array * @since 6.0.1 * @see #asList(Object[]) */ @SuppressWarnings("unchecked") public static final <T> List<List<T>> asList(T[][] ary) { if (ary == null) return Collections.EMPTY_LIST; List<List<T>> list = new ArrayList<List<T>>(ary.length); for (T[] t : ary) list.add(asList(t)); return list; } /**
/** * Duplicates the specified generic array. * * <p>The array could be an array of objects or primitives. * * @param ary the array * @param jb the beginning index (included) * @param je the ending index (excluded) * @return an array duplicated from ary * @exception IllegalArgumentException if ary is not any array * @exception IndexOutOfBoundsException if out of bounds * @since 6.0.0 */ @SuppressWarnings("unchecked") public static final <T> T[] duplicate(T[] ary, int jb, int je) { return (T[])duplicate((Object)ary, jb, je); } /**
/** @deprecated As of release 6.0.1, replaced with {@link #sortGroupData(Object, List, Comparator, boolean, int)}. */ protected void sortGroupData(Object group, D[] groupdata, Comparator<D> cmpr, boolean ascending, int colIndex) { sortGroupData(group, ArraysX.asList(groupdata), cmpr, ascending, colIndex); }
/** Constructor. * * @param data the array to represent * @param live whether to have a 'live' {@link ListModel} on top of * the specified list. * If false, the content of the specified list is copied. * If true, this object is a 'facade' of the specified list, * i.e., when you add or remove items from this ListModelList, * the inner "live" list would be changed accordingly. * * However, it is not a good idea to modify <code>data</code> * once it is passed to this method with live is true, * since {@link Listbox} is not smart enough to handle it. * @since 2.4.1 */ public SimpleListModel(E[] data, boolean live) { _data = live ? data : ArraysX.duplicate(data); }
/** * Constructor * * @param array the array to represent * @param live whether to have a 'live' {@link ListModel} on top of * the specified array. * If false, the content of the specified array is copied. * If true, this object is a 'facade' of the specified array, * i.e., when you add or remove items from this {@link ListModelArray}, * the inner "live" array would be changed accordingly. * * However, it is not a good idea to modify <code>array</code> * if it is passed to this method with live is true, * since {@link Listbox} is not smart enough to handle it. * Instead, modify it thru this object. * @since 2.4.0 */ public ListModelArray(E[] array, boolean live) { _array = live ? array : ArraysX.duplicate(array); }
/** * Duplicates the specified array. * @param ary the array * @return an array duplicated from ary * @exception IllegalArgumentException if ary is not any array * @exception IndexOutOfBoundsException if out of bounds */ public static final Object duplicate(Object ary) { return duplicate(ary, 0, Array.getLength(ary)); } /**
public Object clone() { DialModel clone = (DialModel) super.clone(); if (_bgRGB != null) clone._bgRGB = (int[]) ArraysX.duplicate(_bgRGB); if (_bgRGB1 != null) clone._bgRGB1 = (int[]) ArraysX.duplicate(_bgRGB1); if (_bgRGB2 != null) clone._bgRGB2 = (int[]) ArraysX.duplicate(_bgRGB2); if (_fgRGB != null) clone._fgRGB = (int[]) ArraysX.duplicate(_fgRGB); return clone; } }