1 21 package com.db4o; 22 23 import java.io.*; 24 25 import com.db4o.config.*; 26 27 30 public final class Messages 31 { 32 public final static int CLOSED_OR_OPEN_FAILED = 20; 33 public final static int FATAL_MSG_ID=44; 34 public final static int NOT_IMPLEMENTED=49; 35 public final static int ONLY_FOR_INDEXED_FIELDS=66; 36 public final static int CLIENT_SERVER_UNSUPPORTED=67; 37 38 private static String [] i_messages; 39 40 public static String get(int a_code){ 41 return get(a_code, null); 42 } 43 44 public static String get(int a_code, String param){ 45 if(a_code < 0){ 46 return param; 47 } 48 load(); 49 if(i_messages == null || a_code > i_messages.length - 1){ 50 return "msg[" + a_code + "]"; 51 } 52 String msg = i_messages[a_code]; 53 if(param != null){ 54 int pos = msg.indexOf("%",0); 55 if(pos > -1){ 56 msg = msg.substring(0, pos) 57 + "'" 58 + param 59 + "'" 60 + msg.substring(pos + 1); 61 } 62 } 63 return msg; 64 } 65 66 private static void load(){ 67 if(i_messages == null) { 68 if(Tuning.readableMessages){ 69 70 i_messages = new String [] { 71 "", "blocksize should be between 1 and 127", 73 "% close request", 74 "% closed", 75 "Exception opening %", 76 "% opened O.K.", "Class %: Instantiation failed. \n Check custom ObjectConstructor code.", 78 "Class %: Instantiation failed.\n Add a constructor for use with db4o, ideally with zero arguments.", 79 "renaming %", 80 "rename not possible. % already exists", 81 "rename failed", "File close failed.", 83 "File % not available for readwrite access.", 84 "File read access failed.", 85 "File not found: % Creating new file", 86 "Creation of file failed: %", "File write failed.", 88 "File format incompatible.", 89 "Uncaught Exception. Engine closed.", 90 "writing log for %", 91 "% is closed. close() was called or open() failed.", "Filename not specified.", 93 "The database file is locked by another process.", 94 "Class not available: %. Check CLASSPATH settings.", 95 "finalized while performing a task.\n DO NOT USE CTRL + C OR System.exit() TO STOP THE ENGINE.", 96 "Please mail the following to exception@db4o.com:\n <db4o " + Db4oVersion.NAME + " stacktrace>", "</db4o " + Db4oVersion.NAME + " stacktrace>", 98 "Creation of lock file failed: %", 99 "Previous session was not shut down correctly", 100 "This method call is only possible on stored objects", 101 "Could not open port: %", "Server listening on port: %", 103 "Client % connected.", 104 "Client % timed out and closed.", 105 "Connection closed by client %.", 106 "Connection closed by server. %.", "% connected to server.", 108 "The directory % can neither be found nor created.", 109 "This blob was never stored.", 110 "Blob file % not available.", 111 "Failure finding blob filename.", "File does not exist %.", 113 "Failed to connect to server.", 114 "No blob data stored.", 115 "Uncaught Exception. db4o engine closed.", 116 "Add constructor that won't throw exceptions, configure constructor calls, or provide a translator to class % and make sure the class is deployed to the server with the same package/namespace + assembly name.", "This method can only be called before opening the database file.", 118 "AccessibleObject#setAccessible() is not available. Private fields can not be stored.", 119 "ObjectTranslator could not be installed: %.", 120 "Not implemented", 121 "% closed by ShutdownHook.", "This constraint is not persistent. It has no database identity.", 123 "Add at least one ObjectContainer to the Cluster", 124 "Unsupported Operation", 125 "Database password does not match user-provided password.", 126 "Thread interrupted.", "Password can not be null.", 128 "Classes does not match.", 129 "rename() needs to be executed on the server.", 130 "Primitive types like % can not be stored directly. Store and retrieve them in wrapper objects.", 131 "Backups can not be run from clients and memory files.", "Backup in progress.", 133 "Only use persisted first class objects as keys for IdentityHashMap.", 134 "This functionality is only available from version 5.0 onwards.", 135 "By convention a Predicate needs the following method: public boolean match(ExtentClass extent){}", 136 "Old database file format detected. To allow automatic updates call Db4o.configure().allowVersionUpdates(true).", "This functionality is only available for indexed fields.", "This functionality is not supported for db4o clients in Client/Server mode.", "Invalid address: %", }; 141 }else{ 142 i_messages = new String [0]; 143 } 144 } 145 146 } 147 148 public static void logErr (Configuration config, int code, String msg, Throwable t) { 149 if(config == null){ 150 config = Db4o.configure(); 151 } 152 PrintStream ps = ((Config4Impl)config).errStream(); 153 new Message(msg, code,ps); 154 if(t != null){ 155 new Message(null,25,ps); 156 t.printStackTrace(ps); 157 new Message(null,26,ps, false); 158 } 159 } 160 161 public static void logMsg (Configuration config, int code, String msg) { 162 if(Deploy.debug){ 163 if(code == 0){ 164 System.out.println(msg); 165 return; 166 } 167 } 168 Config4Impl c4i = (Config4Impl)config; 169 if(c4i == null){ 170 c4i = (Config4Impl)Db4o.configure(); 171 } 172 173 if(c4i.messageLevel() > YapConst.NONE){ 174 new Message(msg,code,c4i.outStream()); 175 } 176 } 177 } 178 179 | Popular Tags |