// Path: bst/src/main/java/ru/redsolution/bst/data/table/DatabaseHelper.java
// public class DatabaseHelper extends SQLiteOpenHelper {
// 
// 	private static final String DATABASE_NAME = "sqlite-q.db";
// 	private static final int DATABASE_VERSION = 7;
// 
// 	private static final DatabaseHelper instance;
// 
// 	static {
// 		instance = new DatabaseHelper(BST.getInstance());
// 	}
// 
// 	public static DatabaseHelper getInstance() {
// 		return instance;
// 	}
// 
// 	private final ArrayList<DatabaseTable> tables;
// 
// 	private DatabaseHelper(Context context) {
// 		super(context, DATABASE_NAME, null, DATABASE_VERSION);
// 		tables = new ArrayList<DatabaseTable>();
// 	}
// 
// 	public void addTable(DatabaseTable table) {
// 		tables.add(table);
// 	}
// 
// 	@Override
// 	public void onCreate(SQLiteDatabase paramSQLiteDatabase) {
// 		for (DatabaseTable table : tables)
// 			table.create(paramSQLiteDatabase);
// 	}
// 
// 	@Override
// 	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// 		if (oldVersion > newVersion) {
// 			throw new IllegalStateException();
// 		} else {
// 			while (oldVersion < newVersion) {
// 				oldVersion += 1;
// 				for (DatabaseTable table : tables)
// 					table.migrate(db, oldVersion);
// 			}
// 		}
// 	}
// 
// 	/**
// 	 * Удалить все данные.
// 	 */
// 	public void clear() {
// 		for (DatabaseTable table : tables)
// 			table.clear();
// 	}
// 
// 	public static void execSQL(SQLiteDatabase db, String sql) {
// 		if (Debugger.ENABLED)
// 			Log.i("SQL", sql);
// 		db.execSQL(sql);
// 	}
// 
// }


import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import ru.redsolution.bst.data.table.DatabaseHelper;
import android.database.sqlite.SQLiteDatabase;
/**
 * Copyright (c) 2013, Redsolution LTD. All rights reserved.
 *
 * This file is part of Barcode Scanner Terminal project;
 * you can redistribute it and/or modify it under the terms of
 *
 * Barcode Scanner Terminal is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License,
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */
package ru.redsolution.bst.data.parse;




/**
 * Реализует базовый парсинг данных.
 * 
 * @author alexander.ivanov
 * 
 */
public abstract class BaseImporter implements Importer {

	/**
	 * Парсинг вложенного элемента.
	 * 
	 * @param parser
	 * @return Истину, если элемент был обработан.
	 * @throws XmlPullParserException
	 * @throws IOException
	 */
	protected boolean parseInnerElement(XmlPullParser parser)
			throws XmlPullParserException, IOException {
		return false;
	}

	/**
	 * Подготовка к парсингу вложенных элементов.
	 * 
	 * @param parser
	 */
	protected void preProcess(XmlPullParser parser) {
	}

	/**
	 * Разбор вложенных тегов.
	 * 
	 * @param parser
	 * @throws XmlPullParserException
	 * @throws IOException
	 */
	protected void parseInner(XmlPullParser parser)
			throws XmlPullParserException, IOException {
		int inner = 1;
		while (inner > 0) {
			int eventType = parser.next();
			if (eventType == XmlPullParser.START_TAG) {
				if (inner == 1)
					if (parseInnerElement(parser))
						continue;
				inner += 1;
			} else if (eventType == XmlPullParser.END_TAG) {
				inner -= 1;
			} else if (eventType == XmlPullParser.END_DOCUMENT)
				break;
		}
	}

	@Override
	public void parse(XmlPullParser parser) throws XmlPullParserException,
			IOException {
// Path: bst/src/main/java/ru/redsolution/bst/data/table/DatabaseHelper.java
// public class DatabaseHelper extends SQLiteOpenHelper {
// 
// 	private static final String DATABASE_NAME = "sqlite-q.db";
// 	private static final int DATABASE_VERSION = 7;
// 
// 	private static final DatabaseHelper instance;
// 
// 	static {
// 		instance = new DatabaseHelper(BST.getInstance());
// 	}
// 
// 	public static DatabaseHelper getInstance() {
// 		return instance;
// 	}
// 
// 	private final ArrayList<DatabaseTable> tables;
// 
// 	private DatabaseHelper(Context context) {
// 		super(context, DATABASE_NAME, null, DATABASE_VERSION);
// 		tables = new ArrayList<DatabaseTable>();
// 	}
// 
// 	public void addTable(DatabaseTable table) {
// 		tables.add(table);
// 	}
// 
// 	@Override
// 	public void onCreate(SQLiteDatabase paramSQLiteDatabase) {
// 		for (DatabaseTable table : tables)
// 			table.create(paramSQLiteDatabase);
// 	}
// 
// 	@Override
// 	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// 		if (oldVersion > newVersion) {
// 			throw new IllegalStateException();
// 		} else {
// 			while (oldVersion < newVersion) {
// 				oldVersion += 1;
// 				for (DatabaseTable table : tables)
// 					table.migrate(db, oldVersion);
// 			}
// 		}
// 	}
// 
// 	/**
// 	 * Удалить все данные.
// 	 */
// 	public void clear() {
// 		for (DatabaseTable table : tables)
// 			table.clear();
// 	}
// 
// 	public static void execSQL(SQLiteDatabase db, String sql) {
// 		if (Debugger.ENABLED)
// 			Log.i("SQL", sql);
// 		db.execSQL(sql);
// 	}
// 
// }


// Path: bst/src/main/java/ru/redsolution/bst/data/parse/BaseImporter.java
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import ru.redsolution.bst.data.table.DatabaseHelper;
import android.database.sqlite.SQLiteDatabase;

/**
 * Copyright (c) 2013, Redsolution LTD. All rights reserved.
 *
 * This file is part of Barcode Scanner Terminal project;
 * you can redistribute it and/or modify it under the terms of
 *
 * Barcode Scanner Terminal is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License,
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */
package ru.redsolution.bst.data.parse;




/**
 * Реализует базовый парсинг данных.
 * 
 * @author alexander.ivanov
 * 
 */
public abstract class BaseImporter implements Importer {

	/**
	 * Парсинг вложенного элемента.
	 * 
	 * @param parser
	 * @return Истину, если элемент был обработан.
	 * @throws XmlPullParserException
	 * @throws IOException
	 */
	protected boolean parseInnerElement(XmlPullParser parser)
			throws XmlPullParserException, IOException {
		return false;
	}

	/**
	 * Подготовка к парсингу вложенных элементов.
	 * 
	 * @param parser
	 */
	protected void preProcess(XmlPullParser parser) {
	}

	/**
	 * Разбор вложенных тегов.
	 * 
	 * @param parser
	 * @throws XmlPullParserException
	 * @throws IOException
	 */
	protected void parseInner(XmlPullParser parser)
			throws XmlPullParserException, IOException {
		int inner = 1;
		while (inner > 0) {
			int eventType = parser.next();
			if (eventType == XmlPullParser.START_TAG) {
				if (inner == 1)
					if (parseInnerElement(parser))
						continue;
				inner += 1;
			} else if (eventType == XmlPullParser.END_TAG) {
				inner -= 1;
			} else if (eventType == XmlPullParser.END_DOCUMENT)
				break;
		}
	}

	@Override
	public void parse(XmlPullParser parser) throws XmlPullParserException,
			IOException {
		SQLiteDatabase db = DatabaseHelper.getInstance().getWritableDatabase();