1 7 8 package org.jboss.media.registry; 9 10 import java.util.Iterator ; 11 import java.util.Map ; 12 13 import javax.emb.FormatAlreadyBoundException; 14 import javax.emb.FormatNotFoundException; 15 import javax.emb.MediaFormat; 16 17 import org.jboss.media.util.registry.MapRegistry; 18 import org.jboss.media.util.registry.ObjectAlreadyBoundException; 19 import org.jboss.media.util.registry.ObjectNotBoundException; 20 import org.jboss.media.util.registry.Registry; 21 22 28 public class SimpleMediaFormatRegistry 29 { 30 private final Registry registry; 31 32 public SimpleMediaFormatRegistry() 33 { 34 registry = new MapRegistry(); 35 } 36 37 public SimpleMediaFormatRegistry(Map initialEntries) 38 throws FormatAlreadyBoundException 39 { 40 try 41 { 42 registry = new MapRegistry(initialEntries); 43 } 44 catch (ObjectAlreadyBoundException e) 45 { 46 throw new FormatAlreadyBoundException(); 47 } 48 } 49 50 public void bind(String fileExtension, MediaFormat mediaFormat) 51 throws FormatAlreadyBoundException 52 { 53 try 54 { 55 registry.bind(fileExtension, mediaFormat); 56 } 57 catch (ObjectAlreadyBoundException e) 58 { 59 throw new FormatAlreadyBoundException(); 60 } 61 } 62 63 public void rebind(String fileExtension, MediaFormat mediaFormat) 64 { 65 registry.rebind(fileExtension, mediaFormat); 66 } 67 68 public void unbind(String fileExtension) throws FormatNotFoundException 69 { 70 try 71 { 72 registry.unbind(fileExtension); 73 } 74 catch (ObjectNotBoundException e) 75 { 76 throw new FormatNotFoundException(); 77 } 78 } 79 80 public MediaFormat lookup(String fileExtension) 81 throws FormatNotFoundException 82 { 83 try 84 { 85 return (MediaFormat) registry.lookup(fileExtension); 86 } 87 catch (ObjectNotBoundException e) 88 { 89 throw new FormatNotFoundException(); 90 } 91 } 92 93 public Iterator fileExtensions() 94 { 95 return registry.keyIterator(); 96 } 97 } 98 | Popular Tags |