PageRenderTime 13ms CodeModel.GetById 11ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 1ms

/src/dom-text.vala

http://libgdom3.googlecode.com/
Vala | 22 lines | 19 code | 2 blank | 1 comment | 5 complexity | ab665c12a8b7aa0e4ed4816294b560b6 MD5 | raw file
 1using GLib;
 2using Gee;
 3
 4namespace DOM {
 5	public class Text : CharacterData {
 6		public Text(Document owner, string data) {
 7			(base as Node)(owner, Node.Type.TEXT, "#text");
 8			this.data = data;
 9		}
10		/* Text Interface */
11		public Text splitText(long offset) throws Exception {
12			if(offset >= data.length || offset <= 0) throw new Exception.INDEX_SIZE_ERR("splitting has to be in the center of a string");
13
14			string splited_data = data.substring(offset, data.length - offset);
15			data = data.substring(0, offset);
16			Text splitted = ownerDocument.createTextNode(splited_data);
17			if(this.parentNode != null)
18				return this.parentNode.insertBefore(splitted, this.nextSibling) as Text;
19			else return splitted;
20		}
21	}
22}