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
calabash-android-0.4.20.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.5.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.5.2.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.5.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.5.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.5.0.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.5.0.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.22.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.22.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.22.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.21 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.20 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.19 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.19.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.19.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.19.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.19.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.18 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.16 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java
calabash-android-0.4.15.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java