All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jcodec.containers.mxf.model.MXFUtil Maven / Gradle / Ivy

There is a newer version: 0.2.5
Show newest version
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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy