1 14 package org.wings.externalizer; 15 16 import org.wings.Renderable; 17 import org.wings.io.Device; 18 import org.wings.resource.DynamicResource; 19 20 import java.io.IOException ; 21 import java.util.Collection ; 22 23 27 public class DynamicResourceExternalizer implements Externalizer { 28 29 private static final Class [] SUPPORTED_CLASSES = {DynamicResource.class}; 30 31 public static final DynamicResourceExternalizer SHARED_INSTANCE = new DynamicResourceExternalizer(); 32 33 public String getExtension(Object obj) { 34 if (obj != null) 35 return ((DynamicResource) obj).getExtension(); 36 else 37 return ""; 38 } 39 40 public String getMimeType(Object obj) { 41 if (obj != null) 42 return ((DynamicResource) obj).getMimeType(); 43 else 44 return "unknown"; 45 } 46 47 public int getLength(Object obj) { 48 return -1; 49 } 50 51 public boolean isFinal(Object obj) { 52 return true; 53 } 54 55 public String getEpoch(Object obj) { 56 return ((DynamicResource) obj).getEpoch(); 57 } 58 59 public void write(Object obj, Device out) 60 throws IOException { 61 ((Renderable) obj).write(out); 62 } 63 64 public Class [] getSupportedClasses() { 65 return SUPPORTED_CLASSES; 66 } 67 68 public String [] getSupportedMimeTypes() { 69 return null; 70 } 71 72 public Collection getHeaders(Object obj) { 73 if (obj != null) 74 return ((DynamicResource) obj).getHeaders(); 75 else 76 return null; 77 } 78 } 79 80 81 | Popular Tags |