Index: SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUAbstractResult.java
===================================================================
--- SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUAbstractResult.java	(revision 5899)
+++ SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUAbstractResult.java	(revision 5924)
@@ -40,6 +40,6 @@
      * Add a non surrogate diagnostic to the response.
      *
-     * @param code
-     *            numerical diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      * @param details
      *            supplementary information available, often in a format
@@ -49,6 +49,6 @@
      *            <code>null</code>
      */
-    protected final void addDiagnostic(int code, String details, String message) {
-        diagnostics.addDiagnostic(code, details, message);
+    protected final void addDiagnostic(String uri, String details, String message) {
+        diagnostics.addDiagnostic(uri, details, message);
     }
 
@@ -57,12 +57,12 @@
      * Add a non surrogate diagnostic to the response.
      *
-     * @param code
-     *            numerical diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      * @param details
      *            supplementary information available, often in a format
      *            specified by the diagnostic or <code>null</code>
      */
-    protected final void addDiagnostic(int code, String details) {
-        addDiagnostic(code, details, null);
+    protected final void addDiagnostic(String uri, String details) {
+        addDiagnostic(uri, details, null);
     }
 
@@ -71,9 +71,9 @@
      * Add a non surrogate diagnostic to the response.
      *
-     * @param code
-     *            numerical diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      */
-    protected final void addDiagnostic(int code) {
-        addDiagnostic(code, null, null);
+    protected final void addDiagnostic(String uri) {
+        addDiagnostic(uri, null, null);
     }
 
Index: SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUConstants.java
===================================================================
--- SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUConstants.java	(revision 5899)
+++ SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUConstants.java	(revision 5924)
@@ -27,97 +27,182 @@
  */
 public final class SRUConstants {
+    // private constants
+    private static final String SRU_DIAGNOSTIC_URI_PREFIX =
+            "info:srw/diagnostic/1/";
 
     // general diagnostics
-    public static final int SRU_GENERAL_SYSTEM_ERROR = 1;
-    public static final int SRU_SYSTEM_TEMPORARILY_UNAVAILABLE = 2;
-    public static final int SRU_AUTHENTICATION_ERROR = 3;
-    public static final int SRU_UNSUPPORTED_OPERATION = 4;
-    public static final int SRU_UNSUPPORTED_VERSION = 5;
-    public static final int SRU_UNSUPPORTED_PARAMETER_VALUE = 6;
-    public static final int SRU_MANDATORY_PARAMETER_NOT_SUPPLIED = 7;
-    public static final int SRU_UNSUPPORTED_PARAMETER = 8;
+    public static final String SRU_GENERAL_SYSTEM_ERROR =
+            SRU_DIAGNOSTIC_URI_PREFIX + 1;
+    public static final String SRU_SYSTEM_TEMPORARILY_UNAVAILABLE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 2;
+    public static final String SRU_AUTHENTICATION_ERROR =
+            SRU_DIAGNOSTIC_URI_PREFIX + 3;
+    public static final String SRU_UNSUPPORTED_OPERATION =
+            SRU_DIAGNOSTIC_URI_PREFIX + 4;
+    public static final String SRU_UNSUPPORTED_VERSION =
+            SRU_DIAGNOSTIC_URI_PREFIX + 5;
+    public static final String SRU_UNSUPPORTED_PARAMETER_VALUE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 6;
+    public static final String SRU_MANDATORY_PARAMETER_NOT_SUPPLIED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 7;
+    public static final String SRU_UNSUPPORTED_PARAMETER =
+            SRU_DIAGNOSTIC_URI_PREFIX + 8;
     // diagnostics relating to CQL
-    public static final int SRU_QUERY_SYNTAX_ERROR = 10;
-    public static final int SRU_TOO_MANY_CHARACTERS_IN_QUERY = 12;
-    public static final int SRU_INVALID_OR_UNSUPPORTED_USE_OF_PARENTHESES = 13;
-    public static final int SRU_INVALID_OR_UNSUPPORTED_USE_OF_QUOTES = 14;
-    public static final int SRU_UNSUPPORTED_CONTEXT_SET = 15;
-    public static final int SRU_UNSUPPORTED_INDEX = 16;
-    public static final int SRU_UNSUPPORTED_COMBINATION_OF_INDEXES = 18;
-    public static final int SRU_UNSUPPORTED_RELATION = 19;
-    public static final int SRU_UNSUPPORTED_RELATION_MODIFIER = 20;
-    public static final int SRU_UNSUPPORTED_COMBINATION_OF_RELATION_MODIFERS = 21;
-    public static final int SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_INDEX = 22;
-    public static final int SRU_TOO_MANY_CHARACTERS_IN_TERM = 23;
-    public static final int SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_TERM = 24;
-    public static final int SRU_NON_SPECIAL_CHARACTER_ESCAPED_IN_TERM = 26;
-    public static final int SRU_EMPTY_TERM_UNSUPPORTED = 27;
-    public static final int SRU_MASKING_CHARACTER_NOT_SUPPORTED = 28;
-    public static final int SRU_MASKED_WORDS_TOO_SHORT = 29;
-    public static final int SRU_TOO_MANY_MASKING_CHARACTERS_IN_TERM = 30;
-    public static final int SRU_ANCHORING_CHARACTER_NOT_SUPPORTED = 31;
-    public static final int SRU_ANCHORING_CHARACTER_IN_UNSUPPORTED_POSITION = 32;
-    public static final int SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_MASKING_CHARACTERS_NOT_SUPPORTED = 33;
-    public static final int SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_ANCHORING_CHARACTERS_NOT_SUPPORTED = 34;
-    public static final int SRU_TERM_CONTAINS_ONLY_STOPWORDS = 35;
-    public static final int SRU_TERM_IN_INVALID_FORMAT_FOR_INDEX_OR_RELATION = 36;
-    public static final int SRU_UNSUPPORTED_BOOLEAN_OPERATOR = 37;
-    public static final int SRU_TOO_MANY_BOOLEAN_OPERATORS_IN_QUERY = 38;
-    public static final int SRU_PROXIMITY_NOT_SUPPORTED = 39;
-    public static final int SRU_UNSUPPORTED_PROXIMITY_RELATION = 40;
-    public static final int SRU_UNSUPPORTED_PROXIMITY_DISTANCE = 41;
-    public static final int SRU_UNSUPPORTED_PROXIMITY_UNIT = 42;
-    public static final int SRU_UNSUPPORTED_PROXIMITY_ORDERING = 43;
-    public static final int SRU_UNSUPPORTED_COMBINATION_OF_PROXIMITY_MODIFIERS = 44;
-    public static final int SRU_UNSUPPORTED_BOOLEAN_MODIFIER = 46;
-    public static final int SRU_CANNOT_PROCESS_QUERY_REASON_UNKNOWN = 47;
-    public static final int SRU_QUERY_FEATURE_UNSUPPORTED = 48;
-    public static final int SRU_MASKING_CHARACTER_IN_UNSUPPORTED_POSITION = 49;
+    public static final String SRU_QUERY_SYNTAX_ERROR =
+            SRU_DIAGNOSTIC_URI_PREFIX + 10;
+    public static final String SRU_TOO_MANY_CHARACTERS_IN_QUERY =
+            SRU_DIAGNOSTIC_URI_PREFIX + 12;
+    public static final String SRU_INVALID_OR_UNSUPPORTED_USE_OF_PARENTHESES =
+            SRU_DIAGNOSTIC_URI_PREFIX + 13;
+    public static final String SRU_INVALID_OR_UNSUPPORTED_USE_OF_QUOTES =
+            SRU_DIAGNOSTIC_URI_PREFIX + 14;
+    public static final String SRU_UNSUPPORTED_CONTEXT_SET =
+            SRU_DIAGNOSTIC_URI_PREFIX + 15;
+    public static final String SRU_UNSUPPORTED_INDEX =
+            SRU_DIAGNOSTIC_URI_PREFIX + 16;
+    public static final String SRU_UNSUPPORTED_COMBINATION_OF_INDEXES =
+            SRU_DIAGNOSTIC_URI_PREFIX + 18;
+    public static final String SRU_UNSUPPORTED_RELATION =
+            SRU_DIAGNOSTIC_URI_PREFIX + 19;
+    public static final String SRU_UNSUPPORTED_RELATION_MODIFIER =
+            SRU_DIAGNOSTIC_URI_PREFIX + 20;
+    public static final String SRU_UNSUPPORTED_COMBINATION_OF_RELATION_MODIFERS =
+            SRU_DIAGNOSTIC_URI_PREFIX + 21;
+    public static final String SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_INDEX =
+            SRU_DIAGNOSTIC_URI_PREFIX + 22;
+    public static final String SRU_TOO_MANY_CHARACTERS_IN_TERM =
+            SRU_DIAGNOSTIC_URI_PREFIX + 23;
+    public static final String SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_TERM =
+            SRU_DIAGNOSTIC_URI_PREFIX + 24;
+    public static final String SRU_NON_SPECIAL_CHARACTER_ESCAPED_IN_TERM =
+            SRU_DIAGNOSTIC_URI_PREFIX + 26;
+    public static final String SRU_EMPTY_TERM_UNSUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 27;
+    public static final String SRU_MASKING_CHARACTER_NOT_SUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 28;
+    public static final String SRU_MASKED_WORDS_TOO_SHORT =
+            SRU_DIAGNOSTIC_URI_PREFIX + 29;
+    public static final String SRU_TOO_MANY_MASKING_CHARACTERS_IN_TERM =
+            SRU_DIAGNOSTIC_URI_PREFIX + 30;
+    public static final String SRU_ANCHORING_CHARACTER_NOT_SUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 31;
+    public static final String SRU_ANCHORING_CHARACTER_IN_UNSUPPORTED_POSITION =
+            SRU_DIAGNOSTIC_URI_PREFIX + 32;
+    public static final String SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_MASKING_CHARACTERS_NOT_SUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 33;
+    public static final String SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_ANCHORING_CHARACTERS_NOT_SUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 34;
+    public static final String SRU_TERM_CONTAINS_ONLY_STOPWORDS =
+            SRU_DIAGNOSTIC_URI_PREFIX + 35;
+    public static final String SRU_TERM_IN_INVALID_FORMAT_FOR_INDEX_OR_RELATION =
+            SRU_DIAGNOSTIC_URI_PREFIX + 36;
+    public static final String SRU_UNSUPPORTED_BOOLEAN_OPERATOR =
+            SRU_DIAGNOSTIC_URI_PREFIX + 37;
+    public static final String SRU_TOO_MANY_BOOLEAN_OPERATORS_IN_QUERY =
+            SRU_DIAGNOSTIC_URI_PREFIX + 38;
+    public static final String SRU_PROXIMITY_NOT_SUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 39;
+    public static final String SRU_UNSUPPORTED_PROXIMITY_RELATION =
+            SRU_DIAGNOSTIC_URI_PREFIX + 40;
+    public static final String SRU_UNSUPPORTED_PROXIMITY_DISTANCE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 41;
+    public static final String SRU_UNSUPPORTED_PROXIMITY_UNIT =
+            SRU_DIAGNOSTIC_URI_PREFIX + 42;
+    public static final String SRU_UNSUPPORTED_PROXIMITY_ORDERING =
+            SRU_DIAGNOSTIC_URI_PREFIX + 43;
+    public static final String SRU_UNSUPPORTED_COMBINATION_OF_PROXIMITY_MODIFIERS =
+            SRU_DIAGNOSTIC_URI_PREFIX + 44;
+    public static final String SRU_UNSUPPORTED_BOOLEAN_MODIFIER =
+            SRU_DIAGNOSTIC_URI_PREFIX + 46;
+    public static final String SRU_CANNOT_PROCESS_QUERY_REASON_UNKNOWN =
+            SRU_DIAGNOSTIC_URI_PREFIX + 47;
+    public static final String SRU_QUERY_FEATURE_UNSUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 48;
+    public static final String SRU_MASKING_CHARACTER_IN_UNSUPPORTED_POSITION =
+            SRU_DIAGNOSTIC_URI_PREFIX + 49;
     // diagnostics relating to result sets
-    public static final int SRU_RESULT_SETS_NOT_SUPPORTED = 50;
-    public static final int SRU_RESULT_SET_DOES_NOT_EXIST = 51;
-    public static final int SRU_RESULT_SET_TEMPORARILY_UNAVAILABLE = 52;
-    public static final int SRU_RESULT_SETS_ONLY_SUPPORTED_FOR_RETRIEVAL = 53;
-    public static final int SRU_COMBINATION_OF_RESULT_SETS_WITH_SEARCH_TERMS_NOT_SUPPORTED = 55;
-    public static final int SRU_RESULT_SET_CREATED_WITH_UNPREDICTABLE_PARTIAL_RESULTS_AVAILABLE = 58;
-    public static final int SRU_RESULT_SET_CREATED_WITH_VALID_PARTIAL_RESULTS_AVAILABLE = 59;
-    public static final int SRU_RESULT_SET_NOT_CREATED_TOO_MANY_MATCHING_RECORDS = 60;
+    public static final String SRU_RESULT_SETS_NOT_SUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 50;
+    public static final String SRU_RESULT_SET_DOES_NOT_EXIST =
+            SRU_DIAGNOSTIC_URI_PREFIX + 51;
+    public static final String SRU_RESULT_SET_TEMPORARILY_UNAVAILABLE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 52;
+    public static final String SRU_RESULT_SETS_ONLY_SUPPORTED_FOR_RETRIEVAL =
+            SRU_DIAGNOSTIC_URI_PREFIX + 53;
+    public static final String SRU_COMBINATION_OF_RESULT_SETS_WITH_SEARCH_TERMS_NOT_SUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 55;
+    public static final String SRU_RESULT_SET_CREATED_WITH_UNPREDICTABLE_PARTIAL_RESULTS_AVAILABLE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 58;
+    public static final String SRU_RESULT_SET_CREATED_WITH_VALID_PARTIAL_RESULTS_AVAILABLE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 59;
+    public static final String SRU_RESULT_SET_NOT_CREATED_TOO_MANY_MATCHING_RECORDS =
+            SRU_DIAGNOSTIC_URI_PREFIX + 60;
     // diagnostics relating to records
-    public static final int SRU_FIRST_RECORD_POSITION_OUT_OF_RANGE = 61;
-    public static final int SRU_RECORD_TEMPORARILY_UNAVAILABLE = 64;
-    public static final int SRU_RECORD_DOES_NOT_EXIST = 65;
-    public static final int SRU_UNKNOWN_SCHEMA_FOR_RETRIEVAL = 66;
-    public static final int SRU_RECORD_NOT_AVAILABLE_IN_THIS_SCHEMA = 67;
-    public static final int SRU_NOT_AUTHORISED_TO_SEND_RECORD = 68;
-    public static final int SRU_NOT_AUTHORISED_TO_SEND_RECORD_IN_THIS_SCHEMA = 69;
-    public static final int SRU_RECORD_TOO_LARGE_TO_SEND = 70;
-    public static final int SRU_UNSUPPORTED_RECORD_PACKING = 71;
-    public static final int SRU_XPATH_RETRIEVAL_UNSUPPORTED = 72;
-    public static final int SRU_XPATH_EXPRESSION_CONTAINS_UNSUPPORTED_FEATURE = 73;
-    public static final int SRU_UNABLE_TO_EVALUATE_XPATH_EXPRESSION = 74;
+    public static final String SRU_FIRST_RECORD_POSITION_OUT_OF_RANGE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 61;
+    public static final String SRU_RECORD_TEMPORARILY_UNAVAILABLE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 64;
+    public static final String SRU_RECORD_DOES_NOT_EXIST =
+            SRU_DIAGNOSTIC_URI_PREFIX + 65;
+    public static final String SRU_UNKNOWN_SCHEMA_FOR_RETRIEVAL =
+            SRU_DIAGNOSTIC_URI_PREFIX + 66;
+    public static final String SRU_RECORD_NOT_AVAILABLE_IN_THIS_SCHEMA =
+            SRU_DIAGNOSTIC_URI_PREFIX + 67;
+    public static final String SRU_NOT_AUTHORISED_TO_SEND_RECORD =
+            SRU_DIAGNOSTIC_URI_PREFIX + 68;
+    public static final String SRU_NOT_AUTHORISED_TO_SEND_RECORD_IN_THIS_SCHEMA =
+            SRU_DIAGNOSTIC_URI_PREFIX + 69;
+    public static final String SRU_RECORD_TOO_LARGE_TO_SEND =
+            SRU_DIAGNOSTIC_URI_PREFIX + 70;
+    public static final String SRU_UNSUPPORTED_RECORD_PACKING =
+            SRU_DIAGNOSTIC_URI_PREFIX + 71;
+    public static final String SRU_XPATH_RETRIEVAL_UNSUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 72;
+    public static final String SRU_XPATH_EXPRESSION_CONTAINS_UNSUPPORTED_FEATURE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 73;
+    public static final String SRU_UNABLE_TO_EVALUATE_XPATH_EXPRESSION =
+            SRU_DIAGNOSTIC_URI_PREFIX + 74;
     // diagnostics relating to sorting
-    public static final int SRU_SORT_NOT_SUPPORTED = 80;
-    public static final int SRU_UNSUPPORTED_SORT_SEQUENCE = 82;
-    public static final int SRU_TOO_MANY_RECORDS_TO_SORT = 83;
-    public static final int SRU_TOO_MANY_SORT_KEYS_TO_SORT = 84;
-    public static final int SRU_CANNOT_SORT_INCOMPATIBLE_RECORD_FORMATS = 86;
-    public static final int SRU_UNSUPPORTED_SCHEMA_FOR_SORT = 87;
-    public static final int SRU_UNSUPPORTED_PATH_FOR_SORT = 88;
-    public static final int SRU_PATH_UNSUPPORTED_FOR_SCHEMA = 89;
-    public static final int SRU_UNSUPPORTED_DIRECTION = 90;
-    public static final int SRU_UNSUPPORTED_CASE = 91;
-    public static final int SRU_UNSUPPORTED_MISSING_VALUE_ACTION = 92;
-    public static final int SRU_SORT_ENDED_DUE_TO_MISSING_VALUE = 93;
-    public static final int SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_QUERY_PREVAILS = 94;
-    public static final int SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_PROTOCOL_PREVAILS = 95;
-    public static final int SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_ERROR = 96;
+    public static final String SRU_SORT_NOT_SUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 80;
+    public static final String SRU_UNSUPPORTED_SORT_SEQUENCE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 82;
+    public static final String SRU_TOO_MANY_RECORDS_TO_SORT =
+            SRU_DIAGNOSTIC_URI_PREFIX + 83;
+    public static final String SRU_TOO_MANY_SORT_KEYS_TO_SORT =
+            SRU_DIAGNOSTIC_URI_PREFIX + 84;
+    public static final String SRU_CANNOT_SORT_INCOMPATIBLE_RECORD_FORMATS =
+            SRU_DIAGNOSTIC_URI_PREFIX + 86;
+    public static final String SRU_UNSUPPORTED_SCHEMA_FOR_SORT =
+            SRU_DIAGNOSTIC_URI_PREFIX + 87;
+    public static final String SRU_UNSUPPORTED_PATH_FOR_SORT =
+            SRU_DIAGNOSTIC_URI_PREFIX + 88;
+    public static final String SRU_PATH_UNSUPPORTED_FOR_SCHEMA =
+            SRU_DIAGNOSTIC_URI_PREFIX + 89;
+    public static final String SRU_UNSUPPORTED_DIRECTION =
+            SRU_DIAGNOSTIC_URI_PREFIX + 90;
+    public static final String SRU_UNSUPPORTED_CASE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 91;
+    public static final String SRU_UNSUPPORTED_MISSING_VALUE_ACTION =
+            SRU_DIAGNOSTIC_URI_PREFIX + 92;
+    public static final String SRU_SORT_ENDED_DUE_TO_MISSING_VALUE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 93;
+    public static final String SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_QUERY_PREVAILS =
+            SRU_DIAGNOSTIC_URI_PREFIX + 94;
+    public static final String SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_PROTOCOL_PREVAILS =
+            SRU_DIAGNOSTIC_URI_PREFIX + 95;
+    public static final String SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_ERROR =
+            SRU_DIAGNOSTIC_URI_PREFIX + 96;
     // diagnostics relating to stylesheets
-    public static final int SRU_STYLESHEETS_NOT_SUPPORTED = 110;
-    public static final int SRU_UNSUPPORTED_STYLESHEET = 111;
+    public static final String SRU_STYLESHEETS_NOT_SUPPORTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 110;
+    public static final String SRU_UNSUPPORTED_STYLESHEET =
+            SRU_DIAGNOSTIC_URI_PREFIX + 111;
     // diagnostics relating to scan
-    public static final int SRU_RESPONSE_POSITION_OUT_OF_RANGE = 120;
-    public static final int SRU_TOO_MANY_TERMS_REQUESTED = 121;
-
-    public static final String SRU_DIAGNOSTIC_URI_PREFIX = "info:srw/diagnostic/1/";
+    public static final String SRU_RESPONSE_POSITION_OUT_OF_RANGE =
+            SRU_DIAGNOSTIC_URI_PREFIX + 120;
+    public static final String SRU_TOO_MANY_TERMS_REQUESTED =
+            SRU_DIAGNOSTIC_URI_PREFIX + 121;
+
 
     /* hide constructor */
Index: SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUDiagnostic.java
===================================================================
--- SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUDiagnostic.java	(revision 5899)
+++ SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUDiagnostic.java	(revision 5924)
@@ -28,5 +28,5 @@
  */
 public final class SRUDiagnostic {
-    private final int code;
+    private final String uri;
     private final String details;
     private final String message;
@@ -36,6 +36,6 @@
      * Constructor.
      *
-     * @param code
-     *            numerical diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      * @param details
      *            supplementary information available, often in a format
@@ -44,8 +44,31 @@
      *            human readable message to display to the end user or
      *            <code>null</code>
-     */
-    public SRUDiagnostic(int code, String details, String message) {
-        this.code    = code;
+     * @throws NullPointerException
+     *             if uri is <code>null</code>
+     * @throws IllegalArgumentException
+     *             if uri is empty string
+     */
+    public SRUDiagnostic(String uri, String details, String message) {
+        if (uri == null) {
+            throw new NullPointerException("uri == null");
+        }
+        uri = uri.trim();
+        if (uri.isEmpty()) {
+            throw new IllegalArgumentException("uri is empty");
+        }
+        this.uri     = uri;
+        if (details != null) {
+            details = details.trim();
+            if (details.isEmpty()) {
+                details = null;
+            }
+        }
         this.details = details;
+        if (message != null) {
+            message = message.trim();
+            if (message.isEmpty()) {
+                message = null;
+            }
+        }
         this.message = message;
     }
@@ -55,12 +78,12 @@
      * Constructor.
      *
-     * @param code
-     *            numerical diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      * @param details
      *            supplementary information available, often in a format
      *            specified by the diagnostic or <code>null</code>
      */
-    public SRUDiagnostic(int code, String details) {
-        this(code, details, null);
+    public SRUDiagnostic(String uri, String details) {
+        this(uri, details, null);
     }
 
@@ -69,9 +92,9 @@
      * Constructor.
      *
-     * @param code
-     *            numerical diagnostic code
-     */
-    public SRUDiagnostic(int code) {
-        this(code, null, null);
+     * @param uri
+     *            the diagnostic's identifying URI
+     */
+    public SRUDiagnostic(String uri) {
+        this(uri, null, null);
     }
 
@@ -83,6 +106,6 @@
      * @see SRUConstants
      */
-    public int getCode() {
-        return code;
+    public String getURI() {
+        return uri;
     }
 
@@ -105,179 +128,182 @@
      */
     public String getMessage() {
-        return message != null ? message : getDefaultErrorMessage(code);
-    }
-
-
-    private static String getDefaultErrorMessage(int code) {
-        switch (code) {
-        case SRUConstants.SRU_GENERAL_SYSTEM_ERROR:
+        return message != null ? message : getDefaultErrorMessage(uri);
+    }
+
+
+    private static String getDefaultErrorMessage(final String uri) {
+        /*
+         * Ugly, but can't do better unless we drop JDK 1.6 compatibility.
+         * (JDK 1.7+ has switch on String)
+         */
+        if (uri.equals(SRUConstants.SRU_GENERAL_SYSTEM_ERROR)) {
             return "General system error";
-        case SRUConstants.SRU_SYSTEM_TEMPORARILY_UNAVAILABLE:
+        } else if (uri.equals(SRUConstants.SRU_SYSTEM_TEMPORARILY_UNAVAILABLE)) {
             return "System temporarily unavailable";
-        case SRUConstants.SRU_AUTHENTICATION_ERROR:
+        } else if (uri.equals(SRUConstants.SRU_AUTHENTICATION_ERROR)) {
             return "Authentication error";
-        case SRUConstants.SRU_UNSUPPORTED_OPERATION:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_OPERATION)) {
             return "Unsupported operation";
-        case SRUConstants.SRU_UNSUPPORTED_VERSION:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_VERSION)) {
             return "Unsupported version";
-        case SRUConstants.SRU_UNSUPPORTED_PARAMETER_VALUE:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PARAMETER_VALUE)) {
             return "Unsupported parameter value";
-        case SRUConstants.SRU_MANDATORY_PARAMETER_NOT_SUPPLIED:
+        } else if (uri.equals(SRUConstants.SRU_MANDATORY_PARAMETER_NOT_SUPPLIED)) {
             return "Mandatory parameter not supplied";
-        case SRUConstants.SRU_UNSUPPORTED_PARAMETER:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PARAMETER)) {
             return "Unsupported Parameter";
-        case SRUConstants.SRU_QUERY_SYNTAX_ERROR:
+        } else if (uri.equals(SRUConstants.SRU_QUERY_SYNTAX_ERROR)) {
             return "Query syntax error";
-        case SRUConstants.SRU_TOO_MANY_CHARACTERS_IN_QUERY:
+        } else if (uri.equals(SRUConstants.SRU_TOO_MANY_CHARACTERS_IN_QUERY)) {
             return "Too many characters in query";
-        case SRUConstants.SRU_INVALID_OR_UNSUPPORTED_USE_OF_PARENTHESES:
+        } else if (uri.equals(SRUConstants.SRU_INVALID_OR_UNSUPPORTED_USE_OF_PARENTHESES)) {
             return "Invalid or unsupported use of parentheses";
-        case SRUConstants.SRU_INVALID_OR_UNSUPPORTED_USE_OF_QUOTES:
+        } else if (uri.equals(SRUConstants.SRU_INVALID_OR_UNSUPPORTED_USE_OF_QUOTES)) {
             return "Invalid or unsupported use of quotes";
-        case SRUConstants.SRU_UNSUPPORTED_CONTEXT_SET:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_CONTEXT_SET)) {
             return "Unsupported context set";
-        case SRUConstants.SRU_UNSUPPORTED_INDEX:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_INDEX)) {
             return "Unsupported index";
-        case SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_INDEXES:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_INDEXES)) {
             return "Unsupported combination of indexes";
-        case SRUConstants.SRU_UNSUPPORTED_RELATION:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_RELATION)) {
             return "Unsupported relation";
-        case SRUConstants.SRU_UNSUPPORTED_RELATION_MODIFIER:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_RELATION_MODIFIER)) {
             return "Unsupported relation modifier";
-        case SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_MODIFERS:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_MODIFERS)) {
             return "Unsupported combination of relation modifers";
-        case SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_INDEX:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_INDEX)) {
             return "Unsupported combination of relation and index";
-        case SRUConstants.SRU_TOO_MANY_CHARACTERS_IN_TERM:
+        } else if (uri.equals(SRUConstants.SRU_TOO_MANY_CHARACTERS_IN_TERM)) {
             return "Too many characters in term";
-        case SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_TERM:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_RELATION_AND_TERM)) {
             return "Unsupported combination of relation and term";
-        case SRUConstants.SRU_NON_SPECIAL_CHARACTER_ESCAPED_IN_TERM:
+        } else if (uri.equals(SRUConstants.SRU_NON_SPECIAL_CHARACTER_ESCAPED_IN_TERM)) {
             return "Non special character escaped in term";
-        case SRUConstants.SRU_EMPTY_TERM_UNSUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_EMPTY_TERM_UNSUPPORTED)) {
             return "Empty term unsupported";
-        case SRUConstants.SRU_MASKING_CHARACTER_NOT_SUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_MASKING_CHARACTER_NOT_SUPPORTED)) {
             return "Masking character not supported";
-        case SRUConstants.SRU_MASKED_WORDS_TOO_SHORT:
+        } else if (uri.equals(SRUConstants.SRU_MASKED_WORDS_TOO_SHORT)) {
             return "Masked words too short";
-        case SRUConstants.SRU_TOO_MANY_MASKING_CHARACTERS_IN_TERM:
+        } else if (uri.equals(SRUConstants.SRU_TOO_MANY_MASKING_CHARACTERS_IN_TERM)) {
             return "Too many masking characters in term";
-        case SRUConstants.SRU_ANCHORING_CHARACTER_NOT_SUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_ANCHORING_CHARACTER_NOT_SUPPORTED)) {
             return "Anchoring character not supported";
-        case SRUConstants.SRU_ANCHORING_CHARACTER_IN_UNSUPPORTED_POSITION:
+        } else if (uri.equals(SRUConstants.SRU_ANCHORING_CHARACTER_IN_UNSUPPORTED_POSITION)) {
             return "Anchoring character in unsupported position";
-        case SRUConstants.SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_MASKING_CHARACTERS_NOT_SUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_MASKING_CHARACTERS_NOT_SUPPORTED)) {
             return "Combination of proximity adjacency and masking characters not supported";
-        case SRUConstants.SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_ANCHORING_CHARACTERS_NOT_SUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_COMBINATION_OF_PROXIMITY_ADJACENCY_AND_ANCHORING_CHARACTERS_NOT_SUPPORTED)) {
             return "Combination of proximity adjacency and anchoring characters not supported";
-        case SRUConstants.SRU_TERM_CONTAINS_ONLY_STOPWORDS:
+        } else if (uri.equals(SRUConstants.SRU_TERM_CONTAINS_ONLY_STOPWORDS)) {
             return "Term contains only stopwords";
-        case SRUConstants.SRU_TERM_IN_INVALID_FORMAT_FOR_INDEX_OR_RELATION:
+        } else if (uri.equals(SRUConstants.SRU_TERM_IN_INVALID_FORMAT_FOR_INDEX_OR_RELATION)) {
             return "Term in invalid format for index or relation";
-        case SRUConstants.SRU_UNSUPPORTED_BOOLEAN_OPERATOR:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_BOOLEAN_OPERATOR)) {
             return "Unsupported boolean operator";
-        case SRUConstants.SRU_TOO_MANY_BOOLEAN_OPERATORS_IN_QUERY:
+        } else if (uri.equals(SRUConstants.SRU_TOO_MANY_BOOLEAN_OPERATORS_IN_QUERY)) {
             return "Too many boolean operators in query";
-        case SRUConstants.SRU_PROXIMITY_NOT_SUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_PROXIMITY_NOT_SUPPORTED)) {
             return "Proximity not supported";
-        case SRUConstants.SRU_UNSUPPORTED_PROXIMITY_RELATION:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PROXIMITY_RELATION)) {
             return "Unsupported proximity relation";
-        case SRUConstants.SRU_UNSUPPORTED_PROXIMITY_DISTANCE:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PROXIMITY_DISTANCE)) {
             return "Unsupported proximity distance";
-        case SRUConstants.SRU_UNSUPPORTED_PROXIMITY_UNIT:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PROXIMITY_UNIT)) {
             return "Unsupported proximity unit";
-        case SRUConstants.SRU_UNSUPPORTED_PROXIMITY_ORDERING:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PROXIMITY_ORDERING)) {
             return "Unsupported proximity ordering";
-        case SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_PROXIMITY_MODIFIERS:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_COMBINATION_OF_PROXIMITY_MODIFIERS)) {
             return "Unsupported combination of proximity modifiers";
-        case SRUConstants.SRU_UNSUPPORTED_BOOLEAN_MODIFIER:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_BOOLEAN_MODIFIER)) {
             return "Unsupported boolean modifier";
-        case SRUConstants.SRU_CANNOT_PROCESS_QUERY_REASON_UNKNOWN:
+        } else if (uri.equals(SRUConstants.SRU_CANNOT_PROCESS_QUERY_REASON_UNKNOWN)) {
             return "Cannot process query; reason unknown";
-        case SRUConstants.SRU_QUERY_FEATURE_UNSUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_QUERY_FEATURE_UNSUPPORTED)) {
             return "Query feature unsupported";
-        case SRUConstants.SRU_MASKING_CHARACTER_IN_UNSUPPORTED_POSITION:
+        } else if (uri.equals(SRUConstants.SRU_MASKING_CHARACTER_IN_UNSUPPORTED_POSITION)) {
             return "Masking character in unsupported position";
-        case SRUConstants.SRU_RESULT_SETS_NOT_SUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_RESULT_SETS_NOT_SUPPORTED)) {
             return "Result sets not supported";
-        case SRUConstants.SRU_RESULT_SET_DOES_NOT_EXIST:
+        } else if (uri.equals(SRUConstants.SRU_RESULT_SET_DOES_NOT_EXIST)) {
             return "Result set does not exist";
-        case SRUConstants.SRU_RESULT_SET_TEMPORARILY_UNAVAILABLE:
+        } else if (uri.equals(SRUConstants.SRU_RESULT_SET_TEMPORARILY_UNAVAILABLE)) {
             return "Result set temporarily unavailable";
-        case SRUConstants.SRU_RESULT_SETS_ONLY_SUPPORTED_FOR_RETRIEVAL:
+        } else if (uri.equals(SRUConstants.SRU_RESULT_SETS_ONLY_SUPPORTED_FOR_RETRIEVAL)) {
             return "Result sets only supported for retrieval";
-        case SRUConstants.SRU_COMBINATION_OF_RESULT_SETS_WITH_SEARCH_TERMS_NOT_SUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_COMBINATION_OF_RESULT_SETS_WITH_SEARCH_TERMS_NOT_SUPPORTED)) {
             return "Combination of result sets with search terms not supported";
-        case SRUConstants.SRU_RESULT_SET_CREATED_WITH_UNPREDICTABLE_PARTIAL_RESULTS_AVAILABLE:
+        } else if (uri.equals(SRUConstants.SRU_RESULT_SET_CREATED_WITH_UNPREDICTABLE_PARTIAL_RESULTS_AVAILABLE)) {
             return "Result set created with unpredictable partial results available";
-        case SRUConstants.SRU_RESULT_SET_CREATED_WITH_VALID_PARTIAL_RESULTS_AVAILABLE:
+        } else if (uri.equals(SRUConstants.SRU_RESULT_SET_CREATED_WITH_VALID_PARTIAL_RESULTS_AVAILABLE)) {
             return "Result set created with valid partial results available";
-        case SRUConstants.SRU_RESULT_SET_NOT_CREATED_TOO_MANY_MATCHING_RECORDS:
-            return "Result set not created: too many matching records";
-        case SRUConstants.SRU_FIRST_RECORD_POSITION_OUT_OF_RANGE:
+        } else if (uri.equals(SRUConstants.SRU_RESULT_SET_NOT_CREATED_TOO_MANY_MATCHING_RECORDS)) {
+            return "Result set not created)) { too many matching records";
+        } else if (uri.equals(SRUConstants.SRU_FIRST_RECORD_POSITION_OUT_OF_RANGE)) {
             return "First record position out of range";
-        case SRUConstants.SRU_RECORD_TEMPORARILY_UNAVAILABLE:
+        } else if (uri.equals(SRUConstants.SRU_RECORD_TEMPORARILY_UNAVAILABLE)) {
             return "Record temporarily unavailable";
-        case SRUConstants.SRU_RECORD_DOES_NOT_EXIST:
+        } else if (uri.equals(SRUConstants.SRU_RECORD_DOES_NOT_EXIST)) {
             return "Record does not exist";
-        case SRUConstants.SRU_UNKNOWN_SCHEMA_FOR_RETRIEVAL:
+        } else if (uri.equals(SRUConstants.SRU_UNKNOWN_SCHEMA_FOR_RETRIEVAL)) {
             return "Unknown schema for retrieval";
-        case SRUConstants.SRU_RECORD_NOT_AVAILABLE_IN_THIS_SCHEMA:
+        } else if (uri.equals(SRUConstants.SRU_RECORD_NOT_AVAILABLE_IN_THIS_SCHEMA)) {
             return "Record not available in this schema";
-        case SRUConstants.SRU_NOT_AUTHORISED_TO_SEND_RECORD:
+        } else if (uri.equals(SRUConstants.SRU_NOT_AUTHORISED_TO_SEND_RECORD)) {
             return "Not authorised to send record";
-        case SRUConstants.SRU_NOT_AUTHORISED_TO_SEND_RECORD_IN_THIS_SCHEMA:
+        } else if (uri.equals(SRUConstants.SRU_NOT_AUTHORISED_TO_SEND_RECORD_IN_THIS_SCHEMA)) {
             return "Not authorised to send record in this schema";
-        case SRUConstants.SRU_RECORD_TOO_LARGE_TO_SEND:
+        } else if (uri.equals(SRUConstants.SRU_RECORD_TOO_LARGE_TO_SEND)) {
             return "Record too large to send";
-        case SRUConstants.SRU_UNSUPPORTED_RECORD_PACKING:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_RECORD_PACKING)) {
             return "Unsupported record packing";
-        case SRUConstants.SRU_XPATH_RETRIEVAL_UNSUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_XPATH_RETRIEVAL_UNSUPPORTED)) {
             return "XPath retrieval unsupported";
-        case SRUConstants.SRU_XPATH_EXPRESSION_CONTAINS_UNSUPPORTED_FEATURE:
+        } else if (uri.equals(SRUConstants.SRU_XPATH_EXPRESSION_CONTAINS_UNSUPPORTED_FEATURE)) {
             return "XPath expression contains unsupported feature";
-        case SRUConstants.SRU_UNABLE_TO_EVALUATE_XPATH_EXPRESSION:
+        } else if (uri.equals(SRUConstants.SRU_UNABLE_TO_EVALUATE_XPATH_EXPRESSION)) {
             return "Unable to evaluate XPath expression";
-        case SRUConstants.SRU_SORT_NOT_SUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_SORT_NOT_SUPPORTED)) {
             return "Sort not supported";
-        case SRUConstants.SRU_UNSUPPORTED_SORT_SEQUENCE:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_SORT_SEQUENCE)) {
             return "Unsupported sort sequence";
-        case SRUConstants.SRU_TOO_MANY_RECORDS_TO_SORT:
+        } else if (uri.equals(SRUConstants.SRU_TOO_MANY_RECORDS_TO_SORT)) {
             return "Too many records to sort";
-        case SRUConstants.SRU_TOO_MANY_SORT_KEYS_TO_SORT:
+        } else if (uri.equals(SRUConstants.SRU_TOO_MANY_SORT_KEYS_TO_SORT)) {
             return "Too many sort keys to sort";
-        case SRUConstants.SRU_CANNOT_SORT_INCOMPATIBLE_RECORD_FORMATS:
+        } else if (uri.equals(SRUConstants.SRU_CANNOT_SORT_INCOMPATIBLE_RECORD_FORMATS)) {
             return "Cannot sort incompatible record formats";
-        case SRUConstants.SRU_UNSUPPORTED_SCHEMA_FOR_SORT:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_SCHEMA_FOR_SORT)) {
             return "Unsupported schema for sort";
-        case SRUConstants.SRU_UNSUPPORTED_PATH_FOR_SORT:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_PATH_FOR_SORT)) {
             return "Unsupported path for sort";
-        case SRUConstants.SRU_PATH_UNSUPPORTED_FOR_SCHEMA:
+        } else if (uri.equals(SRUConstants.SRU_PATH_UNSUPPORTED_FOR_SCHEMA)) {
             return "Path unsupported for schema";
-        case SRUConstants.SRU_UNSUPPORTED_DIRECTION:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_DIRECTION)) {
             return "Unsupported direction";
-        case SRUConstants.SRU_UNSUPPORTED_CASE:
-            return "Unsupported case";
-        case SRUConstants.SRU_UNSUPPORTED_MISSING_VALUE_ACTION:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_CASE)) {
+            return "Unsupported } else if (uri.equals(";
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_MISSING_VALUE_ACTION)) {
             return "Unsupported missing value action";
-        case SRUConstants.SRU_SORT_ENDED_DUE_TO_MISSING_VALUE:
+        } else if (uri.equals(SRUConstants.SRU_SORT_ENDED_DUE_TO_MISSING_VALUE)) {
             return "Sort ended due to missing value";
-        case SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_QUERY_PREVAILS:
+        } else if (uri.equals(SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_QUERY_PREVAILS)) {
             return "Sort spec included both in query and protocol query prevails";
-        case SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_PROTOCOL_PREVAILS:
+        } else if (uri.equals(SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_PROTOCOL_PREVAILS)) {
             return "Sort spec included both in query and protocol protocol prevails";
-        case SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_ERROR:
+        } else if (uri.equals(SRUConstants.SRU_SORT_SPEC_INCLUDED_BOTH_IN_QUERY_AND_PROTOCOL_ERROR)) {
             return "Sort spec included both in query and protocol error";
-        case SRUConstants.SRU_STYLESHEETS_NOT_SUPPORTED:
+        } else if (uri.equals(SRUConstants.SRU_STYLESHEETS_NOT_SUPPORTED)) {
             return "Stylesheets not supported";
-        case SRUConstants.SRU_UNSUPPORTED_STYLESHEET:
+        } else if (uri.equals(SRUConstants.SRU_UNSUPPORTED_STYLESHEET)) {
             return "Unsupported stylesheet";
-        case SRUConstants.SRU_RESPONSE_POSITION_OUT_OF_RANGE:
+        } else if (uri.equals(SRUConstants.SRU_RESPONSE_POSITION_OUT_OF_RANGE)) {
             return "Response position out of range";
-        case SRUConstants.SRU_TOO_MANY_TERMS_REQUESTED:
+        } else if (uri.equals(SRUConstants.SRU_TOO_MANY_TERMS_REQUESTED)) {
             return "Too many terms requested";
-        default:
+        } else {
             return null;
-        } // switch
+        }
     }
 
Index: SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUDiagnosticList.java
===================================================================
--- SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUDiagnosticList.java	(revision 5899)
+++ SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUDiagnosticList.java	(revision 5924)
@@ -33,6 +33,6 @@
      * Add a non surrogate diagnostic to the response.
      *
-     * @param code
-     *            numerical diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      * @param details
      *            supplementary information available, often in a format
@@ -42,5 +42,5 @@
      *            <code>null</code>
      */
-    public void addDiagnostic(int code, String details, String message);
+    public void addDiagnostic(String uri, String details, String message);
 
 } // interface DiagnosticList
Index: SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUException.java
===================================================================
--- SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUException.java	(revision 5899)
+++ SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUException.java	(revision 5924)
@@ -25,5 +25,5 @@
 @SuppressWarnings("serial")
 public class SRUException extends Exception {
-    private final int code;
+    private final String uri;
     private final String details;
 
@@ -32,6 +32,6 @@
      * Constructor.
      *
-     * @param code
-     *            the diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      * @param details
      *            diagnostic details or <code>null</code>
@@ -41,8 +41,15 @@
      *            the cause of the error or <code>null</code>
      */
-    public SRUException(int code, String details, String message,
+    public SRUException(String uri, String details, String message,
             Throwable cause) {
         super(message, cause);
-        this.code    = code;
+        if (uri == null) {
+            throw new NullPointerException("uri == null");
+        }
+        uri = uri.trim();
+        if (uri.isEmpty()) {
+            throw new IllegalArgumentException("uri is empty");
+        }
+        this.uri     = uri;
         this.details = details;
     }
@@ -52,6 +59,6 @@
      * Constructor.
      *
-     * @param code
-     *            the diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      * @param details
      *            diagnostic details or <code>null</code>
@@ -59,6 +66,6 @@
      *            diagnostic message or <code>null</code>
      */
-    public SRUException(int code, String details, String message) {
-        this(code, details, message, null);
+    public SRUException(String uri, String details, String message) {
+        this(uri, details, message, null);
     }
 
@@ -67,6 +74,6 @@
      * Constructor.
      *
-     * @param code
-     *            the diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      * @param message
      *            diagnostic message or <code>null</code>
@@ -74,6 +81,6 @@
      *            the cause of the error or <code>null</code>
      */
-    public SRUException(int code, String message, Throwable cause) {
-        this(code, null, message, cause);
+    public SRUException(String uri, String message, Throwable cause) {
+        this(uri, null, message, cause);
     }
 
@@ -82,11 +89,11 @@
      * Constructor.
      *
-     * @param code
-     *            the diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      * @param message
      *            diagnostic message or <code>null</code>
      */
-    public SRUException(int code, String message) {
-        this(code, null, message, null);
+    public SRUException(String uri, String message) {
+        this(uri, null, message, null);
     }
 
@@ -95,11 +102,11 @@
      * Constructor.
      *
-     * @param code
-     *            the diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      * @param cause
      *            the cause of the error or <code>null</code>
      */
-    public SRUException(int code, Throwable cause) {
-        this(code, null, null, cause);
+    public SRUException(String uri, Throwable cause) {
+        this(uri, null, null, cause);
     }
 
@@ -108,9 +115,9 @@
      * Constructor.
      *
-     * @param code
-     *            the diagnostic code
+     * @param uri
+     *            the diagnostic's identifying URI
      */
-    public SRUException(int code) {
-        this(code, null, null, null);
+    public SRUException(String uri) {
+        this(uri, null, null, null);
     }
 
@@ -122,5 +129,5 @@
      */
     public SRUDiagnostic getDiagnostic() {
-        return new SRUDiagnostic(code, details, this.getMessage());
+        return new SRUDiagnostic(uri, details, this.getMessage());
     }
 
Index: SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequestImpl.java
===================================================================
--- SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequestImpl.java	(revision 5899)
+++ SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRURequestImpl.java	(revision 5924)
@@ -623,9 +623,11 @@
 
     @Override
-    public void addDiagnostic(int code, String details, String message) {
+    public void addDiagnostic(String uri, String details, String message) {
+        final SRUDiagnostic diagnostic =
+                new SRUDiagnostic(uri, details, message);
         if (diagnostics == null) {
             diagnostics = new ArrayList<SRUDiagnostic>();
         }
-        diagnostics.add(new SRUDiagnostic(code, details, message));
+        diagnostics.add(diagnostic);
     }
 
Index: SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServer.java
===================================================================
--- SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServer.java	(revision 5899)
+++ SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServer.java	(revision 5924)
@@ -153,15 +153,11 @@
                     final String message = e.getDiagnostic().getMessage();
                     if (message != null) {
-                        logger.info("Sending fatal diagnostic '{}{}' with " +
+                        logger.info("Sending fatal diagnostic '{}' with " +
                                 "message '{}'",
-                                new Object[] {
-                                        SRUConstants.SRU_DIAGNOSTIC_URI_PREFIX,
-                                        e.getDiagnostic().getCode(),
-                                        message
-                                });
+                                e.getDiagnostic().getURI(),
+                                message);
                     } else {
-                        logger.info("Sending fatal diagnostic '{}{}'",
-                                SRUConstants.SRU_DIAGNOSTIC_URI_PREFIX,
-                                e.getDiagnostic().getCode());
+                        logger.info("Sending fatal diagnostic '{}'",
+                                e.getDiagnostic().getURI());
                     }
                     logger.debug("Fatal diagnostic was caused by " +
@@ -818,6 +814,5 @@
         }
         out.writeStartElement(SRU_DIAGNOSIC_NS, "uri");
-        out.writeCharacters(SRUConstants.SRU_DIAGNOSTIC_URI_PREFIX);
-        out.writeCharacters(Integer.toString(diagnostic.getCode()));
+        out.writeCharacters(diagnostic.getURI());
         out.writeEndElement(); // "uri" element
         if (diagnostic.getDetails() != null) {
