java类java.lang.reflect.Array的实例源码

MLetObjectInputStream.java 文件源码 项目:OpenJSharp 阅读 44 收藏 0 点赞 0 评论 0
/**
 * Use the given ClassLoader rather than using the system class
 */
@Override
protected Class<?> resolveClass(ObjectStreamClass objectstreamclass)
    throws IOException, ClassNotFoundException {

    String s = objectstreamclass.getName();
    if (s.startsWith("[")) {
        int i;
        for (i = 1; s.charAt(i) == '['; i++);
        Class<?> class1;
        if (s.charAt(i) == 'L') {
            class1 = loader.loadClass(s.substring(i + 1, s.length() - 1));
        } else {
            if (s.length() != i + 1)
                throw new ClassNotFoundException(s);
            class1 = primitiveType(s.charAt(i));
        }
        int ai[] = new int[i];
        for (int j = 0; j < i; j++)
            ai[j] = 0;

        return Array.newInstance(class1, ai).getClass();
    } else {
        return loader.loadClass(s);
    }
}
BehaviorProcessor.java 文件源码 项目:RxJava3-preview 阅读 44 收藏 0 点赞 0 评论 0
/**
 * Returns a typed array containing a snapshot of all values of the Subject.
 * <p>The method follows the conventions of Collection.toArray by setting the array element
 * after the last value to null (if the capacity permits).
 * <p>The method is thread-safe.
 * @param array the target array to copy values into if it fits
 * @return the given array if the values fit into it or a new array containing all values
 */
@SuppressWarnings("unchecked")
public T[] getValues(T[] array) {
    Object o = value.get();
    if (o == null || NotificationLite.isComplete(o) || NotificationLite.isError(o)) {
        if (array.length != 0) {
            array[0] = null;
        }
        return array;
    }
    T v = NotificationLite.getValue(o);
    if (array.length != 0) {
        array[0] = v;
        if (array.length != 1) {
            array[1] = null;
        }
    } else {
        array = (T[])Array.newInstance(array.getClass().getComponentType(), 1);
        array[0] = v;
    }
    return array;
}
StringQuery.java 文件源码 项目:spring-data-ebean 阅读 34 收藏 0 点赞 0 评论 0
@Override
public Object prepare(Object value) {

  if (!ObjectUtils.isArray(value)) {
    return value;
  }

  int length = Array.getLength(value);
  Collection<Object> result = new ArrayList<Object>(length);

  for (int i = 0; i < length; i++) {
    result.add(Array.get(value, i));
  }

  return result;
}
MatrixWidget.java 文件源码 项目:pandionj 阅读 52 收藏 0 点赞 0 评论 0
private void update() {
    removeAll();
    valid = model.isMatrix();
    if(valid) {
        Object[] array = (Object[]) model.getValues();
        for(Object line : array) {
            int len = Array.getLength(line);
            for(int i = 0; i < len; i++) {
                Object e = Array.get(line, i);
                Label label = new Label(e.toString()); // TODO array deepToString
                label.setForegroundColor(ColorConstants.black);
                add(label);
            }
        }
    }
    getLayoutManager().layout(this);
    repaint();
}
ArrayTypeAdapter.java 文件源码 项目:boohee_v5.6 阅读 40 收藏 0 点赞 0 评论 0
public Object read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    List<E> list = new ArrayList();
    in.beginArray();
    while (in.hasNext()) {
        list.add(this.componentTypeAdapter.read(in));
    }
    in.endArray();
    Object array = Array.newInstance(this.componentType, list.size());
    for (int i = 0; i < list.size(); i++) {
        Array.set(array, i, list.get(i));
    }
    return array;
}
ObjectUtils.java 文件源码 项目:X4J 阅读 41 收藏 0 点赞 0 评论 0
/**
 * Determine whether the given object is empty.
 * <p>This method supports the following object types.
 * <ul>
 * <li>{@code Optional}: considered empty if {@link Optional#empty()}</li>
 * <li>{@code Array}: considered empty if its length is zero</li>
 * <li>{@link CharSequence}: considered empty if its length is zero</li>
 * <li>{@link Collection}: delegates to {@link Collection#isEmpty()}</li>
 * <li>{@link Map}: delegates to {@link Map#isEmpty()}</li>
 * </ul>
 * <p>If the given object is non-null and not one of the aforementioned
 * supported types, this method returns {@code false}.
 * @param obj the object to check
 * @return {@code true} if the object is {@code null} or <em>empty</em>
 * @since 4.2
 * @see Optional#isPresent()
 * @see ObjectUtils#isEmpty(Object[])
 * @see StringUtils#hasLength(CharSequence)
 * @see StringUtils#isEmpty(Object)
 * @see CollectionUtils#isEmpty(java.util.Collection)
 * @see CollectionUtils#isEmpty(java.util.Map)
 */
@SuppressWarnings("rawtypes")
public static boolean isEmpty( Object obj) {
    if (obj == null) {
        return true;
    }

    if (obj instanceof Optional) {
        return !((Optional) obj).isPresent();
    }
    if (obj.getClass().isArray()) {
        return Array.getLength(obj) == 0;
    }
    if (obj instanceof CharSequence) {
        return ((CharSequence) obj).length() == 0;
    }
    if (obj instanceof Collection) {
        return ((Collection) obj).isEmpty();
    }
    if (obj instanceof Map) {
        return ((Map) obj).isEmpty();
    }

    // else
    return false;
}
ConvertUtilsBean.java 文件源码 项目:NotifyTools 阅读 43 收藏 0 点赞 0 评论 0
/**
 * Convert an array of specified values to an array of objects of the
 * specified class (if possible).  If the specified Java class is itself
 * an array class, this class will be the type of the returned value.
 * Otherwise, an array will be constructed whose component type is the
 * specified class.
 *
 * @param values Array of values to be converted
 * @param clazz Java array or element class to be converted to (must not be null)
 * @return The converted value
 *
 * @throws ConversionException if thrown by an underlying Converter
 */
public Object convert(final String[] values, final Class<?> clazz) {

    Class<?> type = clazz;
    if (clazz.isArray()) {
        type = clazz.getComponentType();
    }
    if (log.isDebugEnabled()) {
        log.debug("Convert String[" + values.length + "] to class '" +
                  type.getName() + "[]'");
    }
    Converter converter = lookup(type);
    if (converter == null) {
        converter = lookup(String.class);
    }
    if (log.isTraceEnabled()) {
        log.trace("  Using converter " + converter);
    }
    final Object array = Array.newInstance(type, values.length);
    for (int i = 0; i < values.length; i++) {
        Array.set(array, i, converter.convert(type, values[i]));
    }
    return (array);

}
HashCodeUtil.java 文件源码 项目:PackagePlugin 阅读 44 收藏 0 点赞 0 评论 0
/**
 * <code>aObject</code> is a possibly-null object field, and possibly an
 * array.
 * 
 * If <code>aObject</code> is an array, then each element may be a
 * primitive or a possibly-null object.
 */
public static int hash(int aSeed, Object aObject) {
    int result = aSeed;
    if (aObject == null) {
        result = hash(result, 0);
    } else if (!isArray(aObject)) {
        result = hash(result, aObject.hashCode());
    } else {
        int length = Array.getLength(aObject);
        for (int idx = 0; idx < length; ++idx) {
            Object item = Array.get(aObject, idx);
            //recursive call!
            result = hash(result, item);
        }
    }
    return result;
}
CollectionConverter.java 文件源码 项目:monarch 阅读 38 收藏 0 点赞 0 评论 0
final Object toNonNullOpenValue(Object value) throws OpenDataException {
  final Collection valueCollection = (Collection) value;
  if (valueCollection instanceof SortedSet) {
    Comparator comparator = ((SortedSet) valueCollection).comparator();
    if (comparator != null) {
      final String msg = "Cannot convert SortedSet with non-null comparator: " + comparator;
      throw openDataException(msg, new IllegalArgumentException(msg));
    }
  }
  final Object[] openArray =
      (Object[]) Array.newInstance(getOpenClass().getComponentType(), valueCollection.size());
  int i = 0;
  for (Object o : valueCollection)
    openArray[i++] = elementConverter.toOpenValue(o);
  return openArray;
}
FSWrapperTest.java 文件源码 项目:incubator-netbeans 阅读 51 收藏 0 点赞 0 评论 0
private static void checkValue(Object o1, Object o2) throws Exception {
    assertEquals(o1.getClass().isAnnotation(), o2.getClass().isAnnotation());
    if (o1.getClass().isAnnotation()) {
        assertEquals(((Annotation) o1).annotationType(), ((Annotation) o2).annotationType());
    } else {
        assertEquals(o1.getClass(), o2.getClass());
    }

    if (o1.getClass().isArray()) {
        assertEquals(Array.getLength(o1), Array.getLength(o2));

        for (int c = 0; c < Array.getLength(o1); c++) {
            checkValue(Array.get(o1, c), Array.get(o2, c));
        }
    } else if (o1.getClass().isAnnotation()) {
        checkAnnotation((Annotation) o1, (Annotation) o2);
    } else {
        assertEquals(o1, o2);
    }
}
CollectionUtil.java 文件源码 项目:garlicts 阅读 55 收藏 0 点赞 0 评论 0
/**
 * 检查指定的集合/数组/枚举为空
 * <p>
 * 此方法可以处理如下对象:
 * <ul>
 * <li>Collection
 * <li>Map
 * <li>Array
 * <li>Enumeration
 * </ul>
 * <p>
 *
 * @param object
 * @return true
 * @throws IllegalArgumentException
 * @since 1.0
 */
public static boolean isEmpty(final Object object) {
    if (object == null) {
        return true;
    } else if (object instanceof Collection<?>) {
        return ((Collection<?>) object).isEmpty();
    } else if (object instanceof Map<?, ?>) {
        return ((Map<?, ?>) object).isEmpty();
    } else if (object instanceof Object[]) {
        return ((Object[]) object).length == 0;
    } else if (object instanceof Iterator<?>) {
        return ((Iterator<?>) object).hasNext() == false;
    } else if (object instanceof Enumeration<?>) {
        return ((Enumeration<?>) object).hasMoreElements() == false;
    } else {
        try {
            return Array.getLength(object) == 0;
        } catch (final IllegalArgumentException ex) {
            throw new IllegalArgumentException("Unsupported object type: " + object.getClass().getName());
        }
    }
}
ParenBindVariableNode.java 文件源码 项目:uroborosql 阅读 40 收藏 0 点赞 0 评论 0
/**
 * 配列の値をIN句として加工してバインドする
 *
 * @param transformContext transformコンテキスト
 * @param values バインドする値の配列
 */
private void bindArray(final TransformContext transformContext, final Object values) {
    int length = Array.getLength(values);
    if (length == 0) {
        throw new ParameterNotFoundRuntimeException("Parameter is not set. [" + expression + "]");
    }

    transformContext.addSqlPart("(?");
    transformContext.addBindVariable(Array.get(values, 0));
    for (int i = 1; i < length; i++) {
        transformContext.addSqlPart(", ?");
        transformContext.addBindVariable(Array.get(values, i));
    }
    transformContext.addSqlPart(")/*").addSqlPart(expression).addSqlPart("*/");
    transformContext.addBindName(expression);
}
BeanLinker.java 文件源码 项目:OpenJSharp 阅读 46 收藏 0 点赞 0 评论 0
@SuppressWarnings("unused")
private static final boolean rangeCheck(final Object array, final Object index) {
    if(!(index instanceof Number)) {
        return false;
    }
    final Number n = (Number)index;
    final int intIndex = n.intValue();
    final double doubleValue = n.doubleValue();
    if(intIndex != doubleValue && !Double.isInfinite(doubleValue)) { // let infinite trigger IOOBE
        return false;
    }
    if(0 <= intIndex && intIndex < Array.getLength(array)) {
        return true;
    }
    throw new ArrayIndexOutOfBoundsException("Array index out of range: " + n);
}
DiskLruCache.java 文件源码 项目:GitHub 阅读 50 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
private static <T> T[] copyOfRange(T[] original, int start, int end) {
    final int originalLength = original.length; // For exception priority compatibility.
    if (start > end) {
        throw new IllegalArgumentException();
    }
    if (start < 0 || start > originalLength) {
        throw new ArrayIndexOutOfBoundsException();
    }
    final int resultLength = end - start;
    final int copyLength = Math.min(resultLength, originalLength - start);
    final T[] result = (T[]) Array
            .newInstance(original.getClass().getComponentType(), resultLength);
    System.arraycopy(original, start, result, 0, copyLength);
    return result;
}
SortedList.java 文件源码 项目:vlayout 阅读 50 收藏 0 点赞 0 评论 0
private void addToData(int index, T item) {
    if (index > mSize) {
        throw new IndexOutOfBoundsException(
                "cannot add item to " + index + " because size is " + mSize);
    }
    if (mSize == mData.length) {
        // we are at the limit enlarge
        T[] newData = (T[]) Array.newInstance(mTClass, mData.length + CAPACITY_GROWTH);
        System.arraycopy(mData, 0, newData, 0, index);
        newData[index] = item;
        System.arraycopy(mData, index, newData, index + 1, mSize - index);
        mData = newData;
    } else {
        // just shift, we fit
        System.arraycopy(mData, index, mData, index + 1, mSize - index);
        mData[index] = item;
    }
    mSize++;
}
CatalogMap.java 文件源码 项目:s-store 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Return an array of the values in this CatalogMap.
 * This will be generally faster than using an iterator because
 * we will cache the array locally
 * @return
 */
@SuppressWarnings("unchecked")
public T[] values() {
    if (m_fastArray == null) {
        synchronized (this) {
            if (m_fastArray == null) {
                int capacity = this.size();
                T arr[] = (T[])Array.newInstance(this.m_cls, capacity);
                int i = 0;
                for (T t : m_items.values()) {
                    arr[i++] = t;
                } // FOR
                m_fastArray = arr;
            }
        } // SYNCH
    }
    return m_fastArray;
}
ArrayHolder.java 文件源码 项目:parabuild-ci 阅读 41 收藏 0 点赞 0 评论 0
public Serializable disassemble(CollectionPersister persister) throws HibernateException {
    int length = Array.getLength(array);
    Serializable[] result = new Serializable[length];
    for ( int i=0; i<length; i++ ) {
        result[i] = persister.getElementType().disassemble( Array.get(array,i), getSession() );
    }

    /*int length = tempList.size();
    Serializable[] result = new Serializable[length];
    for ( int i=0; i<length; i++ ) {
        result[i] = persister.getElementType().disassemble( tempList.get(i), session );
    }*/

    return result;

}
ResultMergerTest.java 文件源码 项目:EatDubbo 阅读 45 收藏 0 点赞 0 评论 0
@Test
public void testArrayMerger() throws Exception {
    String[] stringArray1 = {"1", "2", "3"};
    String[] stringArray2 = {"4", "5", "6"};
    String[] stringArray3 = {};

    Object result = ArrayMerger.INSTANCE.merge(stringArray1, stringArray2, stringArray3);
    Assert.assertTrue(result.getClass().isArray());
    Assert.assertEquals(6, Array.getLength(result));
    Assert.assertTrue(String.class.isInstance(Array.get(result, 0)));
    for(int i = 0; i < 6; i++) {
        Assert.assertEquals(String.valueOf(i + 1), Array.get(result, i));
    }

    int[] intArray1 = {1, 2, 3};
    int[] intArray2 = {4, 5, 6};
    int[] intArray3 = {7};
    result = MergerFactory.getMerger(int[].class).merge(intArray1, intArray2, intArray3);
    Assert.assertTrue(result.getClass().isArray());
    Assert.assertEquals(7, Array.getLength(result));
    Assert.assertTrue(int.class == result.getClass().getComponentType());
    for (int i = 0; i < 7; i++) {
        Assert.assertEquals(i + 1, Array.get(result, i));
    }

}
BasicAttribute.java 文件源码 项目:jdk8u-jdk 阅读 38 收藏 0 点赞 0 评论 0
/**
 * Determines whether two arrays are equal by comparing each of their
 * elements using <tt>Object.equals()</tt>.
 */
private static boolean arrayEquals(Object a1, Object a2) {
    int len;
    if ((len = Array.getLength(a1)) != Array.getLength(a2))
        return false;

    for (int j = 0; j < len; j++) {
        Object i1 = Array.get(a1, j);
        Object i2 = Array.get(a2, j);
        if (i1 == null || i2 == null) {
            if (i1 != i2)
                return false;
        } else if (!i1.equals(i2)) {
            return false;
        }
    }
    return true;
}
PrimitiveConverter.java 文件源码 项目:redant 阅读 41 收藏 0 点赞 0 评论 0
/**
 * 对基本类型进行类型转换
 */
@Override
@SuppressWarnings("unused")
protected Object doConvertValue(Object source, Class<?> toType, Object... params) {
    /**
     * 如果是基础类型,则直接返回
     */
    if (source != null && (!PrimitiveTypeUtil.isPriType(source.getClass()) || !PrimitiveTypeUtil.isPriType(toType))) {
        return null;
    }

    /**
     * 如果都是数组类型,则构造数组
     */
    if (source != null && source.getClass().isArray() && toType.isArray()) {
        Object result;
        Class<?> componentType = toType.getComponentType();
        result = Array.newInstance(componentType, Array.getLength(source));

        for (int i = 0; i < Array.getLength(source); i++) {
            Array.set(result, i, convert(Array.get(source, i),componentType, params));
        }
        return result;
    }
    return doConvert(source, toType);
}
ArrayUtil.java 文件源码 项目:dev-courses 阅读 53 收藏 0 点赞 0 评论 0
/**
 * Returns the given array if newsize is the same as existing.
 * Returns a new array of given size, containing as many elements of
 * the original array as it can hold.
 */
public static Object resizeArrayIfDifferent(Object source, int newsize) {

    int oldsize = Array.getLength(source);

    if (oldsize == newsize) {
        return source;
    }

    Object newarray =
        Array.newInstance(source.getClass().getComponentType(), newsize);

    if (oldsize < newsize) {
        newsize = oldsize;
    }

    System.arraycopy(source, 0, newarray, 0, newsize);

    return newarray;
}
SortedList.java 文件源码 项目:PlusGram 阅读 46 收藏 0 点赞 0 评论 0
private void addToData(int index, T item) {
    if (index > mSize) {
        throw new IndexOutOfBoundsException(
                "cannot add item to " + index + " because size is " + mSize);
    }
    if (mSize == mData.length) {
        // we are at the limit enlarge
        T[] newData = (T[]) Array.newInstance(mTClass, mData.length + CAPACITY_GROWTH);
        System.arraycopy(mData, 0, newData, 0, index);
        newData[index] = item;
        System.arraycopy(mData, index, newData, index + 1, mSize - index);
        mData = newData;
    } else {
        // just shift, we fit
        System.arraycopy(mData, index, mData, index + 1, mSize - index);
        mData[index] = item;
    }
    mSize++;
}
ArrayUtil.java 文件源码 项目:parabuild-ci 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Returns the given array if newsize is the same as existing.
 * Returns a new array of given size, containing as many elements of
 * the original array as it can hold.
 */
public static Object resizeArrayIfDifferent(Object source, int newsize) {

    int oldsize = Array.getLength(source);

    if (oldsize == newsize) {
        return source;
    }

    Object newarray =
        Array.newInstance(source.getClass().getComponentType(), newsize);

    if (oldsize < newsize) {
        newsize = oldsize;
    }

    System.arraycopy(source, 0, newarray, 0, newsize);

    return newarray;
}
ArrayIterator.java 文件源码 项目:HCFCore 阅读 42 收藏 0 点赞 0 评论 0
/**
 * Construct an ArrayIterator that will iterate over a range of values
 * in the specified array.
 *
 * @param array  the array to iterate over.
 * @param startIndex  the index to start iterating at.
 * @param endIndex  the index to finish iterating at.
 * @throws IllegalArgumentException if <code>array</code> is not an array.
 * @throws NullPointerException if <code>array</code> is <code>null</code>
 * @throws IndexOutOfBoundsException if either index is invalid
 */
public ArrayIterator(final Object array, final int startIndex, final int endIndex) {
    super();

    this.array = array;
    this.startIndex = startIndex;
    this.endIndex = endIndex;
    this.index = startIndex;

    final int len = Array.getLength(array);
    checkBound(startIndex, len, "start");
    checkBound(endIndex, len, "end");
    if (endIndex < startIndex) {
        throw new IllegalArgumentException("End index must not be less than start index.");
    }
}
AbstractVerifier.java 文件源码 项目:openjdk-jdk10 阅读 37 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
protected static <T> T resolveAnnotationValue(Class<T> expectedType, AnnotationValue value) {
    if (value == null) {
        return null;
    }
    if (expectedType.isArray()) {
        ArrayList<Object> result = new ArrayList<>();
        List<AnnotationValue> l = (List<AnnotationValue>) value.getValue();
        for (AnnotationValue el : l) {
            result.add(resolveAnnotationValue(expectedType.getComponentType(), el));
        }
        return (T) result.toArray((Object[]) Array.newInstance(expectedType.getComponentType(), result.size()));
    }
    Object unboxedValue = value.getValue();
    if (unboxedValue != null) {
        if (expectedType == TypeMirror.class && unboxedValue instanceof String) {
            /*
             * Happens if type is invalid when using the ECJ compiler. The ECJ does not match
             * AP-API specification here.
             */
            return null;
        }
        if (!expectedType.isAssignableFrom(unboxedValue.getClass())) {
            throw new ClassCastException(unboxedValue.getClass().getName() + " not assignable from " + expectedType.getName());
        }
    }
    return (T) unboxedValue;
}
BusinessAssert.java 文件源码 项目:xproject 阅读 36 收藏 0 点赞 0 评论 0
private static boolean isEmptyObject(Object object){
    if(object == null){
        return true;
    }else if(object instanceof String){
        return ((String)object).trim().equals("") || ((String)object).trim().equals("null");
    }else if(object instanceof Collection<?>){
        return ((Collection<?>)object).isEmpty();
    }else if(object instanceof Map<?,?>){
        return ((Map<?,?>)object).isEmpty();
    }else if(object.getClass().isArray()){
        return Array.getLength(object) == 0;
    }else{
        return false;
    }
}
EmptyUtils.java 文件源码 项目:Android-UtilCode 阅读 52 收藏 0 点赞 0 评论 0
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj instanceof String && obj.toString().length() == 0) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
        return true;
    }
    if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
AnnotationValueUtils.java 文件源码 项目:annotation-processor-toolkit 阅读 51 收藏 0 点赞 0 评论 0
/**
 * Converts an Attribute List to an array of passed type.
 *
 * @param annotatedValues The list to convert
 * @param type            The arrays target type
 * @param <T>             generic Type
 * @return an array of passed type containing all casted elements of passed annotatedValues list or null if passed annotatedValues are null.
 * @throws ClassCastException will be thrown if Attributes of List cannot be cast to passed type
 */
public static <T> T[] convertAndCastAttributeValueListToArray(List<Attribute> annotatedValues, Class<T> type) {

    if (annotatedValues == null) {
        return null;
    }

    T[] result = (T[]) Array.newInstance(type, annotatedValues.size());

    for (int i = 0; i < annotatedValues.size(); i++) {
        result[i] = (T) annotatedValues.get(i).getValue();
    }

    return result;
}
DynamicParsers.java 文件源码 项目:X4J 阅读 45 收藏 0 点赞 0 评论 0
@Override
public Object parse(String input, ParserHelper helper) {
    if (!helper.getRawTargetClass().isArray()) {
        return TRY_NEXT;
    }
    List<String> strList = helper.split(input);
    Class<?> componentType = helper.getComponentClass();
    Object result = Array.newInstance(componentType, strList.size());
    for (int i = 0; i < strList.size(); i++) {
        Object element = helper.parse(strList.get(i), componentType);
        Array.set(result, i, element);
    }
    return result;
}
ArrayBeanInfoImpl.java 文件源码 项目:openjdk-jdk10 阅读 44 收藏 0 点赞 0 评论 0
public void serializeBody(Object array, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
    int len = Array.getLength(array);
    for( int i=0; i<len; i++ )  {
        Object item = Array.get(array,i);
        // TODO: check the namespace URI.
        target.startElement("","item",null,null);
        if(item==null) {
            target.writeXsiNilTrue();
        } else {
            target.childAsXsiType(item,"arrayItem",itemBeanInfo, false);
        }
        target.endElement();
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号