KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > script > UnsupportedScriptTypeException


1 package org.nanocontainer.script;
2
3 import org.picocontainer.PicoException;
4
5 /**
6  * Indicates that a given file extension has no corresponding builder. The
7  * message will also indicate all supported builders.
8  * @author Michael Rimov
9  * @version 1.0
10  */

11 public class UnsupportedScriptTypeException extends PicoException {
12
13     private final String JavaDoc specifiedFileExtension;
14
15     private final String JavaDoc[] allSupportedFileExtensions;
16
17     public UnsupportedScriptTypeException(String JavaDoc specifiedFileExtension, String JavaDoc[] allSupportedFileExtensions) {
18         super();
19         this.specifiedFileExtension = specifiedFileExtension;
20         this.allSupportedFileExtensions = allSupportedFileExtensions;
21     }
22
23
24
25     /**
26      * Transforms the constructor arguments into a real exption
27      * @param specifiedFileExtension String
28      * @param allSupportedFileExtensions String[]
29      * @return String
30      */

31     private String JavaDoc buildExceptionMessage() {
32         StringBuffer JavaDoc message = new StringBuffer JavaDoc(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 JavaDoc getMessage() {
58         return buildExceptionMessage();
59     }
60
61     public String JavaDoc[] getSystemSupportedExtensions() {
62         return allSupportedFileExtensions;
63     }
64
65     public String JavaDoc getRequestedExtension() {
66         return specifiedFileExtension;
67     }
68
69 }
70
Popular Tags