net.sf.fmj.media.MergingPullDataSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fmj Show documentation
Show all versions of fmj Show documentation
Freedom for Media in Java
package net.sf.fmj.media;
import java.io.*;
import java.util.*;
import javax.media.*;
import javax.media.protocol.*;
/**
* Merges multiple {@link PullDataSource}.
*
* @author Ken Larson
*
*/
public class MergingPullDataSource extends PullDataSource
{
protected final List sources;
public MergingPullDataSource(List sources)
{
super();
this.sources = sources;
}
@Override
public void connect() throws IOException
{
for (PullDataSource source : sources)
source.connect();
}
@Override
public void disconnect()
{
for (PullDataSource source : sources)
source.disconnect();
}
@Override
public String getContentType()
{
// if all content types the same, use it, otherwise,
// ContentDescriptor.MIXED.
for (int i = 0; i < sources.size(); ++i)
{
if (!sources.get(i).getContentType()
.equals(sources.get(0).getContentType()))
return ContentDescriptor.MIXED;
}
return sources.get(0).getContentType();
}
@Override
public Object getControl(String controlType)
{
for (PullDataSource source : sources)
{
Object control = source.getControl(controlType);
if (control != null)
return control;
}
return null;
}
@Override
public Object[] getControls()
{
final List