001: /*
002:
003: Loader - tool for transfering data from one JDBC source to another and
004: doing transformations during copy.
005:
006: Copyright (C) 2002-2003 Together
007:
008: This library is free software; you can redistribute it and/or
009: modify it under the terms of the GNU Lesser General Public
010: License as published by the Free Software Foundation; either
011: version 2.1 of the License, or (at your option) any later version.
012:
013: This library is distributed in the hope that it will be useful,
014: but WITHOUT ANY WARRANTY; without even the implied warranty of
015: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: Lesser General Public License for more details.
017:
018: You should have received a copy of the GNU Lesser General Public
019: License along with this library; if not, write to the Free Software
020: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021:
022: Loader.java
023: Date: 03.03.2003.
024: @version 2.1 alpha
025: @author:
026: Radoslav Dutina rale@prozone.co.yu
027:
028: */
029:
030: package org.webdocwf.util.loader;
031:
032: import java.io.*;
033: import java.sql.*;
034: import java.util.*;
035:
036: /**
037: *
038: * LocationOfException class provide exact line where exception are happened
039: * @author Radoslav Dutina
040: * @version 1.0
041: */
042: public class LocationOfException {
043:
044: private static int introNumber = 0;
045: private static int dtdNumber = 0;
046: private static int jdbcNumber = 0;
047: private static Vector fileLineNumber = new Vector();
048: private static String fileName = "";
049: private static int exceptionNumber = 0;
050: private static String baseFile = "";
051: private static int createDropNumber = 0;
052:
053: /**
054: * This constructor set value of base xml file
055: * @param baseFileName is name of base xml file
056: */
057: public LocationOfException(String baseFileName) {
058: baseFile = baseFileName;
059: }
060:
061: /**
062: * This method set value of introNumber parameter
063: * @param lineNumber is value of parmeter
064: */
065: public static void setIntroNumber(int lineNumber) {
066: introNumber = lineNumber;
067: }
068:
069: /**
070: * This method set value of dtdNumber parameter
071: * @param lineNumber is value of parameter
072: */
073: public static void setDtdNumber(int lineNumber) {
074: dtdNumber = lineNumber;
075: }
076:
077: /**
078: * This method set value of jdbcNumber parameter
079: * @param lineNumber is value of parameter
080: */
081: public static void setJdbcNumber(int lineNumber) {
082: jdbcNumber = lineNumber;
083: }
084:
085: /**
086: * This method set value of fileLineNumber parameter
087: * @param lineNumber is secunde value of pratemeter
088: * @param fileName is first value of parameter
089: */
090: public static void setFileLineNumber(int lineNumber, String fileName) {
091: fileLineNumber.add(String.valueOf(lineNumber));
092: fileLineNumber.add(fileName);
093: }
094:
095: /**
096: * This method read value of exceptionNumber parameter
097: * @param number is line number of exception
098: * @return value of parameter
099: */
100: public static int getLineNumber(int number) {
101: int temp1 = introNumber + dtdNumber + jdbcNumber;
102: if (number < introNumber) {
103: fileName = baseFile;
104: } else if (number > introNumber
105: && number <= introNumber + dtdNumber) {
106: fileName = "Dtd file which match " + baseFile;
107: } else if (number > introNumber + dtdNumber && number <= temp1) {
108: fileName = baseFile;
109: exceptionNumber = jdbcNumber - (temp1 - number) + 3;
110: } else {
111: for (int i = 0; i < fileLineNumber.size(); i = i + 2) {
112: if (number > temp1
113: && number < temp1
114: + Integer.parseInt(fileLineNumber
115: .get(i).toString())) {
116: fileName = fileLineNumber.get(i + 1).toString();
117: exceptionNumber = Integer.parseInt(fileLineNumber
118: .get(i).toString())
119: - ((temp1 + Integer.parseInt(fileLineNumber
120: .get(i).toString())) - number);
121: break;
122: } else {
123: temp1 += Integer.parseInt(fileLineNumber.get(i)
124: .toString());
125: }
126: }
127: }
128: return exceptionNumber - 1;
129: }
130:
131: /**
132: * This method read value of fileName parameter
133: * @return value of parameter
134: */
135: public static String getFileName() {
136: return fileName;
137: }
138: }
|