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

org.zkoss.zk.ui.select.impl.PseudoClass Maven / Gradle / Ivy

There is a newer version: 10.0.0-jakarta
Show newest version
package org.zkoss.zk.ui.select.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * The model representing a pseudo class in Selector
 * @since 6.0.0
 * @author simonpai
 */
public class PseudoClass {
	
	private String _name;
	private List _parameters = new ArrayList();
	
	public PseudoClass(String name){
		_name = name;
	}
	
	public String getName() {
		return _name;
	}
	
	public void setName(String name) {
		_name = name;
	}
	
	public String[] getParameter() {
		return _parameters.toArray(new String[0]);
	}
	
	public void addParameter(String parameter) {
		_parameters.add(parameter);
	}
	
	public String toString() {
		return ":"+_name + (_parameters.isEmpty()? "" : 
			"(" + join(_parameters, ",") + ")");
	}
	
	// helper //
	private static String join(List objs, String joiner){
		if(objs == null || objs.isEmpty()) return "";
		Iterator iter = objs.iterator();
		StringBuffer sb = new StringBuffer(iter.next().toString());
		while(iter.hasNext()) sb.append(joiner).append(iter.next());
		return sb.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy