KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > media > urlcomposers > FragmentURLComposer


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;
12 import org.mmbase.applications.media.builders.MediaFragments;
13 import org.mmbase.module.core.MMObjectNode;
14 import org.mmbase.util.HashCodeUtil;
15
16 import java.util.*;
17
18 /**
19  * A Fragment URLComposer is an URLComposer which can also use
20  * information about the Fragment in the URL. Generally this means
21  * that is can represent a fragments 'completely' so, with
22  * information about start and stop times.
23  *
24  *
25  * @author Michiel Meeuwissen
26  * @author Rob Vermeulen (VPRO)
27  */

28 public class FragmentURLComposer extends URLComposer {
29     protected MMObjectNode fragment;
30     
31     public void init(MMObjectNode provider, MMObjectNode source, MMObjectNode fragment, Map info, Set cacheExpireObjects) {
32         super.init(provider, source, fragment, info, cacheExpireObjects);
33         
34         if (cacheExpireObjects != null) {
35             cacheExpireObjects.add(fragment);
36         }
37         
38         this.fragment = fragment;
39     }
40     
41     public MMObjectNode getFragment() { return fragment; }
42     
43     public boolean isAvailable() {
44         Boolean JavaDoc fragmentAvailable;
45         if (fragment != null) {
46             fragmentAvailable = (Boolean JavaDoc) fragment.getFunctionValue(MediaFragments.FUNCTION_AVAILABLE, null);
47         } else {
48             fragmentAvailable = Boolean.TRUE;
49         }
50         return fragmentAvailable.booleanValue() && super.isAvailable();
51     }
52     
53     /**
54      * @see java.lang.Object#equals(java.lang.Object)
55      */

56     public boolean equals(Object JavaDoc o) {
57         if (super.equals(o)) {
58             FragmentURLComposer r = (FragmentURLComposer) o;
59             return (fragment == null ? r.fragment == null : fragment.getNumber() == r.fragment.getNumber());
60         }
61         return false;
62     }
63     
64     
65     /**
66      * @see java.lang.Object#hashCode()
67      */

68     public int hashCode() {
69         return HashCodeUtil.hashCode(super.hashCode(), fragment);
70     }
71 }
72
Popular Tags