Subversion Repositories SmartDukaan

Rev

Rev 1050 | Rev 2720 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * 
 */
package in.shop2020.metamodel.core;

import in.shop2020.metamodel.util.MetaModelComponent;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * @author naveen
 *
 */
public class Media extends MetaModelComponent {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        private String label;
        private String title;
        private String videoType;
        private String type;
        private String fileName;
        private String contentType;
        private String location;
        
        /**
         * 
         * @param label
         * @param type
         * @param location
         */
        public Media(String label, String type, String location) {
                this.label = label;
                this.type = type;
                this.location = location;
        }
        
        /**
         * @param label the label to set
         */
        public void setLabel(String label) {
                this.label = label;
        }
        /**
         * @return the label
         */
        public String getLabel() {
                return label;
        }
        public void setTitle(String title) {
                this.title = title;
        }

        public String getTitle() {
                return title;
        }

        public void setVideoType(String videoType) {
                this.videoType = videoType;
        }

        public String getVideoType() {
                return videoType;
        }

        /**
         * @return the label
         */
        public String getEncodedLabel() {
                try {
                        return URLEncoder.encode(label, "UTF-8");
                } catch (UnsupportedEncodingException e) {
                        //CreationUtils.getStackTrace(e);
                        e.printStackTrace();
                        return "";
                }
        }
        /**
         * @param type the type to set
         */
        public void setType(String type) {
                this.type = type;
        }
        /**
         * @return the type
         */
        public String getType() {
                return type;
        }
        /**
         * @param location the location to set
         */
        public void setLocation(String location) {
                this.location = location;
        }
        /**
         * @return the location
         */
        public String getLocation() {
                return location;
        }

        /**
         * parse the youtube url and return  youtube id
         * @return the youtube id.
         */
        public String getYoutubeId(){
        String[] token = location.split("\\?v=");
        if(token.length == 2){
                        return token[1];
                }
                return "";
        }
        
        /**
         * @param fileName the fileName to set
         */
        public void setFileName(String fileName) {
                this.fileName = fileName;
        }

        /**
         * @return the fileName
         */
        public String getFileName() {
                return fileName;
        }

        /**
         * @param contentType the contentType to set
         */
        public void setContentType(String contentType) {
                this.contentType = contentType;
        }

        /**
         * @return the contentType
         */
        public String getContentType() {
                return contentType;
        }

        /* (non-Javadoc)
         * @see java.lang.Object#toString()
         */
        @Override
        public String toString() {
                return "Media [label=" + label + ", location=" + location + ", type="
                                + type + "]";
        }
}