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