All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.xolite.XMLParseException Maven / Gradle / Ivy

Go to download

This project provides a lightweight framework to serialize/deserialize (or marshall/unmarshall) java objects into XML. The implementation is based on standard SAX (Simple Api for Xml) but it follows a original approach based on the strong data encapsulation paradigm of Object Oriented (OO) programming.

The newest version!
/*-------------------------------------------------------------------------
 Copyright 2006 Olivier Berlanger

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 -------------------------------------------------------------------------*/
package net.sf.xolite;


/**
 * Exception for XML parsing. 
* This exception allow to define the location of the bad tokens that caused the exception in the input XML. This location can be * expressed as two int (line, row) or as a plain string. */ public class XMLParseException extends Exception { private static final long serialVersionUID = -5693785937821376660L; private String source; private int line = -1; private int column = -1; public XMLParseException(String message) { super(message); } public XMLParseException(String message, Throwable cause) { super(message, cause); } @Override public String getMessage() { StringBuilder sb = new StringBuilder(); // add exception message sb.append(super.getMessage()); // add source description if (source != null) { sb.append("\n\t\tin "); sb.append(source); } // add location in source if (line >= 0) { sb.append("\n\t\tat line "); sb.append(line); if (column >= 0) { sb.append(", column "); sb.append(column); } } return sb.toString(); } public void setSource(String sourceDescription) { source = sourceDescription; } public void setLocation(int newLine, int newColumn) { line = newLine; column = newColumn; } public String getSource() { return source; } public int getLine() { return line; } public int getColumn() { return column; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy