1 /* 2 * Copyright 2006 Simon Raess 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package net.sf.beep4j.internal.profile; 17 18 /** 19 * Object representation of a BEEP error element. A BEEP error has 20 * a code and a diagnostic message. 21 * 22 * @author Simon Raess 23 */ 24 public final class BEEPError { 25 26 /** 27 * The three digit error code that is significant for machines. 28 */ 29 private final int code; 30 31 /** 32 * The diagnostic message significant for humans. 33 */ 34 private final String message; 35 36 /** 37 * Creates a new BEEPError object with the given code and 38 * diagnostic message. The message can be null. 39 * 40 * @param code the status code 41 * @param message the diagnostic message 42 */ 43 public BEEPError(int code, String message) { 44 this.code = code; 45 this.message = message; 46 } 47 48 /** 49 * Gets the three digit status code. See section 8 of RFC 3080. 50 * 51 * @return the status code 52 */ 53 public int getCode() { 54 return code; 55 } 56 57 /** 58 * Gets the diagnostic message. 59 * 60 * @return the diagnostic message 61 */ 62 public String getMessage() { 63 return message; 64 } 65 66 @Override 67 public String toString() { 68 return "<error code='" + code + "'>" + message + "</code>"; 69 } 70 71 }