001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: 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, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.dom.svg;
020:
021: import org.w3c.dom.Element;
022:
023: /**
024: * Thrown when a live attribute cannot parse an attribute's value.
025: *
026: * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
027: * @version $Id: LiveAttributeException.java 479349 2006-11-26 11:54:23Z cam $
028: */
029: public class LiveAttributeException extends RuntimeException {
030:
031: // Constants for the error code.
032: public static final short ERR_ATTRIBUTE_MISSING = 0;
033: public static final short ERR_ATTRIBUTE_MALFORMED = 1;
034: public static final short ERR_ATTRIBUTE_NEGATIVE = 2;
035:
036: /**
037: * The element on which the error occured.
038: */
039: protected Element e;
040:
041: /**
042: * The attribute name.
043: */
044: protected String attributeName;
045:
046: /**
047: * The reason for the exception. This must be one of the ERR_* constants
048: * defined in this class.
049: */
050: protected short code;
051:
052: /**
053: * The malformed attribute value.
054: */
055: protected String value;
056:
057: /**
058: * Constructs a new <tt>LiveAttributeException</tt> with the specified
059: * parameters.
060: *
061: * @param e the element on which the error occured
062: * @param an the attribute name
063: * @param code the error code
064: * @param val the malformed attribute value
065: */
066: public LiveAttributeException(Element e, String an, short code,
067: String val) {
068: this .e = e;
069: this .attributeName = an;
070: this .code = code;
071: this .value = val;
072: }
073:
074: /**
075: * Returns the element on which the error occurred.
076: */
077: public Element getElement() {
078: return e;
079: }
080:
081: /**
082: * Returns the attribute name.
083: */
084: public String getAttributeName() {
085: return attributeName;
086: }
087:
088: /**
089: * Returns the error code.
090: */
091: public short getCode() {
092: return code;
093: }
094:
095: /**
096: * Returns the problematic attribute value.
097: */
098: public String getValue() {
099: return value;
100: }
101: }
|