Skip to main content
summaryrefslogtreecommitdiffstats
blob: 165a166392933d5d4442227aa3bda0e67104d415 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package org.eclipse.fx.demo.media.model;

import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class Media {
	private ReadOnlyObjectProperty<MediaType> type;
	private SimpleStringProperty name = new SimpleStringProperty(this, "name");
	private SimpleStringProperty url = new SimpleStringProperty(this, "url");
	
	public Media(MediaType type) {
		this.type = new SimpleObjectProperty<MediaType>(this, "type", type);
	}
	
	public Media(MediaType type, String name, String url) {
		this(type);
		this.name.set(name);
		this.url.set(url);
	}
	
	public MediaType getType() {
		return this.type.get();
	}
	
	public ReadOnlyObjectProperty<MediaType> type() {
		return type;
	}
	
	public void setName(String name) {
		this.name.set(name);
	}
	
	public String getName() {
		return this.name.get();
	}
	
	public StringProperty name() {
		return this.name;
	}
	
	public void setUrl(String url) {
		this.url.set(url);
	}
	
	public String getUrl() {
		return this.url.get();
	}
	
	public StringProperty url() {
		return this.url;
	}
	
	public static final String serialize(Media media) {
		return media.type.getValue().name() + "##_##" + media.name.getValue() + "##_##" + media.url.getValue();
	}
	
	public static final Media deserialize(String serializedObject) {
		String[] parts = serializedObject.split("##_##");
		Media m = new Media(MediaType.valueOf(parts[0]));
		m.setName(parts[1]);
		m.setUrl(parts[2]);
		return m;
	}
}

Back to the top