1 package org.nanocontainer.script; 2 3 import org.picocontainer.PicoException; 4 5 11 public class UnsupportedScriptTypeException extends PicoException { 12 13 private final String specifiedFileExtension; 14 15 private final String [] allSupportedFileExtensions; 16 17 public UnsupportedScriptTypeException(String specifiedFileExtension, String [] allSupportedFileExtensions) { 18 super(); 19 this.specifiedFileExtension = specifiedFileExtension; 20 this.allSupportedFileExtensions = allSupportedFileExtensions; 21 } 22 23 24 25 31 private String buildExceptionMessage() { 32 StringBuffer message = new StringBuffer (48); 33 message.append("Unsupported file extension '"); 34 message.append(specifiedFileExtension); 35 message.append("'. Supported extensions are: ["); 36 37 if (allSupportedFileExtensions != null) { 38 boolean needPipe = false; 39 for (int i = 0; i < allSupportedFileExtensions.length; i++) { 40 if (needPipe) { 41 message.append("|"); 42 } else { 43 needPipe = true; 44 } 45 46 message.append(allSupportedFileExtensions[i]); 47 } 48 49 message.append("]."); 50 } else { 51 message.append(" null "); 52 } 53 54 return message.toString(); 55 } 56 57 public String getMessage() { 58 return buildExceptionMessage(); 59 } 60 61 public String [] getSystemSupportedExtensions() { 62 return allSupportedFileExtensions; 63 } 64 65 public String getRequestedExtension() { 66 return specifiedFileExtension; 67 } 68 69 } 70 | Popular Tags |