1 10 package org.mmbase.datatypes.processors; 11 12 import org.mmbase.bridge.*; 13 import org.mmbase.util.Casting; 14 import org.apache.commons.fileupload.FileItem; 15 16 25 26 public class FileNameProcessor implements Processor { 27 28 private static final long serialVersionUID = 1L; 29 30 public final Object process(Node node, Field field, Object value) { 31 if (value == null) { 32 return null; 33 } else if (value instanceof FileItem) { 34 value = ((FileItem) value).getName(); 35 } 36 String fileName = Casting.toString(value); 37 int pos = fileName.lastIndexOf("\\"); 38 if (pos > 0) { 39 fileName = fileName.substring(pos + 1); 40 } 41 pos = fileName.lastIndexOf("/"); 42 if (pos > 0) { 43 fileName = fileName.substring(pos + 1); 44 } 45 return fileName; 46 } 47 48 public String toString() { 49 return "FILENAME"; 50 } 51 } 52 53 54 | Popular Tags |