All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.popper.fw.interfaces.Loc Maven / Gradle / Ivy

Go to download

Definition of the interfaces all Popper Framework implementations depend on

There is a newer version: 0.6
Show newest version
/*
 * Copyright [2013] [Michael Bulla, [email protected]]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.popper.fw.interfaces;

public class Loc {
	private String cssSelector;
	
	private String xpath;
	
	protected Loc() {
		// private constructor for factory methods
	}
	
	@Override
	public String toString() {
		if (cssSelector != null) {
			return "cssSelector: " + cssSelector;
		} else  {
			return "xpath: " + xpath;
		}
	}

	public String getCssSelector() {
		return cssSelector;
	}

	public void setCssSelector(String cssSelector) {
		this.cssSelector = cssSelector;
	}

	public String getXpath() {
		return xpath;
	}

	public void setXpath(String xpath) {
		this.xpath = xpath;
	}

	public static final Loc cssSelector(String selector) {
		if (selector == null) {
			throw new RuntimeException("selector may not be null");
		}
		Loc ret = new Loc();
		ret.setCssSelector(selector);
		return ret;
	}

	public static final Loc xpath(String xpath) {
		if (xpath == null) {
			throw new RuntimeException("xpath may not be null");
		}
		Loc ret = new Loc();
		ret.setXpath(xpath);
		return ret;
	}

	public static final Loc id(String id) {
		Loc ret = new Loc();
		ret.setXpath("//*[@id='" + id + "']");
		return ret;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy