KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > LocationOfException


1 /*
2
3   Loader - tool for transfering data from one JDBC source to another and
4   doing transformations during copy.
5
6     Copyright (C) 2002-2003 Together
7
8     This library is free software; you can redistribute it and/or
9     modify it under the terms of the GNU Lesser General Public
10     License as published by the Free Software Foundation; either
11     version 2.1 of the License, or (at your option) any later version.
12
13     This library is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16     Lesser General Public License for more details.
17
18     You should have received a copy of the GNU Lesser General Public
19     License along with this library; if not, write to the Free Software
20     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22  Loader.java
23  Date: 03.03.2003.
24  @version 2.1 alpha
25  @author:
26  Radoslav Dutina rale@prozone.co.yu
27
28 */

29
30 package org.webdocwf.util.loader;
31
32 import java.io.*;
33 import java.sql.*;
34 import java.util.*;
35
36 /**
37  *
38  * LocationOfException class provide exact line where exception are happened
39  * @author Radoslav Dutina
40  * @version 1.0
41  */

42 public class LocationOfException {
43
44   private static int introNumber=0;
45   private static int dtdNumber=0;
46   private static int jdbcNumber=0;
47   private static Vector fileLineNumber=new Vector();
48   private static String JavaDoc fileName="";
49   private static int exceptionNumber=0;
50   private static String JavaDoc baseFile="";
51   private static int createDropNumber=0;
52
53
54
55   /**
56    * This constructor set value of base xml file
57    * @param baseFileName is name of base xml file
58    */

59   public LocationOfException(String JavaDoc baseFileName) {
60     baseFile=baseFileName;
61   }
62
63   /**
64    * This method set value of introNumber parameter
65    * @param lineNumber is value of parmeter
66    */

67   public static void setIntroNumber(int lineNumber){
68     introNumber=lineNumber;
69   }
70
71   /**
72    * This method set value of dtdNumber parameter
73    * @param lineNumber is value of parameter
74    */

75   public static void setDtdNumber(int lineNumber){
76     dtdNumber=lineNumber;
77   }
78
79   /**
80    * This method set value of jdbcNumber parameter
81    * @param lineNumber is value of parameter
82    */

83   public static void setJdbcNumber(int lineNumber){
84     jdbcNumber=lineNumber;
85   }
86
87   /**
88    * This method set value of fileLineNumber parameter
89    * @param lineNumber is secunde value of pratemeter
90    * @param fileName is first value of parameter
91    */

92   public static void setFileLineNumber(int lineNumber, String JavaDoc fileName){
93     fileLineNumber.add(String.valueOf(lineNumber));
94     fileLineNumber.add(fileName);
95   }
96
97   /**
98    * This method read value of exceptionNumber parameter
99    * @param number is line number of exception
100    * @return value of parameter
101    */

102   public static int getLineNumber(int number){
103     int temp1=introNumber+dtdNumber+jdbcNumber;
104     if(number<introNumber){
105       fileName=baseFile;
106     }else if(number>introNumber && number<=introNumber+dtdNumber){
107       fileName="Dtd file which match "+baseFile;
108     }else if(number>introNumber+dtdNumber && number<=temp1){
109       fileName=baseFile;
110       exceptionNumber=jdbcNumber-(temp1-number)+3;
111     }else{
112       for(int i=0;i<fileLineNumber.size();i=i+2){
113         if(number>temp1 && number<temp1+Integer.parseInt(fileLineNumber.get(i).toString())){
114           fileName=fileLineNumber.get(i+1).toString();
115           exceptionNumber=Integer.parseInt(fileLineNumber.get(i).toString())-
116                           ((temp1+Integer.parseInt(fileLineNumber.get(i).toString()))-number);
117           break;
118         }else{
119           temp1+=Integer.parseInt(fileLineNumber.get(i).toString());
120         }
121       }
122     }
123     return exceptionNumber-1;
124   }
125
126   /**
127    * This method read value of fileName parameter
128    * @return value of parameter
129    */

130   public static String JavaDoc getFileName(){
131     return fileName;
132   }
133 }
Popular Tags