Sha256: 2c753531ea463fa4db8c8ab6e303a29824e89691f8666b8a0fc8455ddc2d1f88

Contents?: true

Size: 1.27 KB

Versions: 79

Compression:

Stored size: 1.27 KB

Contents

package sh.calaba.instrumentationbackend.query;

import java.lang.reflect.Method;
import java.util.Map;

import sh.calaba.instrumentationbackend.query.ast.UIQueryUtils;
import android.view.View;

public class PropertyOperation implements Operation {

	public final String propertyName;	
	
	public PropertyOperation(String propertyName) {
		super();
		this.propertyName = propertyName;
	}


	@SuppressWarnings({ "rawtypes" })
	@Override
	public Object apply(Object o) throws Exception {
		if (o instanceof Map) {
			Map objAsMap = (Map) o;
			if (objAsMap.containsKey(propertyName)) {											
				return objAsMap.get(propertyName);
			} else {
				return UIQueryResultVoid.instance.asMap(
						propertyName, o, "No key for "
								+ propertyName + ". Keys: "
								+ (objAsMap.keySet().toString()));
			}
		} else {
			if (o instanceof View && "id".equals(propertyName)) {
				return UIQueryUtils.getId((View) o);
			} else {
				Method m = UIQueryUtils
						.hasProperty(o, propertyName);
				if (m != null) {
					return m.invoke(o);					
				} else {
					return UIQueryResultVoid.instance
							.asMap(propertyName, o,
									"NO accessor for "
											+ propertyName);
				}
			}
		}

	}

	@Override
	public String getName() {
		return "Property["+this.propertyName+"]";
	}

}

Version data entries

79 entries across 79 versions & 2 rubygems

Version Path
testautoa-0.4.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.3.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.3.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
testautoa-0.4.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.0.pre18 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
testautoa-0.4.0.pre19 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
testautoa-0.4.0.pre18 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
testautoa-0.4.0.pre16 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.0.pre17 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.0.pre16 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.0.pre15 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.0.pre11 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.0.pre10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.0.pre9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.0.pre8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.0.pre7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java