001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: *
019: */
020: package org.apache.mina.filter.codec;
021:
022: import org.apache.mina.common.IoBuffer;
023:
024: /**
025: * An exception that is thrown when {@link ProtocolDecoder}
026: * cannot understand or failed to validate the specified {@link IoBuffer}
027: * content.
028: *
029: * @author The Apache MINA Project (dev@mina.apache.org)
030: * @version $Rev: 581234 $, $Date: 2007-10-02 07:39:48 -0600 (Tue, 02 Oct 2007) $
031: */
032: public class ProtocolDecoderException extends ProtocolCodecException {
033: private static final long serialVersionUID = 3545799879533408565L;
034:
035: private String hexdump;
036:
037: /**
038: * Constructs a new instance.
039: */
040: public ProtocolDecoderException() {
041: }
042:
043: /**
044: * Constructs a new instance with the specified message.
045: */
046: public ProtocolDecoderException(String message) {
047: super (message);
048: }
049:
050: /**
051: * Constructs a new instance with the specified cause.
052: */
053: public ProtocolDecoderException(Throwable cause) {
054: super (cause);
055: }
056:
057: /**
058: * Constructs a new instance with the specified message and the specified
059: * cause.
060: */
061: public ProtocolDecoderException(String message, Throwable cause) {
062: super (message, cause);
063: }
064:
065: /**
066: * Returns the message and the hexdump of the unknown part.
067: */
068: @Override
069: public String getMessage() {
070: String message = super .getMessage();
071:
072: if (message == null) {
073: message = "";
074: }
075:
076: if (hexdump != null) {
077: return message + (message.length() > 0 ? " " : "")
078: + "(Hexdump: " + hexdump + ')';
079: } else {
080: return message;
081: }
082: }
083:
084: /**
085: * Returns the hexdump of the unknown message part.
086: */
087: public String getHexdump() {
088: return hexdump;
089: }
090:
091: /**
092: * Sets the hexdump of the unknown message part.
093: */
094: public void setHexdump(String hexdump) {
095: if (this .hexdump != null) {
096: throw new IllegalStateException(
097: "Hexdump cannot be set more than once.");
098: }
099: this.hexdump = hexdump;
100: }
101: }
|