View Javadoc

1   package es.inteco.eni.xml;
2   
3   import org.xml.sax.SAXParseException;
4   
5   
6   /**
7    * Clase que representa el resultado de la validación XML
8    * 
9    *
10   */
11  public class ValidationXmlResult {
12  
13  	/**
14  	 * Error de validacion
15  	 */
16  	private boolean validationError;
17  	/**
18  	 * Linea del error
19  	 */
20  	private int lineNumber;
21  	/**
22  	 * Columna del error
23  	 */
24  	private int columnNumber;
25  	/**
26  	 * Excepcion describiendo el error
27  	 */
28  	private Exception exception;
29  	/**
30  	 * Representacion en árbol del XML
31  	 */
32  	private XmlTree xmlTree;
33  	
34  	/**
35  	 * Constructor
36  	 */
37  	public ValidationXmlResult(){
38  		
39  	}
40  	
41  	/**
42  	 * Constructor
43  	 * @param saxParseException Excepcion
44  	 */
45  	public ValidationXmlResult(SAXParseException saxParseException){
46  		this.validationError = true;
47  		this.lineNumber = saxParseException.getLineNumber();
48  		this.columnNumber = saxParseException.getColumnNumber();
49  		this.exception = saxParseException;
50  	}
51  	
52  	/**
53  	 * @return Devuelve el valor del campo validationError
54  	 */
55  	public boolean isValidationError() {
56  		return validationError;
57  	}
58  	/**
59  	 * @param Asigna al campo validationError el valor del parámetro validationError
60  	 */
61  	public void setValidationError(boolean validationError) {
62  		this.validationError = validationError;
63  	}
64  	/**
65  	 * @return Devuelve el valor del campo lineNumber
66  	 */
67  	public int getLineNumber() {
68  		return lineNumber;
69  	}
70  	/**
71  	 * @param Asigna al campo lineNumber el valor del parámetro lineNumber
72  	 */
73  	public void setLineNumber(int lineNumber) {
74  		this.lineNumber = lineNumber;
75  	}
76  	/**
77  	 * @return Devuelve el valor del campoco lumnNumber
78  	 */
79  	public int getColumnNumber() {
80  		return columnNumber;
81  	}
82  	/**
83  	 * @param Asigna al campo columnNumber el valor del parámetro columnNumber
84  	 */
85  	public void setColumnNumber(int columnNumber) {
86  		this.columnNumber = columnNumber;
87  	}
88  	/**
89  	 * @return Devuelve el valor del campo exception
90  	 */
91  	public Exception getException() {
92  		return exception;
93  	}
94  	/**
95  	 * @param Asigna al campo exception el valor del parámetro exception
96  	 */
97  	public void setException(Exception exception) {
98  		this.exception = exception;
99  	}
100 	
101 	/**
102 	 * Devuelve el mensaje de la validación
103 	 * @return Mensaje de la validación
104 	 */
105 	public String getMessage(){
106 		String result = "";
107 		if(columnNumber!=0 && lineNumber!=0 && exception!=null){
108 			result+="["+ columnNumber + "," + lineNumber+ "] ";
109 		}
110 		if(exception!=null){
111 			result += exception.getMessage();
112 		}
113 		return result;
114 	}
115 
116 	/**
117 	 * @return Devuelve el valor del campo xmlTree
118 	 */
119 	public XmlTree getXmlTree() {
120 		return xmlTree;
121 	}
122 
123 	/**
124 	 * @param Asigna al campo xmlTree el valor del parámetro xmlTree
125 	 */
126 	public void setXmlTree(XmlTree xmlTree) {
127 		this.xmlTree = xmlTree;
128 	}
129 	
130 }