diff options
Diffstat (limited to 'demos/org.eclipse.fx.demo.media/src/org/eclipse/fx/demo/media/model/Media.java')
-rwxr-xr-x | demos/org.eclipse.fx.demo.media/src/org/eclipse/fx/demo/media/model/Media.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/demos/org.eclipse.fx.demo.media/src/org/eclipse/fx/demo/media/model/Media.java b/demos/org.eclipse.fx.demo.media/src/org/eclipse/fx/demo/media/model/Media.java new file mode 100755 index 000000000..165a16639 --- /dev/null +++ b/demos/org.eclipse.fx.demo.media/src/org/eclipse/fx/demo/media/model/Media.java @@ -0,0 +1,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; + } +} |