1 14 package org.wings.externalizer; 15 16 import org.wings.Renderable; 17 import org.wings.io.Device; 18 import org.wings.resource.StringResource; 19 20 import java.io.IOException ; 21 import java.util.Collection ; 22 23 28 public class StringResourceExternalizer implements Externalizer { 29 30 private static final Class [] SUPPORTED_CLASSES = {StringResource.class}; 31 32 public static final StringResourceExternalizer SHARED_INSTANCE = new StringResourceExternalizer(); 33 34 public String getExtension(Object obj) { 35 if (obj != null) 36 return ((StringResource) obj).getExtension(); 37 else 38 return ""; 39 } 40 41 public String getMimeType(Object obj) { 42 if (obj != null) 43 return ((StringResource) obj).getMimeType(); 44 else 45 return "unknown"; 46 } 47 48 public int getLength(Object obj) { 49 if (obj != null) 50 return ((StringResource) 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 ((StringResource) obj).getHeaders(); 74 else 75 return null; 76 } 77 } 78 79 80 | Popular Tags |