当前位置: 首页>>代码示例>>Java>>正文


Java Array.get方法代码示例

本文整理汇总了Java中java.lang.reflect.Array.get方法的典型用法代码示例。如果您正苦于以下问题:Java Array.get方法的具体用法?Java Array.get怎么用?Java Array.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.Array的用法示例。


在下文中一共展示了Array.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hash

import java.lang.reflect.Array; //导入方法依赖的package包/类
/**
 * <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.
 *
 * @param aSeed
 *            the a seed
 * @param aObject
 *            the a object
 * @return the int
 */
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;
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:28,代码来源:HashCodeUtil.java

示例2: arrayEquals

import java.lang.reflect.Array; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:BasicAttribute.java

示例3: MatrixFigure

import java.lang.reflect.Array; //导入方法依赖的package包/类
public MatrixFigure(IArrayModel<?> model) {
	this.model = model;
	org.eclipse.draw2d.GridLayout layout;
	Object array = model.getValues();
	int nLines = Array.getLength(array);
	if(nLines == 0) {
		layout = new org.eclipse.draw2d.GridLayout(1,true);
	}
	else {
		Object firstLine = Array.get(array, 0);
		layout = new org.eclipse.draw2d.GridLayout(Array.getLength(firstLine), true);
	}
	layout.horizontalSpacing = 20;
	layout.marginWidth = 10;
	setLayoutManager(layout);

	model.registerDisplayObserver((a) -> update());
	update();
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:20,代码来源:MatrixWidget.java

示例4: writeObject

import java.lang.reflect.Array; //导入方法依赖的package包/类
@Override
public boolean writeObject(Object obj, JsonGenerator jgen, boolean expand) throws JsonProcessingException, IOException {
  logger.debug("array");
  // write out an array of objects.
  jgen.writeStartArray();
  final int length = Array.getLength(obj);
  for (int i = 0; i < length; ++i) {
    Object o = Array.get(obj, i);
    if (!parent.writeObject(o, jgen, false)) {
        jgen.writeObject(o.toString());
    }
  }
  jgen.writeEndArray();
  return true;
}
 
开发者ID:twosigma,项目名称:beaker-notebook-archive,代码行数:16,代码来源:BasicObjectSerializer.java

示例5: processField

import java.lang.reflect.Array; //导入方法依赖的package包/类
private static void processField(Field f)
{
	try
	{
		if (f.getType().isArray())
		{
			Object o = f.get(null);
			for (int i = 0; i < Array.getLength(o); ++i)
			{
				Object arrayAt = Array.get(o, i);
				if (IOreDictEntry.class.isAssignableFrom(arrayAt.getClass()))
				{
					((IOreDictEntry)arrayAt).registerOreDictNames();
				}
			}
		}
		else
		{
			Object at = f.get(null);
			if (at != null && IOreDictEntry.class.isAssignableFrom(at.getClass()))
			{
				((IOreDictEntry)f.get(null)).registerOreDictNames();
			}
		}
	}
	catch (Exception ex)
	{
		ex.printStackTrace();
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:31,代码来源:OreDictManager.java

示例6: logMethodSignature

import java.lang.reflect.Array; //导入方法依赖的package包/类
/** Logs the signature of the method used for debuging purposes */
private void logMethodSignature( Stack<String> methodNames, Object[] argumentsValues ) {

    StringBuffer buffer = new StringBuffer();
    buffer.append(methodNames.peek()).append("( ");

    for (int i = 0; i < argumentsValues.length; i++) {
        if (argumentsValues[i] == null) {
            buffer.append("null");
        } else {
            if (argumentsValues[i].getClass().isArray()) {
                // we have an array, so get all elements
                buffer.append("{ ");

                for (int j = 0; j < Array.getLength(argumentsValues[i]); j++) {
                    if (Array.get(argumentsValues[i], j) == null) {
                        buffer.append("null");
                    } else {
                        buffer.append(Array.get(argumentsValues[i], j).toString());
                    }
                    if ( (j + 1) != Array.getLength(argumentsValues[i])) {
                        buffer.append(" , ");
                    }
                }

                buffer.append(" }");

            } else {
                buffer.append(argumentsValues[i].toString());
            }
        }
        if ( (i + 1) != argumentsValues.length) {
            buffer.append(" , ");
        }
    }
    buffer.append(" )");

    log.debug("START - " + buffer);
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:40,代码来源:Validator.java

示例7: next

import java.lang.reflect.Array; //导入方法依赖的package包/类
/**
 * Returns the next element in the array.
 *
 * @return the next element in the array
 * @throws NoSuchElementException if all the elements in the array
 *  have already been returned
 */
@SuppressWarnings("unchecked")
public E next() {
    if (hasNext() == false) {
        throw new NoSuchElementException();
    }
    return (E) Array.get(array, index++);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:15,代码来源:ArrayIterator.java

示例8: createEnumeration

import java.lang.reflect.Array; //导入方法依赖的package包/类
/**
 * Create an enumeration over the given object
 *
 * @param iterateOverMe Object of type Enumeration, Vector, String, 
 *                      StringBuffer or an array
 *
 * @return an enumeration
 *
 * @throws java.lang.IllegalArgumentException If the argument is not a
 * supported (i.e. iterable) type.
 *
 * @throws java.lang.NullPointerException If the argument is null
 */
protected Enumeration createEnumeration( Object iterateOverMe )
{
	if(iterateOverMe==null)
		throw new NullPointerException("Object arguments passed to " +
			"the BasicBshIterator constructor cannot be null.");

	if (iterateOverMe instanceof Enumeration)
		return (Enumeration)iterateOverMe;

	if (iterateOverMe instanceof Vector)
		return ((Vector)iterateOverMe).elements();

	if (iterateOverMe.getClass().isArray()) {
		final Object array = iterateOverMe;
		return new Enumeration() {
			int index = 0, length = Array.getLength(array);
			public Object nextElement() { 
				return Array.get(array, index++);
			}
			public boolean hasMoreElements() { return index<length; }
		};
	} 
	
	if (iterateOverMe instanceof String)
		return createEnumeration(((String)iterateOverMe).toCharArray());
	
	if (iterateOverMe instanceof StringBuffer)
		return createEnumeration(
			iterateOverMe.toString().toCharArray());

	throw new IllegalArgumentException(
		"Cannot enumerate object of type "+iterateOverMe.getClass());
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:47,代码来源:CollectionManager.java

示例9: writeObject

import java.lang.reflect.Array; //导入方法依赖的package包/类
private void writeObject(JsonGenerator jg, Object value) throws IOException {
  if(value == null) {
    jg.writeNull();
  } else {
    Class<?> c = value.getClass();
    if (c.isArray()) {
      jg.writeStartArray();
      int len = Array.getLength(value);
      for (int j = 0; j < len; j++) {
        Object item = Array.get(value, j);
        writeObject(jg, item);
      }
      jg.writeEndArray();
    } else if(value instanceof Number) {
      Number n = (Number)value;
      jg.writeNumber(n.toString());
    } else if(value instanceof Boolean) {
      Boolean b = (Boolean)value;
      jg.writeBoolean(b);
    } else if(value instanceof CompositeData) {
      CompositeData cds = (CompositeData)value;
      CompositeType comp = cds.getCompositeType();
      Set<String> keys = comp.keySet();
      jg.writeStartObject();
      for(String key: keys) {
        writeAttribute(jg, key, cds.get(key));
      }
      jg.writeEndObject();
    } else if(value instanceof TabularData) {
      TabularData tds = (TabularData)value;
      jg.writeStartArray();
      for(Object entry : tds.values()) {
        writeObject(jg, entry);
      }
      jg.writeEndArray();
    } else {
      jg.writeString(value.toString());
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:41,代码来源:JMXJsonServlet.java

示例10: deepToString

import java.lang.reflect.Array; //导入方法依赖的package包/类
private static String deepToString(Object o) {
    StringBuffer buf = new StringBuffer();
    buf.append("[");
    int len = Array.getLength(o);
    for (int i = 0; i < len; i++) {
        if (i > 0)
            buf.append(", ");
        Object e = Array.get(o, i);
        buf.append(string(e));
    }
    buf.append("]");
    return buf.toString();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:MXBeanTest.java

示例11: unboxPremitiveArray

import java.lang.reflect.Array; //导入方法依赖的package包/类
public static Object unboxPremitiveArray(Object r) {
    int length = Array.getLength(r);
    ArrayList<Object> list = new ArrayList<Object>();
    for (int i = 0; i < length; i++) {
        Object e = Array.get(r, i);
        if (e != null && e.getClass().isArray()) {
            list.add(unboxPremitiveArray(e));
        } else {
            list.add(e);
        }
    }
    return list;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:RComponent.java

示例12: buildMongoCriteria

import java.lang.reflect.Array; //导入方法依赖的package包/类
@Override
public Criteria buildMongoCriteria(Object expression) {
	String path = expression.toString();
	Object value1 = Array.get(value, 0);
	Object value2 = Array.get(value, 1);
	return Criteria.where(path).gte(value1).and(path).lte(value2);
}
 
开发者ID:szsucok,项目名称:sucok-framework,代码行数:8,代码来源:Between.java

示例13: getDefaultValue

import java.lang.reflect.Array; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> T getDefaultValue(Class<T> clazz) {
	T defaultValue = null;

	try {
		defaultValue = clazz.getConstructor().newInstance();
	}
	catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
		defaultValue = (T) Array.get(Array.newInstance(clazz, 1), 0);
	}

	return defaultValue;
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:14,代码来源:MetadataTest.java

示例14: printArrayProperty

import java.lang.reflect.Array; //导入方法依赖的package包/类
private void printArrayProperty(StringBuffer sb, String prefix,Object array) {
    int length = Array.getLength(array);
    for (int i=0;i<length;i++) {
        Object obj = Array.get(array,i);
        printProperty(sb,prefix+"["+i+"]",obj);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:8,代码来源:ToStringBean.java

示例15: write

import java.lang.reflect.Array; //导入方法依赖的package包/类
@Override
public Object write(Object array) {
    List<Object> objects = new ArrayList<>();

    for (int i = 0, length = Array.getLength(array); i < length; i++) {
        E value = (E) Array.get(array, i);
        objects.add(baseAdaptor.write(value));
    }

    return objects;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:12,代码来源:ArrayAdaptor.java


注:本文中的java.lang.reflect.Array.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。