當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。