package sm.tools.veda_client;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Resources
{
	public List<Resource> resources = new ArrayList<Resource>();

	public Resources()
	{

	}

	public Resources add(Resource rc)
	{
		for (Resource i_rc : resources)
		{
			if (i_rc.data.equals(rc.data) && i_rc.type == rc.type && i_rc.lang == rc.lang)
				return this;
		}

		resources.add(rc);
		return this;
	}

	public Resources add(String _data, String _lang)
	{
		if (_data != null)
		{
			_data = _data.replace("\\", "\\\\");

			Resource rc = new Resource(_data, 2, _lang);

			for (Resource i_rc : resources)
			{
				if (i_rc.data.equals(rc.data) && i_rc.type == rc.type && i_rc.lang == rc.lang)
					return this;
			}

			resources.add(rc);
		}
		return this;
	}

	public Resources add(String _data, int _type)
	{
		if (_data != null)
		{
			if (_type == Type._String)
				_data = _data.replace("\\", "\\\\");

			Resource rc = new Resource(_data, _type);

			for (Resource i_rc : resources)
			{
				if (i_rc.data.equals(rc.data) && i_rc.type == rc.type && i_rc.lang == rc.lang)
					return this;
			}

			resources.add(rc);
		}
		return this;
	}

	public Resources add(Date _data)
	{
		if (_data != null)
		{
			Resource rc = new Resource(util.date2string(_data), Type._Datetime);
			for (Resource i_rc : resources)
			{
				if (i_rc.data.equals(rc.data) && i_rc.type == rc.type && i_rc.lang == rc.lang)
					return this;
			}

			resources.add(rc);
		}
		return this;
	}

	public String toString()
	{
		return "" + resources;
	}
}
@@ -513,16 +513,41 @@
 ll)%0A%09%09%7B%0A
+%09%09%09_data = _data.trim();%0A
 %09%09%09_data
@@ -789,32 +789,36 @@
 ources.add(rc);%0A
+%09%09%09%0A
 %09%09%7D%0A%09%09return thi
@@ -894,24 +894,50 @@
 != null)%0A%09%09%7B
+%09%0A%09%09%09_data = _data.trim();
 %0A%09%09%09if (_typ

trim value