當前位置: 首頁>>代碼示例>>Java>>正文


Java NativeArray.get方法代碼示例

本文整理匯總了Java中org.mozilla.javascript.NativeArray.get方法的典型用法代碼示例。如果您正苦於以下問題:Java NativeArray.get方法的具體用法?Java NativeArray.get怎麽用?Java NativeArray.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mozilla.javascript.NativeArray的用法示例。


在下文中一共展示了NativeArray.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getKeyEntries

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
@Nullable
private List<KeyEntry> getKeyEntries(Map.Entry<Object, Object> entry) {
    if (!(entry.getValue() instanceof NativeArray)) {
        return null;
    }

    NativeArray nativeArray = (NativeArray) entry.getValue();
    if (nativeArray.isEmpty()) {
        return null;
    }

    List<KeyEntry> keyList = new ArrayList<>();
    final int size = nativeArray.size();
    for (int i = 0; i < size; i++) {
        NativeObject elem = (NativeObject) nativeArray.get(i);
        keyList.add(new KeyEntry(
                Context.toString(elem.get("text")),
                (int) Context.toNumber(elem.get("keyCode")),
                Context.toBoolean(elem.get("enabled")),
                Context.toBoolean(elem.get("isFunKey"))
        ));
    }
    return keyList;
}
 
開發者ID:parkingwang,項目名稱:vehicle-keyboard-android,代碼行數:25,代碼來源:EngineRunner.java

示例2: setDatoMultivaluadoElemento

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
/**
 * Mete dato multivaluado para un elemento
 * @param indiceElemento Indice elemento
 * @param column Columna
 * @param data Dato
 */
public void setDatoMultivaluadoElemento(int indiceElemento,String column, NativeArray data){
	if (indiceElemento > elementos.size()) return;
	HashMap dataElemento = (HashMap) elementos.get(indiceElemento - 1);
	
	// Pasamos NativeArray a List
	List dataList = new ArrayList();
	Object [] ids = data.getIds();
	for ( int i = 0; i < ids.length; i++ )
	{
		Object valor = data.get( (( Integer ) ids[i] ).intValue() , data ); 
		dataList.add( valor.toString() );
	}
	
	// Guardamos datos		
	dataElemento.put(column,dataList);		
}
 
開發者ID:GovernIB,項目名稱:sistra,代碼行數:23,代碼來源:DatosListaElementos.java

示例3: deserialize

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
static public Map<String,Object> deserialize(NativeObject object) {
    HashMap<String,Object> map = new HashMap<>();
    for (Object key : object.keySet()) {
        Object value = object.get(key);
        if (value == null) {
            map.put(key.toString(), null);
        } else if (value instanceof Number) {
            map.put(key.toString(), value);
        } else if (value instanceof Boolean) {
            map.put(key.toString(), value);
        } else if (value instanceof NativeObject) {
            map.put(key.toString(), deserialize((NativeObject)value));
        } else if (value instanceof NativeArray) {
            NativeArray array = (NativeArray)value;
            Object[] a = new Object[(int)array.getLength()];
            for (int i = 0; i < array.getLength(); ++i) {
                Object o = array.get(i);
                a[i] = deserialize(o);
            }
            map.put(key.toString(), a);
        } else {
            map.put(key.toString(), value.toString());
        }
    }
    return map;
}
 
開發者ID:loadtestgo,項目名稱:pizzascript,代碼行數:27,代碼來源:RhinoUtils.java

示例4: shouldListJobs

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
@Test
public void shouldListJobs(){

    try {
        Context cx = Context.enter();
        Scriptable scope = cx.initStandardObjects();
        scriptJobService.setScope(scope);
        final NativeArray allJobs = (NativeArray) scriptJobService.getAllJobs();
        Assert.assertTrue(allJobs.getIds().length > 0);
        ScriptJob job = (ScriptJob) allJobs.get(0);
        Assert.assertNotNull(job.jobName);
        Assert.assertNotNull(job.nextFireTime);

    }finally{
        Context.exit();
    }

}
 
開發者ID:jgoldhammer,項目名稱:alfresco-jscript-extensions,代碼行數:19,代碼來源:ScriptJobServiceTest.java

示例5: call

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
@Override
public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
    if (args.length == 0) {
        throw new RuntimeException("'load' function takes at least one argument");
    }

    for (Object arg : args) {
        if (arg instanceof NativeArray) {
            NativeArray array = (NativeArray)arg;
            for (int i = 0; i < array.getLength(); i++) {
                Object path = array.get(i);
                if (path != null) {
                    load(path.toString(), cx, scope);
                } else {
                    throw new NullPointerException("Cannot have null argument in load function");
                }
            }
        } else if (arg == null) {
            throw new NullPointerException("Cannot have null argument in load function");
        } else {
            load(arg.toString(), cx, scope);
        }
    }
    return null;
}
 
開發者ID:galenframework,項目名稱:galen,代碼行數:26,代碼來源:JsFunctionLoad.java

示例6: convertFromScriptObject

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
public Object convertFromScriptObject(Object scriptObject, Class expectedClass) {
    if (scriptObject != null && conversionRequires(scriptObject, expectedClass)) {
        Object result = RhinoUtil.convertResult(null, expectedClass, scriptObject);
        if (result instanceof NativeArray) {
            NativeArray jsArray = (NativeArray) result;
            int length = (int) jsArray.getLength();
            Object[] array = new Object[length];
            for (int i = 0; i < length; i++) {
                array[i] = jsArray.get(i, null);
            }
            result = array;
        }
        return result;
    }
    return scriptObject;
}
 
開發者ID:seasarorg,項目名稱:mayaa,代碼行數:17,代碼來源:ScriptEnvironmentImpl.java

示例7: shouldParseHeterogeneousJsonArray

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void shouldParseHeterogeneousJsonArray() throws Exception {
    NativeArray actual = (NativeArray) parser
            .parseValue("[ \"hello\" , 3, null, [false] ]");
    assertEquals("hello", actual.get(0, actual));
    assertEquals(3, actual.get(1, actual));
    assertEquals(null, actual.get(2, actual));

    NativeArray innerArr = (NativeArray) actual.get(3, actual);
    assertEquals(false, innerArr.get(0, innerArr));

    assertEquals(4, actual.getLength());
}
 
開發者ID:middle2tw,項目名稱:whackpad,代碼行數:15,代碼來源:JsonParserTest.java

示例8: expresionAutocalculoCampo

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
/**
 * Devuelve el valor de autocalcular un campo.
 * 
 * Devuelve un string para campos monovaluados o una lista (de strings) para campos multivaluados
 * 
 * @ejb.interface-method
 */
public Object expresionAutocalculoCampo(String nombre) {
    Campo campo = pantallaActual.findCampo(nombre);
    if (campo == null) return new ArrayList();

    String script = campo.getExpresionAutocalculo();
    if (script == null || script.trim().length() == 0) {
        return new ArrayList();
    }

    Object result = ScriptUtil.evalScript(script, variablesScriptActuals());
            
    if (result instanceof NativeArray) {
    	
    	List lstParams = new LinkedList();
    	
    	// Array de strings
    	NativeArray params = (NativeArray) result;        	
		if ( params != null )
		{
			Object [] ids = params.getIds();
			for ( int i = 0; i < ids.length; i++ )
			{
				Object valorParametro = params.get( (( Integer ) ids[i] ).intValue() , params ); 
				lstParams.add( valorParametro.toString() );
			}
		}     
		
		return lstParams;
    }else {
    	// Cadena simple
    	return ((result!=null?result.toString():""));        	
    }
 
}
 
開發者ID:GovernIB,項目名稱:sistra,代碼行數:42,代碼來源:InstanciaProcessorEJB.java

示例9: toStringList

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
public static String[] toStringList(Object value) {
    if (value == null) {
        return null;
    } else if (value instanceof NativeArray) {
        NativeArray array = (NativeArray)value;
        String[] a = new String[(int)array.getLength()];
        for (int i = 0; i < array.getLength(); ++i) {
            Object o = array.get(i);
            a[i] = toString(o);
        }
        return a;
    } else {
        return null;
    }
}
 
開發者ID:loadtestgo,項目名稱:pizzascript,代碼行數:16,代碼來源:RhinoUtils.java

示例10: randomElement

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
@Override
public Object randomElement(NativeArray array) {
    if (array.size() == 0) {
        return null;
    }
    int i = random(array.size());
    return array.get(i);
}
 
開發者ID:loadtestgo,項目名稱:pizzascript,代碼行數:9,代碼來源:UtilsImpl.java

示例11: get_array

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
static Object[] get_array(String path, Object base) throws ObjectNotFoundException {
	NativeArray arr = (NativeArray)get_object(path, base);
	Object[] out = new Object[(int)arr.getLength()];
	int idx;
	for(Object o : arr.getIds()) out[idx = (Integer)o] = arr.get(idx, arr); 
	return out;
}
 
開發者ID:dzhw,項目名稱:metadatamanagement,代碼行數:8,代碼來源:JSHelper.java

示例12: toArray

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
/**
 * @param contextFactory usually just the global {@link ContextFactory}
 * @return a Java array of the JavaScript input values
 */
public Object[] toArray(ContextFactory contextFactory) {
  NativeArray values = toJSArray(contextFactory);
  Object[] result = new Object[valueStrings.length];
  for (int i = 0; i < valueStrings.length; i++) {
    result[i] = values.get(i, values);
  }
  return result;
}
 
開發者ID:ehsan,項目名稱:js-symbolic-executor,代碼行數:13,代碼來源:Input.java

示例13: toIntArray

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
/**
 * 將NativeArray返回結果轉換為int[]對象
 * 
 * @Title: toIntArray
 * @Description: TODO(這裏用一句話描述這個方法的作用)
 * @param 參數
 * @return int[] 返回類型
 * @throws
 */
public static int[] toIntArray(NativeArray nv) {
	int[] result = new int[(int) nv.getLength()];
	for (int i = 0; i < result.length; i++) {
		Object obj = nv.get(i, null);
		if (obj instanceof Number) {
			result[i] = ((Number) obj).intValue();
		} else {
			result[i] = StringUtils.toInt(StringUtils.toString(obj), 0);
		}
	}
	return result;
}
 
開發者ID:GeeQuery,項目名稱:ef-orm,代碼行數:22,代碼來源:JavaScriptUtil.java

示例14: convertScriptNodesArray

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
/**
 * converts the native array of scriptnodes to a list of noderefs
 *
 * @param scriptNodes
 * @return list of noderefs
 */
private List<NodeRef> convertScriptNodesArray(NativeArray scriptNodes) {
	List<NodeRef> nodes = new ArrayList<>();
	for (Object id : scriptNodes.getIds()) {
		int index = (Integer) id;
                       Object obj = scriptNodes.get(index);
                       if (obj instanceof NativeJavaObject) {
                           obj = ((NativeJavaObject) obj).unwrap();
                       }
		ScriptNode scriptNode = (ScriptNode) obj;
		nodes.add(scriptNode.getNodeRef());
	}
	return nodes;
}
 
開發者ID:jgoldhammer,項目名稱:alfresco-jscript-extensions,代碼行數:20,代碼來源:BatchScriptFacade.java

示例15: convertNodeRefsAsStringsArray

import org.mozilla.javascript.NativeArray; //導入方法依賴的package包/類
/**
 * converts the native array of NodeRef strings to a list of noderefs
 *
 * @param nodeRefsAsStrings
 * @return list of noderefs
 */
private List<NodeRef> convertNodeRefsAsStringsArray(NativeArray nodeRefsAsStrings) {
	List<NodeRef> nodes = new ArrayList<>();
	for (Object id : nodeRefsAsStrings.getIds()) {
		int index = (Integer) id;
                       Object obj = nodeRefsAsStrings.get(index);
                       if (obj instanceof NativeJavaObject) {
                           obj = ((NativeJavaObject) obj).unwrap();
                       }
		String nodeRefAsString = (String) obj;
		nodes.add(new NodeRef(nodeRefAsString));
	}
	return nodes;
}
 
開發者ID:jgoldhammer,項目名稱:alfresco-jscript-extensions,代碼行數:20,代碼來源:BatchScriptFacade.java


注:本文中的org.mozilla.javascript.NativeArray.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。