1 14 package org.wings.externalizer; 15 16 import org.wings.Resource; 17 import org.wings.io.Device; 18 19 import java.io.IOException ; 20 import java.util.Collection ; 21 22 26 public class ResourceExternalizer implements Externalizer { 27 28 private static final Class [] SUPPORTED_CLASSES = {Resource.class}; 29 30 public static final ResourceExternalizer SHARED_INSTANCE = new ResourceExternalizer(); 31 32 public String getExtension(Object obj) { 33 return ((Resource) obj).getExtension(); 34 } 35 36 public String getMimeType(Object obj) { 37 return ((Resource) obj).getMimeType(); 38 } 39 40 public int getLength(Object obj) { 41 return ((Resource) obj).getLength(); 42 } 43 44 public boolean isFinal(Object obj) { 45 return false; 46 } 47 48 public void write(Object obj, Device out) 49 throws IOException { 50 ((Resource) obj).write(out); 51 } 52 53 public Class [] getSupportedClasses() { 54 return SUPPORTED_CLASSES; 55 } 56 57 public String [] getSupportedMimeTypes() { 58 return null; 59 } 60 61 public Collection getHeaders(Object obj) { 62 return ((Resource) obj).getHeaders(); 63 } 64 65 } 66 | Popular Tags |