@Test public void testConvert() { Object[] s = new Object[]{"a", "b"}; String[] o = InformationSet.convert(s, String[].class); Object p = InformationSet.convert(o, Object[].class); assertTrue(Arrays.deepEquals(s, (Object[]) p)); }
public static <T> T convert(Object obj, Class<T> tclass) { if (obj == null) { return null; } if (tclass.isInstance(obj)) { return (T) obj; } else if (tclass.isArray()) { Class oclass = obj.getClass(); if (oclass.isArray()) { int len = Array.getLength(obj); Object nobj = Array.newInstance(tclass.getComponentType(), len); try { System.arraycopy(obj, 0, nobj, 0, len); return (T) nobj; } catch (ArrayStoreException ex) { return null; } } } return null; }
InformationSet implements Cloneable { public static <T> T convert(Object obj, Class<T> tclass) { if (obj == null) { return null; } if (tclass.isInstance(obj)) { return (T) obj; } else if (tclass.isArray()) { Class oclass = obj.getClass(); if (oclass.isArray()) { int len = Array.getLength(obj); Object nobj = Array.newInstance(tclass.getComponentType(), len); try { System.arraycopy(obj, 0, nobj, 0, len); return (T) nobj; } catch (ArrayStoreException ex) { return null; } } } return null; } }
InformationSet implements Cloneable { public static <T> T convert(Object obj, Class<T> tclass) { if (obj == null) { return null; } if (tclass.isInstance(obj)) { return (T) obj; } else if (tclass.isArray()) { Class oclass = obj.getClass(); if (oclass.isArray()) { int len = Array.getLength(obj); Object nobj = Array.newInstance(tclass.getComponentType(), len); try { System.arraycopy(obj, 0, nobj, 0, len); return (T) nobj; } catch (ArrayStoreException ex) { return null; } } } return null; } InformationSet(); }
InformationSet implements Cloneable { public static <T> T convert(Object obj, Class<T> tclass) { if (obj == null) { return null; } if (tclass.isInstance(obj)) { return (T) obj; } else if (tclass.isArray()) { Class oclass = obj.getClass(); if (oclass.isArray()) { int len = Array.getLength(obj); Object nobj = Array.newInstance(tclass.getComponentType(), len); try { System.arraycopy(obj, 0, nobj, 0, len); return (T) nobj; } catch (ArrayStoreException ex) { return null; } } } return null; } InformationSet(); static String concatenate(String... s); static boolean isPrefix(String fullName, String prefix); static boolean hasWildCards(String str); static String removePrefix(String name); static String simpleName(String fullName); static String[] split(String fullName); static boolean wildCompare(String wString, String curString); static String item(String prefix, String name); @Override InformationSet clone(); boolean isLocked(); void setLocked(boolean locked); @SuppressWarnings("unchecked") boolean set(final Information<?> info); @SuppressWarnings("unchecked") boolean add(final Information<?> info); boolean add(final String name, final S info); boolean add(final String[] deepname, final S info); boolean set(final String[] deepname, final S info); boolean add(final Enum e, final S info); void addWarning(String string); void addError(String string); void clear(); void copy(InformationSet info); @NewObject String[] content(); @SuppressWarnings("unchecked") S deepSearch(String name, Class<S> sclass); List<Information<S>> deepSelect(String wc, Class<S> sclass); List<Information<S>> deepSelect(Class<S> sclass); List<String> errors(); void fillDictionary(String prefix, List<String> items); void fillDictionary(String prefix, Map<String, Class> items); void fillDictionary(String prefix, List<String> items,
            Class<T> tclass); Object get(final String name); Object get(final Enum e); @SuppressWarnings("unchecked") S get(final String name, final Class<S> sclass); S get(final Enum e, final Class<S> sclass); List<String> getDictionary(); List<String> getDictionary(Class<T> tclass); InformationSet getSubSet(final String name); @SuppressWarnings("unchecked") @NewObject List<Information<?>> items(); void remove(final String name); void remove(final Enum e); S search(final String fullName, final Class<S> sclass); S search(final String[] names, final Class<S> sclass); @SuppressWarnings("unchecked") @NewObject List<Information<S>> select(final Class<S> sclass); @NewObject List<Information<Object>> select(final String wc); @SuppressWarnings("unchecked") @NewObject List<Information<S>> select(final String wc,
            final Class<S> sclass); @SuppressWarnings("unchecked") boolean set(final String name, final S info); boolean set(final Enum e, final S info); InformationSet subSet(final String name); List<String> warnings(); void setContent(String type, String version); String getContentType(); String getContentVersion(); boolean isContent(String type, String version); InformationSet filter(List<String> dictionary); boolean merge(InformationSet info); boolean update(InformationSet info); boolean addLog(final String name, final S info); boolean setLog(final String name, final S info); InformationSet getLog(); static T convert(Object obj, Class<T> tclass); }
InformationSet implements Cloneable { public static <T> T convert(Object obj, Class<T> tclass) { if (obj == null) { return null; } if (tclass.isInstance(obj)) { return (T) obj; } else if (tclass.isArray()) { Class oclass = obj.getClass(); if (oclass.isArray()) { int len = Array.getLength(obj); Object nobj = Array.newInstance(tclass.getComponentType(), len); try { System.arraycopy(obj, 0, nobj, 0, len); return (T) nobj; } catch (ArrayStoreException ex) { return null; } } } return null; } InformationSet(); static String concatenate(String... s); static boolean isPrefix(String fullName, String prefix); static boolean hasWildCards(String str); static String removePrefix(String name); static String simpleName(String fullName); static String[] split(String fullName); static boolean wildCompare(String wString, String curString); static String item(String prefix, String name); @Override InformationSet clone(); boolean isLocked(); void setLocked(boolean locked); @SuppressWarnings("unchecked") boolean set(final Information<?> info); @SuppressWarnings("unchecked") boolean add(final Information<?> info); boolean add(final String name, final S info); boolean add(final String[] deepname, final S info); boolean set(final String[] deepname, final S info); boolean add(final Enum e, final S info); void addWarning(String string); void addError(String string); void clear(); void copy(InformationSet info); @NewObject String[] content(); @SuppressWarnings("unchecked") S deepSearch(String name, Class<S> sclass); List<Information<S>> deepSelect(String wc, Class<S> sclass); List<Information<S>> deepSelect(Class<S> sclass); List<String> errors(); void fillDictionary(String prefix, List<String> items); void fillDictionary(String prefix, Map<String, Class> items); void fillDictionary(String prefix, List<String> items,
            Class<T> tclass); Object get(final String name); Object get(final Enum e); @SuppressWarnings("unchecked") S get(final String name, final Class<S> sclass); S get(final Enum e, final Class<S> sclass); List<String> getDictionary(); List<String> getDictionary(Class<T> tclass); InformationSet getSubSet(final String name); @SuppressWarnings("unchecked") @NewObject List<Information<?>> items(); void remove(final String name); void remove(final Enum e); S search(final String fullName, final Class<S> sclass); S search(final String[] names, final Class<S> sclass); @SuppressWarnings("unchecked") @NewObject List<Information<S>> select(final Class<S> sclass); @NewObject List<Information<Object>> select(final String wc); @SuppressWarnings("unchecked") @NewObject List<Information<S>> select(final String wc,
            final Class<S> sclass); @SuppressWarnings("unchecked") boolean set(final String name, final S info); boolean set(final Enum e, final S info); InformationSet subSet(final String name); List<String> warnings(); void setContent(String type, String version); String getContentType(); String getContentVersion(); boolean isContent(String type, String version); InformationSet filter(List<String> dictionary); boolean merge(InformationSet info); boolean update(InformationSet info); boolean addLog(final String name, final S info); boolean setLog(final String name, final S info); InformationSet getLog(); static T convert(Object obj, Class<T> tclass); static final char SEP; static final String STRSEP; static final String CONTENT; static final String LOG; static final String ERRORS; }