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


Java NativeArray类代码示例

本文整理汇总了Java中org.mozilla.javascript.NativeArray的典型用法代码示例。如果您正苦于以下问题:Java NativeArray类的具体用法?Java NativeArray怎么用?Java NativeArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: jsToJava

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
static Object jsToJava(final Object obj) {
    if (obj instanceof Scriptable) {
        final Object javaObj = Context.jsToJava(obj, Object.class);
        if (javaObj instanceof NativeArray) {
            return new ScriptableList((NativeArray) javaObj);
        }
        if (javaObj instanceof Scriptable) {
            return new ScriptableMap((Scriptable) javaObj);
        }
        return javaObj;
    }
    if (obj instanceof Wrapper) {
        return ((Wrapper) obj).unwrap();
    }
    if (obj == Scriptable.NOT_FOUND) {
        return null;
    }
    return obj;
}
 
开发者ID:szegedi,项目名称:spring-web-jsflow,代码行数:20,代码来源:ScriptableConverter.java

示例2: getBondedDevices

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
@ProtoMethod(description = "Send bluetooth serial message", example = "")
@ProtoMethodParam(params = {"string"})
public NativeArray getBondedDevices() {
    start();

    Set<BluetoothDevice> listDevices = mAdapter.getBondedDevices();
    MLog.d(TAG, "listDevices " + listDevices);
    int listSize = listDevices.size();
    ProtocoderNativeArray array = new ProtocoderNativeArray(listSize);
    MLog.d(TAG, "array " + array);


    int counter = 0;
    for (BluetoothDevice b : listDevices) {
        MLog.d(TAG, "bt " + b);

        ReturnObject btDevice = new ReturnObject();
        btDevice.put("name", b.getName());
        btDevice.put("mac", b.getAddress());

        array.addPE(counter++, btDevice);
    }

    return array;
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:26,代码来源:PBluetooth.java

示例3: init

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
public void init(NativeArray data, int numCols, ReturnInterfaceWithReturn createCallback, ReturnInterfaceWithReturn bindingCallback) {
    styler = new Styler(mAppRunner, this, props);
    styler.apply();

    mGridLayoutManager = new GridLayoutManager(mContext, numCols);
    setLayoutManager(mGridLayoutManager);
    // setLayoutManager(new StaggeredGridLayoutManager(2, VERTICAL));
    mViewAdapter = new PViewItemAdapter(mContext, data, createCallback, bindingCallback);

    // Get GridView and set adapter
    setHasFixedSize(true);

    setAdapter(mViewAdapter);
    notifyDataChanged();

    setItemAnimator(null);
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:18,代码来源:PList.java

示例4: 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

示例5: 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

示例6: parseCalloutResponse

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
private String parseCalloutResponse(String calloutResponse, List<NativeArray> returnedArray) {
  String initS = "id=\"paramArray\">";
  String resp = calloutResponse.substring(calloutResponse.indexOf(initS) + initS.length());
  resp = resp.substring(0, resp.indexOf("</SCRIPT")).trim();
  if (!resp.contains("new Array(") && !resp.contains("[[")) {
    return null;
  }
  try {
    Context cx = Context.enter();
    Scriptable scope = cx.initStandardObjects();
    cx.evaluateString(scope, resp, "<cmd>", 1, null);
    NativeArray array = (NativeArray) scope.get("respuesta", scope);
    Object calloutName = scope.get("calloutName", scope);
    String calloutNameS = calloutName == null ? null : calloutName.toString();
    log.debug("Callout Name: " + calloutNameS);
    for (int i = 0; i < array.getLength(); i++) {
      returnedArray.add((NativeArray) array.get(i, null));
    }
    return calloutNameS;
  } catch (Exception e) {
    log.error("Couldn't parse callout response. The parsed response was: " + resp, e);
  }
  return null;
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:25,代码来源:FormInitializationComponent.java

示例7: testCompiledJs

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
@Test
public void testCompiledJs() throws Exception {
  // The main module calls a soy template and alerts the output.
  // Replace alert with something that lets us capture the output.
  cx.evaluateString(
      scope, "var _alerts_ = []; alert = function (s) { _alerts_.push(s); }",
      "test", 1, null);

  loadJsModule("/closure/js/main.js");
  loadJsModule("/closure/js/hello.world.js");

  NativeArray alerts = (NativeArray)
      ScriptableObject.getProperty(scope, "_alerts_");

  assertEquals(
      "<div id=\"greeting\">Hello, <b class=\"b\">Cle&lt;eland</b>!</div>",
      Context.toString(alerts.get(0)));
}
 
开发者ID:mikesamuel,项目名称:closure-maven-plugin,代码行数:19,代码来源:CompiledJsTest.java

示例8: 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

示例9: generateAssertionStatements

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
private List<MappingAssertionStatement> generateAssertionStatements(Object compiledJavascriptObject) {
	List<MappingAssertionStatement> assertionStatements = new ArrayList<MappingAssertionStatement>();
	if (compiledJavascriptObject != null && compiledJavascriptObject instanceof NativeArray) {
		NativeArray array = (NativeArray) compiledJavascriptObject;
		for (Object object : array) {
			NativeObject nativeObject = (NativeObject) object;
			String actualValuePath = (String) nativeObject
					.get("actualValuePath");
			Object actualValue = nativeObject.get("actualValue");
			String operator = (String) nativeObject.get("operator");
			Object expectedValue = nativeObject.get("expectedValue");
			if (expectedValue instanceof NativeArray) {
				NativeArray expectedValueNativeArray = (NativeArray) expectedValue;
				expectedValue = expectedValueNativeArray.toArray();
			}
			assertionStatements.add(new MappingAssertionStatement(
					actualValuePath, actualValue, operator, expectedValue));
		}
	}
	return assertionStatements;
}
 
开发者ID:marcotabago,项目名称:hl7-mapping-validator,代码行数:22,代码来源:AssertionsJavascriptCompiler.java

示例10: getAssertionStatementMetadataList

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
public List<MappingAssertionStatement> getAssertionStatementMetadataList() {
	if (this.compiledJavascriptObject != null && this.compiledJavascriptObject instanceof NativeArray) {
		NativeArray array = (NativeArray) this.compiledJavascriptObject;
		for (Object object : array) {
			NativeObject nativeObject = (NativeObject) object;
			String actualValuePath = (String) nativeObject
					.get("actualValuePath");
			Object actualValue = nativeObject.get("actualValue");
			String operator = (String) nativeObject.get("operator");
			Object expectedValue = nativeObject.get("expectedValue");
			this.assertionStatementMetadataList.add(new MappingAssertionStatement(
					actualValuePath, actualValue, operator, expectedValue));
		}
	}
	return this.assertionStatementMetadataList;
}
 
开发者ID:marcotabago,项目名称:hl7-mapping-validator,代码行数:17,代码来源:CompiledJavascriptAssertions.java

示例11: addToScope

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
/**
 * Adds the values of a row to the JavaScript scope
 *
 * @param scope
 * @param inputRow
 * @param columns
 * @param arrayName
 */
public static void addToScope(final Scriptable scope, final InputRow inputRow, final InputColumn<?>[] columns,
        final String arrayName) {
    final NativeArray values = new NativeArray(columns.length * 2);
    for (int i = 0; i < columns.length; i++) {
        final InputColumn<?> column = columns[i];
        Object value = inputRow.getValue(column);

        if (value != null) {
            final Class<?> dataType = column.getDataType();
            if (ReflectionUtils.isNumber(dataType)) {
                value = Context.toNumber(value);
            } else if (ReflectionUtils.isBoolean(dataType)) {
                value = Context.toBoolean(value);
            }
        }

        values.put(i, values, value);
        values.put(column.getName(), values, value);

        addToScope(scope, value, column.getName(), column.getName().toLowerCase(), column.getName().toUpperCase());
    }

    addToScope(scope, values, arrayName);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:33,代码来源:JavaScriptUtils.java

示例12: onMeasure

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
	measureChildren(widthMeasureSpec, heightMeasureSpec);
	int width=0, height=0;
	if (MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY &&
			MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY) {
		NativeArray calc = (NativeArray) callFunc("onMeasure");
		width = ((Number) calc.get(0)).intValue();
		height= ((Number) calc.get(1)).intValue();
	} else {
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		return;
	}
	if (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY) {
		width = MeasureSpec.getSize(widthMeasureSpec);
	} if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY) {
		height = MeasureSpec.getSize(heightMeasureSpec);
	}
	setMeasuredDimension(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), 
			MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
}
 
开发者ID:joeywatts,项目名称:native.js,代码行数:22,代码来源:Container.java

示例13: addToScope

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
/**
 * Adds the values of a row to the JavaScript scope
 * 
 * @param scope
 * @param inputRow
 * @param columns
 * @param arrayName
 */
public static void addToScope(Scriptable scope, InputRow inputRow, InputColumn<?>[] columns, String arrayName) {
	NativeArray values = new NativeArray(columns.length * 2);
	for (int i = 0; i < columns.length; i++) {
		InputColumn<?> column = columns[i];
		Object value = inputRow.getValue(column);

		if (value != null) {
			Class<?> dataType = column.getDataType();
			if (ReflectionUtils.isNumber(dataType)) {
				value = Context.toNumber(value);
			} else if (ReflectionUtils.isBoolean(dataType)) {
				value = Context.toBoolean(value);
			}
		}

		values.put(i, values, value);
		values.put(column.getName(), values, value);

		addToScope(scope, value, column.getName(), column.getName().toLowerCase(), column.getName().toUpperCase());
	}

	addToScope(scope, values, arrayName);
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:32,代码来源:JavaScriptUtils.java

示例14: testWrap

import org.mozilla.javascript.NativeArray; //导入依赖的package包/类
@Test
public void testWrap( )
{
	// test nativeArray
	NativeArray nativeArray = new NativeArray( new Object[]{
			"one", "two"
	} );
	Object object = coreWrapper.wrap( cx, scope, nativeArray, null );
	assertTrue( object instanceof org.mozilla.javascript.NativeArray );

	// test list
	List<Integer> list = new ArrayList<>( );
	object = coreWrapper.wrap( cx, scope, list, null );
	assertTrue( object instanceof NativeJavaList );

	// test map
	Map<Integer, Integer> linkedHashMap = new LinkedHashMap<>( );
	object = coreWrapper.wrap( cx, scope, linkedHashMap, null );
	assertTrue( object instanceof NativeJavaLinkedHashMap );

	// test BirtHashMap
	BirtHashMap birtHashMap = new BirtHashMap( );
	object = coreWrapper.wrap( cx, scope, birtHashMap, null );
	assertTrue( object instanceof NativeJavaMap );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:26,代码来源:CoreJavaScriptWrapperTest.java

示例15: 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


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