01: /*
02: * Jacareto Copyright (c) 2002-2005
03: * Applied Computer Science Research Group, Darmstadt University of
04: * Technology, Institute of Mathematics & Computer Science,
05: * Ludwigsburg University of Education, and Computer Based
06: * Learning Research Group, Aachen University. All rights reserved.
07: *
08: * Jacareto is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation; either
11: * version 2 of the License, or (at your option) any later version.
12: *
13: * Jacareto is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public
19: * License along with Jacareto; if not, write to the Free
20: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21: *
22: */
23:
24: package jacareto.trackimpl.blockimpl;
25:
26: import jacareto.record.AudioClipRecordable;
27: import jacareto.record.Recordable;
28: import jacareto.record.VideoClipRecordable;
29: import jacareto.track.block.Block;
30: import jacareto.track.block.BlockFactory;
31:
32: import org.apache.commons.lang.Validate;
33:
34: /**
35: * <p>
36: * Implementation of the {@link BlockFactory} interface
37: * </p>
38: *
39: * @author Oliver Specht
40: * @version $revision$
41: */
42: public class DefaultBlockFactory implements BlockFactory {
43: /** The static instance */
44: private static final DefaultBlockFactory INSTANCE = new DefaultBlockFactory();
45:
46: private DefaultBlockFactory() {
47: }
48:
49: /**
50: * Returns the DefaultBlockFactory instance.
51: *
52: * @return DefaultBlockFactory
53: */
54: public static DefaultBlockFactory getInstance() {
55: if (DefaultBlockFactory.INSTANCE == null) {
56: return new DefaultBlockFactory();
57: }
58:
59: return DefaultBlockFactory.INSTANCE;
60: }
61:
62: /**
63: * {@inheritDoc}
64: */
65: public Block createCustomBlock(Recordable element) {
66: Validate.notNull(element);
67:
68: if (element instanceof AudioClipRecordable) {
69: return new AudioBlock(element);
70: } else if (element instanceof VideoClipRecordable) {
71: return new VideoBlock(element);
72: } else {
73: return new EventBlock(element);
74: }
75: }
76:
77: /**
78: * {@inheritDoc}
79: */
80: public Block createAudioBlock(AudioClipRecordable audioClip) {
81: return new AudioBlock(audioClip);
82: }
83:
84: /**
85: * {@inheritDoc}
86: */
87: public Block createVideoBlock(VideoClipRecordable videoClip) {
88: return new VideoBlock(videoClip);
89: }
90:
91: /**
92: * {@inheritDoc}
93: */
94: public Block createEventBlock(Recordable recordable) {
95: return new EventBlock(recordable);
96: }
97: }
|