org.jcodec.containers.mxf.model.MXFUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jcodec Show documentation
Show all versions of jcodec Show documentation
Pure Java implementation of video/audio codecs and formats
package org.jcodec.containers.mxf.model;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
/**
* This class is part of JCodec ( www.jcodec.org ) This software is distributed
* under FreeBSD License
*
* MXF demuxer
*
* @author The JCodec project
*
*/
public class MXFUtil {
public static T resolveRef(List metadata, UL refs, Class class1) {
List res = resolveRefs(metadata, new UL[] { refs }, class1);
return res.size() > 0 ? res.get(0) : null;
}
public static List resolveRefs(List metadata, UL[] refs, Class class1) {
List copy = new ArrayList(metadata);
for (Iterator iterator = copy.iterator(); iterator.hasNext();) {
MXFMetadata next = iterator.next();
if (next.getUid() == null || !class1.isAssignableFrom(next.getClass()))
iterator.remove();
}
List result = new ArrayList();
for (int i = 0; i < refs.length; i++) {
for (MXFMetadata meta : copy) {
if (meta.getUid().equals(refs[i])) {
result.add(meta);
}
}
}
return result;
}
public static T findMeta(Collection metadata, Class class1) {
for (MXFMetadata mxfMetadata : metadata) {
if (mxfMetadata.getClass().isAssignableFrom(class1))
return (T) mxfMetadata;
}
return null;
}
public static List findAllMeta(Collection metadata, Class class1) {
List result = new ArrayList();
for (MXFMetadata mxfMetadata : metadata) {
if (class1.isAssignableFrom(mxfMetadata.getClass()))
result.add((T) mxfMetadata);
}
return result;
}
}