Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
479 rajveer 1
/**
2
 * 
3
 */
4
package in.shop2020.metamodel.core;
5
 
6
import in.shop2020.metamodel.util.MetaModelComponent;
7
 
8
import java.io.UnsupportedEncodingException;
9
import java.net.URLEncoder;
500 rajveer 10
import java.util.StringTokenizer;
479 rajveer 11
 
12
/**
13
 * @author naveen
14
 *
15
 */
16
public class Media extends MetaModelComponent {
17
	/**
18
	 * 
19
	 */
20
	private static final long serialVersionUID = 1L;
21
	private String label;
22
	private String title;
23
	private String videoType;
24
	private String type;
25
	private String fileName;
26
	private String contentType;
27
	private String location;
28
 
29
	/**
30
	 * 
31
	 * @param label
32
	 * @param type
33
	 * @param location
34
	 */
35
	public Media(String label, String type, String location) {
36
		this.label = label;
37
		this.type = type;
38
		this.location = location;
39
	}
40
 
41
	/**
42
	 * @param label the label to set
43
	 */
44
	public void setLabel(String label) {
45
		this.label = label;
46
	}
47
	/**
48
	 * @return the label
49
	 */
50
	public String getLabel() {
51
		return label;
52
	}
53
	public void setTitle(String title) {
54
		this.title = title;
55
	}
56
 
57
	public String getTitle() {
58
		return title;
59
	}
60
 
61
	public void setVideoType(String videoType) {
62
		this.videoType = videoType;
63
	}
64
 
65
	public String getVideoType() {
66
		return videoType;
67
	}
68
 
69
	/**
70
	 * @return the label
71
	 */
72
	public String getEncodedLabel() {
73
		try {
74
			return URLEncoder.encode(label, "UTF-8");
75
		} catch (UnsupportedEncodingException e) {
76
			//CreationUtils.getStackTrace(e);
77
			e.printStackTrace();
78
			return "";
79
		}
80
	}
81
	/**
82
	 * @param type the type to set
83
	 */
84
	public void setType(String type) {
85
		this.type = type;
86
	}
87
	/**
88
	 * @return the type
89
	 */
90
	public String getType() {
91
		return type;
92
	}
93
	/**
94
	 * @param location the location to set
95
	 */
96
	public void setLocation(String location) {
97
		this.location = location;
98
	}
99
	/**
100
	 * @return the location
101
	 */
102
	public String getLocation() {
103
		return location;
104
	}
105
 
580 rajveer 106
	/**
107
	 * parse the youtube url and return  youtube id
108
	 * @return the youtube id.
109
	 */
500 rajveer 110
	public String getYoutubeId(){
580 rajveer 111
        String[] token = location.split("\\?v=");
112
        if(token.length == 2){
113
			return token[1];
500 rajveer 114
		}
115
		return "";
116
	}
117
 
479 rajveer 118
	/**
119
	 * @param fileName the fileName to set
120
	 */
121
	public void setFileName(String fileName) {
122
		this.fileName = fileName;
123
	}
124
 
125
	/**
126
	 * @return the fileName
127
	 */
128
	public String getFileName() {
129
		return fileName;
130
	}
131
 
132
	/**
133
	 * @param contentType the contentType to set
134
	 */
135
	public void setContentType(String contentType) {
136
		this.contentType = contentType;
137
	}
138
 
139
	/**
140
	 * @return the contentType
141
	 */
142
	public String getContentType() {
143
		return contentType;
144
	}
145
 
146
	/* (non-Javadoc)
147
	 * @see java.lang.Object#toString()
148
	 */
149
	@Override
150
	public String toString() {
151
		return "Media [label=" + label + ", location=" + location + ", type="
152
				+ type + "]";
153
	}
154
}