/*
* Jacareto Copyright (c) 2002-2005
* Applied Computer Science Research Group, Darmstadt University of
* Technology, Institute of Mathematics & Computer Science,
* Ludwigsburg University of Education, and Computer Based
* Learning Research Group, Aachen University. All rights reserved.
*
* Jacareto is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* Jacareto is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with Jacareto; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
package jacareto.trackimpl.blockimpl;
import jacareto.record.AudioClipRecordable;
import jacareto.record.Recordable;
import jacareto.record.VideoClipRecordable;
import jacareto.track.block.Block;
import jacareto.track.block.BlockFactory;
import org.apache.commons.lang.Validate;
/**
* <p>
* Implementation of the {@link BlockFactory} interface
* </p>
*
* @author Oliver Specht
* @version $revision$
*/
public class DefaultBlockFactory implements BlockFactory {
/** The static instance */
private static final DefaultBlockFactory INSTANCE = new DefaultBlockFactory();
private DefaultBlockFactory () {
}
/**
* Returns the DefaultBlockFactory instance.
*
* @return DefaultBlockFactory
*/
public static DefaultBlockFactory getInstance () {
if (DefaultBlockFactory.INSTANCE == null) {
return new DefaultBlockFactory();
}
return DefaultBlockFactory.INSTANCE;
}
/**
* {@inheritDoc}
*/
public Block createCustomBlock (Recordable element) {
Validate.notNull (element);
if (element instanceof AudioClipRecordable) {
return new AudioBlock(element);
} else if (element instanceof VideoClipRecordable) {
return new VideoBlock(element);
} else {
return new EventBlock(element);
}
}
/**
* {@inheritDoc}
*/
public Block createAudioBlock (AudioClipRecordable audioClip) {
return new AudioBlock(audioClip);
}
/**
* {@inheritDoc}
*/
public Block createVideoBlock (VideoClipRecordable videoClip) {
return new VideoBlock(videoClip);
}
/**
* {@inheritDoc}
*/
public Block createEventBlock (Recordable recordable) {
return new EventBlock(recordable);
}
}
|