KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > media > urlcomposers > omroep > RealSbURLComposer


1 /*
2   
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5   
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8   
9 */

10
11 package org.mmbase.applications.media.urlcomposers.omroep;
12 import org.mmbase.applications.media.urlcomposers.RealURLComposer;
13
14 import java.util.Map JavaDoc;
15
16 /**
17  * An example. URL's from these kind of URLComposers can contain 'start' and 'end' arguments and so on.
18  *
19  * @author Michiel Meeuwissen
20  * @version $Id: RealSbURLComposer.java,v 1.8 2003/11/26 16:48:37 michiel Exp $
21  * @since MMBase-1.7
22  */

23 public class RealSbURLComposer extends RealURLComposer {
24
25     public boolean canCompose() {
26         return provider.getStringValue("host").equals("cgi.omroep.nl") && provider.getStringValue("rootpath").charAt(0) == '%';
27     }
28
29
30     /**
31      * Add the url to the buffer, but first remove the sb. or bb. prefix if it is in it already.
32      */

33     static int addURL(StringBuffer JavaDoc buf, String JavaDoc url) {
34         int length = buf.length();
35         buf.append(url);
36         int lastSlash = length + url.lastIndexOf('/');
37         String JavaDoc existingPrefix = buf.substring(lastSlash + 1, lastSlash + 4);
38         if (existingPrefix.equals("sb.") || existingPrefix.equals("bb.")) { // remove existing prefix, if there is one.
39
buf.delete(lastSlash + 1, lastSlash + 4);
40         }
41         return lastSlash;
42     }
43
44     
45     protected String JavaDoc getBandPrefix() {
46         return "sb.";
47     }
48     protected String JavaDoc getBand() {
49         return "smalband";
50     }
51     public String JavaDoc getGUIIndicator(Map JavaDoc options) {
52         return super.getGUIIndicator(options) + " (" + getBand() +")";
53     }
54
55     protected StringBuffer JavaDoc getURLBuffer() {
56         StringBuffer JavaDoc buff = new StringBuffer JavaDoc("rtsp://streams.omroep.nl");
57         int lastSlash = addURL(buff, source.getStringValue("url"));
58         buff.insert(lastSlash + 1, getBandPrefix());
59         RealURLComposer.getRMArgs(buff, fragment, info); // append time, title, als
60
return buff;
61     }
62 }
63
64
65
Popular Tags