package com.color.actionbar.app;

import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.app.ActionBar;
import android.app.Activity;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
import com.android.internal.R;
import com.color.animation.ColorAnimatorWrapper;
import com.color.widget.ColorActionModeCallback;
import com.color.widget.ColorBottomMenuCallback;
import com.color.widget.ColorPagerCallback;
import com.color.widget.ColorSpinnerCallback;
import com.color.widget.ColorSpinnerCallback.DropdownDismissCallback;
import java.util.List;

public class ColorActionBarUtil {

    private static final boolean DBG = false;

    private static final String TAG = "ColorActionBarUtil";

    static final String THEME_CUSTOM_ACTIONBAR = "oppo:Theme.OPPO.CustomActionBar";

    public interface ScrollTabCallback extends ColorPagerCallback {

        void updateTabScrollPosition(int i, float f, int i2);

        void updateTabScrollState(int i);
    }

    public interface ActionBarCallback extends ScrollTabCallback, ColorBottomMenuCallback, ColorSpinnerCallback {

        void addAfterAnimator(Animator animator);

        void addAfterAnimatorWrapper(ColorAnimatorWrapper colorAnimatorWrapper);

        void addAfterAnimatorWrappers(List<ColorAnimatorWrapper> list);

        void addAfterAnimators(List<Animator> list);

        void addBeforeAnimator(Animator animator);

        void addBeforeAnimatorWrapper(ColorAnimatorWrapper colorAnimatorWrapper);

        void addBeforeAnimatorWrappers(List<ColorAnimatorWrapper> list);

        void addBeforeAnimators(List<Animator> list);

        void addHideListener(AnimatorListener animatorListener);

        void addSearchViewHideListener(AnimatorListener animatorListener);

        void addSearchViewShowListener(AnimatorListener animatorListener);

        void addSearchViewWithAnimator(Animator animator);

        void addShowListener(AnimatorListener animatorListener);

        void addWithAnimator(Animator animator);

        void addWithAnimatorWrapper(ColorAnimatorWrapper colorAnimatorWrapper);

        void addWithAnimatorWrappers(List<ColorAnimatorWrapper> list);

        void addWithAnimators(List<Animator> list);

        void cancelShowHide();

        int getContentId();

        int getHomeId();

        boolean hasEmbeddedTabs();

        void setActionBarSubTitle(int i);

        void setActionBarSubTitle(CharSequence charSequence);

        void setActionMenuTextColor(ColorStateList colorStateList);

        void setActionModeAnim(boolean z);

        void setActionModeCallback(ColorActionModeCallback colorActionModeCallback);

        void setBackTitle(int i);

        void setBackTitle(CharSequence charSequence);

        void setBackTitleTextColor(ColorStateList colorStateList);

        void setColorBottomWindowContentOverlay(Drawable drawable);

        void setColorWindowContentOverlay(Drawable drawable);

        void setEmbeddedTabs(boolean z);

        void setHintText(int i);

        void setHintText(CharSequence charSequence);

        void setIgnoreColorBottomWindowContentOverlay(boolean z);

        void setIgnoreColorWindowContentOverlay(boolean z);

        void setMainActionBar(boolean z);

        void setSearchBarMode(boolean z);

        void setSplitActionBarBg(Drawable drawable);

        void setSplitActionBarOverlay(boolean z);

        void setSplitActionBarTextColor(ColorStateList colorStateList);

        void setSplitHideWithActionBar(boolean z);

        void setStatusBarActionBarBg(Drawable drawable);

        void setSubtitleTextColor(int i);

        void setTitleTextColor(int i);
    }

    public interface DelegateCallback {

        boolean hasWindowFeature(int i);

        void superSetContentView(int i);

        void superSetContentView(View view);

        boolean supportRequestWindowFeature(int i);
    }

    public interface ActivityCallback extends DelegateCallback {

        void setSupportProgress(int i);

        void setSupportProgressBarIndeterminate(boolean z);

        void setSupportProgressBarIndeterminateVisibility(boolean z);

        void setSupportProgressBarVisibility(boolean z);

        void setSupportSecondaryProgress(int i);
    }

    public interface DialogCallback extends DelegateCallback {
    }

    public static int getContentId(ActionBar actionBar) {
        if (actionBar instanceof ActionBarCallback) {
            return ((ActionBarCallback) actionBar).getContentId();
        }
        return 16908290;
    }

    public static int getHomeId(ActionBar actionBar) {
        if (actionBar instanceof ActionBarCallback) {
            return ((ActionBarCallback) actionBar).getHomeId();
        }
        return R.id.home;
    }

    public static int getBottomMenuViewId() {
        return 201458882;
    }

    public static void updateTabScrollPosition(ActionBar actionBar, int position, float positionOffset, int positionOffsetPixels) {
        if (actionBar instanceof ScrollTabCallback) {
            ((ScrollTabCallback) actionBar).updateTabScrollPosition(position, positionOffset, positionOffsetPixels);
        }
    }

    public static void updateTabScrollState(ActionBar actionBar, int state) {
        if (actionBar instanceof ScrollTabCallback) {
            ((ScrollTabCallback) actionBar).updateTabScrollState(state);
        }
    }

    public static void updateMenuScrollPosition(ActionBar actionBar, int index, float offset) {
        if (actionBar instanceof ColorBottomMenuCallback) {
            ((ColorBottomMenuCallback) actionBar).updateMenuScrollPosition(index, offset);
        }
    }

    public static void updateMenuScrollState(ActionBar actionBar, int state) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).updateMenuScrollState(state);
        }
    }

    public static void updateMenuScrollData(ActionBar actionBar) {
        if (actionBar instanceof ColorBottomMenuCallback) {
            ((ColorBottomMenuCallback) actionBar).updateMenuScrollData();
        }
    }

    public static void setMenuUpdateMode(ActionBar actionBar, int mode) {
        if (actionBar instanceof ColorBottomMenuCallback) {
            ((ColorBottomMenuCallback) actionBar).setMenuUpdateMode(mode);
        }
    }

    public static void lockMenuUpdate(ActionBar actionBar) {
        if (actionBar instanceof ColorBottomMenuCallback) {
            ((ColorBottomMenuCallback) actionBar).lockMenuUpdate();
        }
    }

    public static void unlockMenuUpdate(ActionBar actionBar) {
        if (actionBar instanceof ColorBottomMenuCallback) {
            ((ColorBottomMenuCallback) actionBar).unlockMenuUpdate();
        }
    }

    public static void setDropdownDismissCallback(ActionBar actionBar, DropdownDismissCallback callback) {
        if (actionBar instanceof ColorSpinnerCallback) {
            ((ColorSpinnerCallback) actionBar).setDropdownDismissCallback(callback);
        }
    }

    public static void setDropdownItemClickListener(ActionBar actionBar, OnItemClickListener listener) {
        if (actionBar instanceof ColorSpinnerCallback) {
            ((ColorSpinnerCallback) actionBar).setDropdownItemClickListener(listener);
        }
    }

    public static void setDropdownUpdateAfterAnim(ActionBar actionBar, boolean update) {
        if (actionBar instanceof ColorSpinnerCallback) {
            ((ColorSpinnerCallback) actionBar).setDropdownUpdateAfterAnim(update);
        }
    }

    public static void setHasEmbeddedTabs(ActionBar actionBar, boolean hasEmbeddedTabs) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setEmbeddedTabs(hasEmbeddedTabs);
        }
    }

    public static void setSplitActionBarOverlay(ActionBar actionBar, boolean overlay) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setSplitActionBarOverlay(overlay);
        }
    }

    public static void setSplitHideWithActionBar(ActionBar actionBar, boolean hideWith) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setSplitHideWithActionBar(hideWith);
        }
    }

    public static boolean hasEmbeddedTabs(ActionBar actionBar) {
        if (actionBar instanceof ActionBarCallback) {
            return ((ActionBarCallback) actionBar).hasEmbeddedTabs();
        }
        return false;
    }

    public static void setColorWindowContentOverlay(ActionBar actionBar, Drawable overlay) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setColorWindowContentOverlay(overlay);
        }
    }

    public static void setColorBottomWindowContentOverlay(ActionBar actionBar, Drawable bottomOverlay) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setColorBottomWindowContentOverlay(bottomOverlay);
        }
    }

    public static void setIgnoreColorWindowContentOverlay(ActionBar actionBar, boolean isIgnore) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setIgnoreColorWindowContentOverlay(isIgnore);
        }
    }

    public static void setIgnoreColorBottomWindowContentOverlay(ActionBar actionBar, boolean isIgnore) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setIgnoreColorBottomWindowContentOverlay(isIgnore);
        }
    }

    public static void setStatusBarActionBarBg(ActionBar actionBar, Drawable bg) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setStatusBarActionBarBg(bg);
        }
    }

    public static void setSplitActionBarBg(ActionBar actionBar, Drawable bg) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setSplitActionBarBg(bg);
        }
    }

    public static void setSplitActionBarTextColor(ActionBar actionBar, ColorStateList textColor) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setSplitActionBarTextColor(textColor);
        }
    }

    public static void setBackTitleTextColor(ActionBar actionBar, ColorStateList textColor) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setBackTitleTextColor(textColor);
        }
    }

    public static void setTitleTextColor(ActionBar actionBar, int textColor) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setTitleTextColor(textColor);
        }
    }

    public static void setSubtitleTextColor(ActionBar actionBar, int textColor) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setSubtitleTextColor(textColor);
        }
    }

    public static void setActionMenuTextColor(ActionBar actionBar, ColorStateList textColor) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setActionMenuTextColor(textColor);
        }
    }

    public static boolean requestWindowFeature(Activity activity, int featureId) {
        if (activity instanceof ActivityCallback) {
            return ((ActivityCallback) activity).supportRequestWindowFeature(featureId);
        }
        return activity.requestWindowFeature(featureId);
    }

    public static void setProgressBarVisibility(Activity activity, boolean visible) {
        if (activity instanceof ActivityCallback) {
            ((ActivityCallback) activity).setSupportProgressBarVisibility(visible);
        } else {
            activity.setProgressBarVisibility(visible);
        }
    }

    public static void setProgressBarIndeterminateVisibility(Activity activity, boolean visible) {
        if (activity instanceof ActivityCallback) {
            ((ActivityCallback) activity).setSupportProgressBarIndeterminateVisibility(visible);
        } else {
            activity.setProgressBarIndeterminateVisibility(visible);
        }
    }

    public static void setProgressBarIndeterminate(Activity activity, boolean indeterminate) {
        if (activity instanceof ActivityCallback) {
            ((ActivityCallback) activity).setSupportProgressBarIndeterminate(indeterminate);
        } else {
            activity.setProgressBarIndeterminate(indeterminate);
        }
    }

    public static void setProgress(Activity activity, int progress) {
        if (activity instanceof ActivityCallback) {
            ((ActivityCallback) activity).setSupportProgress(progress);
        } else {
            activity.setProgress(progress);
        }
    }

    public static void setSecondaryProgress(Activity activity, int progress) {
        if (activity instanceof ActivityCallback) {
            ((ActivityCallback) activity).setSupportSecondaryProgress(progress);
        } else {
            activity.setSecondaryProgress(progress);
        }
    }

    public static void setBackTitle(ActionBar actionBar, CharSequence title) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setBackTitle(title);
        }
    }

    public static void setBackTitle(ActionBar actionBar, int resId) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setBackTitle(resId);
        }
    }

    public static void setHintText(ActionBar actionBar, CharSequence hintText) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setHintText(hintText);
        }
    }

    public static void setHintText(ActionBar actionBar, int resId) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setHintText(resId);
        }
    }

    public static void setActionBarSubTitle(ActionBar actionBar, CharSequence subtitle) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setActionBarSubTitle(subtitle);
        }
    }

    public static void setActionBarSubTitle(ActionBar actionBar, int resId) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setActionBarSubTitle(resId);
        }
    }

    public static void setMainActionBar(ActionBar actionBar, boolean isMain) {
        if (actionBar instanceof ActionBarCallback) {
            ((ActionBarCallback) actionBar).setMainActionBar(isMain);


public static TQuotAuthor get(Connect connect, String _name, String _wikilink)

/* TQuotAuthor.java - author of quotation,
 * SQL operations with the table 'quot_author' in Wiktionary parsed database.
 *
 */
package wikokit.base.wikt.sql.quote;

import wikokit.base.wikipedia.sql.Connect;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import wikokit.base.wikipedia.language.Encodings;
import wikokit.base.wikipedia.sql.PageTableBase;

/**
 * Author of quotation and
 * operations with the table 'quot_author' in MySQL Wiktionary parsed database.
 *
 * Remark: quot_author table has UNIQUE compound KEY (name, wikilink),
 * and wikilink field could be NULL.
 */
public class TQuotAuthor {

    /**
     * Inique identifier of the author.
     */
    private int id;

    /**
     * Author's name of the quote.
     */
    private String name;

    /**
     * A wikilink to author's name in Wikipedia (format: [[w:name|]]),
     * it could not be NULL, though it can be empty ("").
     */
    private String wikilink;

    private final static TQuotAuthor[] NULL_TQUOTAUTHOR_ARRAY = new TQuotAuthor[0];

    public TQuotAuthor(int _id, String _name, String _wikilink) {
        id = _id;
        name = _name;
        wikilink = _wikilink;
    }

    public TQuotAuthor(int _id, String _name) {
        id = _id;
        name = _name;
        wikilink = "";
    }

    /**
     * Gets unique ID from database
     */
    public int getID() {
        return id;
    }

    /**
     * Gets author's name from database.
     */
    public String getName() {
        return name;
    }

    /**
     * Gets wikilink to Wikipedia (format: [[w:name|]]) for the author.
     */
    public String getWikilink() {
        return wikilink;
    }

    /**
     * Inserts record into the table 'quot_author'.

     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   _wikilink can be empty or NULL
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertName(Connect connect, String _name) {
        return insertNameWikilink(connect, _name, "");
    }

    /**
     * Inserts record into the table 'quot_author'.

     * INSERT INTO quot_author (name,wikilink) VALUES ("Isaac Asimov", "Isaac Asimov");
     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   it could be empty ("")
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertNameWikilink(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor.insertNameAndWikilink()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("INSERT INTO quot_author (name,wikilink) VALUES (\"");
        str_sql.append(safe_name);
        str_sql.append("\", \"");
        str_sql.append(safe_wikilink);
        str_sql.append("\")");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                s.executeUpdate(str_sql.toString());
                s = connect.conn.createStatement();
                ResultSet rs = s.executeQuery("SELECT LAST_INSERT_ID() as id");
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.insertName):: _name='" + _name + "'; _wikilink='" + _wikilink + "'; sql='" + str_sql.toString() + "' error=" + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's first record from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" LIMIT 1;
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor getFirst(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        result = new TQuotAuthor(_id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's array of records from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov";
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor[] get(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\";");
        List<TQuotAuthor> list_authors = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    while (rs.next()) {
                        if (null == list_authors)
                            list_authors = new ArrayList<TQuotAuthor>();
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        list_authors.add(new TQuotAuthor(_id, _name, _wikilink));
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        if (null == list_authors)
            return NULL_TQUOTAUTHOR_ARRAY;
        return (TQuotAuthor[]) list_authors.toArray(NULL_TQUOTAUTHOR_ARRAY);
    }

    /**
     * Get's first suitable row from the table 'quot_author' by the author's name and wikilink.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" AND wikilink="" LIMIT 1;
     *
     * @param _name author's name
     * @param _wikilink author's name, it could be NULL or empty ("")
     *
     * @return NULL if data is absent
     */

{
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("SELECT id FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" AND wikilink=\"");
        str_sql.append(safe_wikilink);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Gets ID of a record or inserts record (if it is absent)
     * into the table 'quot_author'.
     *
     * @param _author author's name
     * @param _author_wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                          it could be empty ("")
     */
    public static TQuotAuthor getOrInsert(Connect connect, String _author, String _author_wikilink) {
        if (null == _author || 0 == _author.length())
            return null;
        TQuotAuthor a = TQuotAuthor.getFirst(connect, _author);
        if (null == a)
            a = TQuotAuthor.insertNameWikilink(connect, _author, _author_wikilink);
        return a;
    }

    /**
     * Selects row from the table 'quot_author' by ID.

     *
     * SELECT name,wikilink FROM quot_author WHERE id=1
     *
     * @return null if data is absent
     */
    public static TQuotAuthor getByID(Connect connect, int id) {
        StringBuilder str_sql = new StringBuilder();
        str_sql.append("SELECT name,wikilink FROM quot_author WHERE id=");
        str_sql.append(id);
        TQuotAuthor quot_author = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        byte[] bb = rs.getBytes("name");
                        String _name = null == bb ? null : Encodings.bytesToUTF8(bb);
                        bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? null : Encodings.bytesToUTF8(bb);
                        quot_author = new TQuotAuthor(id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.getByID()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return quot_author;
    }

    /**
     * Deletes row from the table 'quot_author' by a value of ID.

     * DELETE FROM quot_author WHERE id=4;
     */
    public void delete(Connect connect) {
        StringBuilder str_sql = new StringBuilder();
        str_sql.append("DELETE FROM quot_author WHERE id=");
        str_sql.append(id);
        try {
            Statement s = connect.conn.createStatement();
            try {
                s.execute(str_sql.toString());
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.delete()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
    }
}


{
        if (null == _author || 0 == _author.length())
            return null;
        TQuotAuthor a = TQuotAuthor.getFirst(connect, _author);
        if (null == a)
            a = TQuotAuthor.insertNameWikilink(connect, _author, _author_wikilink);
        return a;
    }

/* TQuotAuthor.java - author of quotation,
 * SQL operations with the table 'quot_author' in Wiktionary parsed database.
 *
 */
package wikokit.base.wikt.sql.quote;

import wikokit.base.wikipedia.sql.Connect;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import wikokit.base.wikipedia.language.Encodings;
import wikokit.base.wikipedia.sql.PageTableBase;

/**
 * Author of quotation and
 * operations with the table 'quot_author' in MySQL Wiktionary parsed database.
 *
 * Remark: quot_author table has UNIQUE compound KEY (name, wikilink),
 * and wikilink field could be NULL.
 */
public class TQuotAuthor {

    /**
     * Inique identifier of the author.
     */
    private int id;

    /**
     * Author's name of the quote.
     */
    private String name;

    /**
     * A wikilink to author's name in Wikipedia (format: [[w:name|]]),
     * it could not be NULL, though it can be empty ("").
     */
    private String wikilink;

    private final static TQuotAuthor[] NULL_TQUOTAUTHOR_ARRAY = new TQuotAuthor[0];

    public TQuotAuthor(int _id, String _name, String _wikilink) {
        id = _id;
        name = _name;
        wikilink = _wikilink;
    }

    public TQuotAuthor(int _id, String _name) {
        id = _id;
        name = _name;
        wikilink = "";
    }

    /**
     * Gets unique ID from database
     */
    public int getID() {
        return id;
    }

    /**
     * Gets author's name from database.
     */
    public String getName() {
        return name;
    }

    /**
     * Gets wikilink to Wikipedia (format: [[w:name|]]) for the author.
     */
    public String getWikilink() {
        return wikilink;
    }

    /**
     * Inserts record into the table 'quot_author'.

     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   _wikilink can be empty or NULL
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertName(Connect connect, String _name) {
        return insertNameWikilink(connect, _name, "");
    }

    /**
     * Inserts record into the table 'quot_author'.

     * INSERT INTO quot_author (name,wikilink) VALUES ("Isaac Asimov", "Isaac Asimov");
     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   it could be empty ("")
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertNameWikilink(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor.insertNameAndWikilink()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("INSERT INTO quot_author (name,wikilink) VALUES (\"");
        str_sql.append(safe_name);
        str_sql.append("\", \"");
        str_sql.append(safe_wikilink);
        str_sql.append("\")");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                s.executeUpdate(str_sql.toString());
                s = connect.conn.createStatement();
                ResultSet rs = s.executeQuery("SELECT LAST_INSERT_ID() as id");
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.insertName):: _name='" + _name + "'; _wikilink='" + _wikilink + "'; sql='" + str_sql.toString() + "' error=" + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's first record from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" LIMIT 1;
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor getFirst(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        result = new TQuotAuthor(_id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's array of records from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov";
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor[] get(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\";");
        List<TQuotAuthor> list_authors = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    while (rs.next()) {
                        if (null == list_authors)
                            list_authors = new ArrayList<TQuotAuthor>();
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        list_authors.add(new TQuotAuthor(_id, _name, _wikilink));
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        if (null == list_authors)
            return NULL_TQUOTAUTHOR_ARRAY;
        return (TQuotAuthor[]) list_authors.toArray(NULL_TQUOTAUTHOR_ARRAY);
    }

    /**
     * Get's first suitable row from the table 'quot_author' by the author's name and wikilink.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" AND wikilink="" LIMIT 1;
     *
     * @param _name author's name
     * @param _wikilink author's name, it could be NULL or empty ("")
     *
     * @return NULL if data is absent
     */
    public static TQuotAuthor get(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("SELECT id FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" AND wikilink=\"");
        str_sql.append(safe_wikilink);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Gets ID of a record or inserts record (if it is absent)
     * into the table 'quot_author'.
     *
     * @param _author author's name
     * @param _author_wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                          it could be empty ("")
     */
    public static TQuotAuthor getOrInsert(Connect connect, String _author, String _author_wikilink)

/**
     * Selects row from the table 'quot_author' by ID.

     *
     * SELECT name,wikilink FROM quot_author WHERE id=1
     *
     * @return null if data is absent
     */
    public static TQuotAuthor getByID(Connect connect, int id) {
        StringBuilder str_sql = new StringBuilder();
        str_sql.append("SELECT name,wikilink FROM quot_author WHERE id=");
        str_sql.append(id);
        TQuotAuthor quot_author = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        byte[] bb = rs.getBytes("name");
                        String _name = null == bb ? null : Encodings.bytesToUTF8(bb);
                        bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? null : Encodings.bytesToUTF8(bb);
                        quot_author = new TQuotAuthor(id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.getByID()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return quot_author;
    }

    /**
     * Deletes row from the table 'quot_author' by a value of ID.

     * DELETE FROM quot_author WHERE id=4;
     */
    public void delete(Connect connect) {
        StringBuilder str_sql = new StringBuilder();
        str_sql.append("DELETE FROM quot_author WHERE id=");
        str_sql.append(id);
        try {
            Statement s = connect.conn.createStatement();
            try {
                s.execute(str_sql.toString());
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.delete()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
    }
}


/* TQuotAuthor.java - author of quotation,
 * SQL operations with the table 'quot_author' in Wiktionary parsed database.
 *
 */
package wikokit.base.wikt.sql.quote;

import wikokit.base.wikipedia.sql.Connect;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import wikokit.base.wikipedia.language.Encodings;
import wikokit.base.wikipedia.sql.PageTableBase;

/**
 * Author of quotation and
 * operations with the table 'quot_author' in MySQL Wiktionary parsed database.
 *
 * Remark: quot_author table has UNIQUE compound KEY (name, wikilink),
 * and wikilink field could be NULL.
 */
public class TQuotAuthor {

    /**
     * Inique identifier of the author.
     */
    private int id;

    /**
     * Author's name of the quote.
     */
    private String name;

    /**
     * A wikilink to author's name in Wikipedia (format: [[w:name|]]),
     * it could not be NULL, though it can be empty ("").
     */
    private String wikilink;

    private final static TQuotAuthor[] NULL_TQUOTAUTHOR_ARRAY = new TQuotAuthor[0];

    public TQuotAuthor(int _id, String _name, String _wikilink) {
        id = _id;
        name = _name;
        wikilink = _wikilink;
    }

    public TQuotAuthor(int _id, String _name) {
        id = _id;
        name = _name;
        wikilink = "";
    }

    /**
     * Gets unique ID from database
     */
    public int getID() {
        return id;
    }

    /**
     * Gets author's name from database.
     */
    public String getName() {
        return name;
    }

    /**
     * Gets wikilink to Wikipedia (format: [[w:name|]]) for the author.
     */
    public String getWikilink() {
        return wikilink;
    }

    /**
     * Inserts record into the table 'quot_author'.

     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   _wikilink can be empty or NULL
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertName(Connect connect, String _name) {
        return insertNameWikilink(connect, _name, "");
    }

    /**
     * Inserts record into the table 'quot_author'.

     * INSERT INTO quot_author (name,wikilink) VALUES ("Isaac Asimov", "Isaac Asimov");
     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   it could be empty ("")
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertNameWikilink(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor.insertNameAndWikilink()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("INSERT INTO quot_author (name,wikilink) VALUES (\"");
        str_sql.append(safe_name);
        str_sql.append("\", \"");
        str_sql.append(safe_wikilink);
        str_sql.append("\")");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                s.executeUpdate(str_sql.toString());
                s = connect.conn.createStatement();
                ResultSet rs = s.executeQuery("SELECT LAST_INSERT_ID() as id");
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.insertName):: _name='" + _name + "'; _wikilink='" + _wikilink + "'; sql='" + str_sql.toString() + "' error=" + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's first record from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" LIMIT 1;
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor getFirst(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        result = new TQuotAuthor(_id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's array of records from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov";
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor[] get(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\";");
        List<TQuotAuthor> list_authors = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    while (rs.next()) {
                        if (null == list_authors)
                            list_authors = new ArrayList<TQuotAuthor>();
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        list_authors.add(new TQuotAuthor(_id, _name, _wikilink));
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        if (null == list_authors)
            return NULL_TQUOTAUTHOR_ARRAY;
        return (TQuotAuthor[]) list_authors.toArray(NULL_TQUOTAUTHOR_ARRAY);
    }

    /**
     * Get's first suitable row from the table 'quot_author' by the author's name and wikilink.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" AND wikilink="" LIMIT 1;
     *
     * @param _name author's name
     * @param _wikilink author's name, it could be NULL or empty ("")
     *
     * @return NULL if data is absent
     */
    public static TQuotAuthor get(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("SELECT id FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" AND wikilink=\"");
        str_sql.append(safe_wikilink);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Gets ID of a record or inserts record (if it is absent)
     * into the table 'quot_author'.
     *
     * @param _author author's name
     * @param _author_wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                          it could be empty ("")
     */
    public static TQuotAuthor getOrInsert(Connect connect, String _author, String _author_wikilink) {
        if (null == _author || 0 == _author.length())
            return null;
        TQuotAuthor a = TQuotAuthor.getFirst(connect, _author);
        if (null == a)
            a = TQuotAuthor.insertNameWikilink(connect, _author, _author_wikilink);
        return a;
    }

    /**
     * Selects row from the table 'quot_author' by ID.

     *
     * SELECT name,wikilink FROM quot_author WHERE id=1
     *
     * @return null if data is absent
     */
    public static TQuotAuthor getByID(Connect connect, int id) {
        StringBuilder str_sql = new StringBuilder();
        str_sql.append("SELECT name,wikilink FROM quot_author WHERE id=");
        str_sql.append(id);
        TQuotAuthor quot_author = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        byte[] bb = rs.getBytes("name");
                        String _name = null == bb ? null : Encodings.bytesToUTF8(bb);
                        bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? null : Encodings.bytesToUTF8(bb);
                        quot_author = new TQuotAuthor(id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.getByID()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return quot_author;
    }

    /**
     * Deletes row from the table 'quot_author' by a value of ID.

     * DELETE FROM quot_author WHERE id=4;
     */
    public void delete(Connect connect) {

        str_sql.append("DELETE FROM quot_author WHERE id=");
        str_sql.append(id);
        try {
            Statement s = connect.conn.createStatement();
            try {
                s.execute(str_sql.toString());
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.delete()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
    }
}


str_sql.append("DELETE FROM quot_author WHERE id=");
        str_sql.append(id);

/* TQuotAuthor.java - author of quotation,
 * SQL operations with the table 'quot_author' in Wiktionary parsed database.
 *
 */
package wikokit.base.wikt.sql.quote;

import wikokit.base.wikipedia.sql.Connect;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import wikokit.base.wikipedia.language.Encodings;
import wikokit.base.wikipedia.sql.PageTableBase;

/**
 * Author of quotation and
 * operations with the table 'quot_author' in MySQL Wiktionary parsed database.
 *
 * Remark: quot_author table has UNIQUE compound KEY (name, wikilink),
 * and wikilink field could be NULL.
 */
public class TQuotAuthor {

    /**
     * Inique identifier of the author.
     */
    private int id;

    /**
     * Author's name of the quote.
     */
    private String name;

    /**
     * A wikilink to author's name in Wikipedia (format: [[w:name|]]),
     * it could not be NULL, though it can be empty ("").
     */
    private String wikilink;

    private final static TQuotAuthor[] NULL_TQUOTAUTHOR_ARRAY = new TQuotAuthor[0];

    public TQuotAuthor(int _id, String _name, String _wikilink) {
        id = _id;
        name = _name;
        wikilink = _wikilink;
    }

    public TQuotAuthor(int _id, String _name) {
        id = _id;
        name = _name;
        wikilink = "";
    }

    /**
     * Gets unique ID from database
     */
    public int getID() {
        return id;
    }

    /**
     * Gets author's name from database.
     */
    public String getName() {
        return name;
    }

    /**
     * Gets wikilink to Wikipedia (format: [[w:name|]]) for the author.
     */
    public String getWikilink() {
        return wikilink;
    }

    /**
     * Inserts record into the table 'quot_author'.

     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   _wikilink can be empty or NULL
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertName(Connect connect, String _name) {
        return insertNameWikilink(connect, _name, "");
    }

    /**
     * Inserts record into the table 'quot_author'.

     * INSERT INTO quot_author (name,wikilink) VALUES ("Isaac Asimov", "Isaac Asimov");
     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   it could be empty ("")
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertNameWikilink(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor.insertNameAndWikilink()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("INSERT INTO quot_author (name,wikilink) VALUES (\"");
        str_sql.append(safe_name);
        str_sql.append("\", \"");
        str_sql.append(safe_wikilink);
        str_sql.append("\")");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                s.executeUpdate(str_sql.toString());
                s = connect.conn.createStatement();
                ResultSet rs = s.executeQuery("SELECT LAST_INSERT_ID() as id");
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.insertName):: _name='" + _name + "'; _wikilink='" + _wikilink + "'; sql='" + str_sql.toString() + "' error=" + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's first record from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" LIMIT 1;
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor getFirst(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        result = new TQuotAuthor(_id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's array of records from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov";
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor[] get(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\";");
        List<TQuotAuthor> list_authors = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    while (rs.next()) {
                        if (null == list_authors)
                            list_authors = new ArrayList<TQuotAuthor>();
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        list_authors.add(new TQuotAuthor(_id, _name, _wikilink));
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        if (null == list_authors)
            return NULL_TQUOTAUTHOR_ARRAY;
        return (TQuotAuthor[]) list_authors.toArray(NULL_TQUOTAUTHOR_ARRAY);
    }

    /**
     * Get's first suitable row from the table 'quot_author' by the author's name and wikilink.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" AND wikilink="" LIMIT 1;
     *
     * @param _name author's name
     * @param _wikilink author's name, it could be NULL or empty ("")
     *
     * @return NULL if data is absent
     */
    public static TQuotAuthor get(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("SELECT id FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" AND wikilink=\"");
        str_sql.append(safe_wikilink);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Gets ID of a record or inserts record (if it is absent)
     * into the table 'quot_author'.
     *
     * @param _author author's name
     * @param _author_wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                          it could be empty ("")
     */
    public static TQuotAuthor getOrInsert(Connect connect, String _author, String _author_wikilink) {
        if (null == _author || 0 == _author.length())
            return null;
        TQuotAuthor a = TQuotAuthor.getFirst(connect, _author);
        if (null == a)
            a = TQuotAuthor.insertNameWikilink(connect, _author, _author_wikilink);
        return a;
    }

    /**
     * Selects row from the table 'quot_author' by ID.

     *
     * SELECT name,wikilink FROM quot_author WHERE id=1
     *
     * @return null if data is absent
     */
    public static TQuotAuthor getByID(Connect connect, int id) {
        StringBuilder str_sql = new StringBuilder();
        str_sql.append("SELECT name,wikilink FROM quot_author WHERE id=");
        str_sql.append(id);
        TQuotAuthor quot_author = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        byte[] bb = rs.getBytes("name");
                        String _name = null == bb ? null : Encodings.bytesToUTF8(bb);
                        bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? null : Encodings.bytesToUTF8(bb);
                        quot_author = new TQuotAuthor(id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.getByID()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return quot_author;
    }

    /**
     * Deletes row from the table 'quot_author' by a value of ID.

     * DELETE FROM quot_author WHERE id=4;
     */
    public void delete(Connect connect) {
        StringBuilder str_sql = new StringBuilder();

        try {
            Statement s = connect.conn.createStatement();
            try {
                s.execute(str_sql.toString());
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.delete()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
    }
}


try {
            Statement s = connect.conn.createStatement();
            try {
                s.execute(str_sql.toString());
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.delete()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
    }

/* TQuotAuthor.java - author of quotation,
 * SQL operations with the table 'quot_author' in Wiktionary parsed database.
 *
 */
package wikokit.base.wikt.sql.quote;

import wikokit.base.wikipedia.sql.Connect;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import wikokit.base.wikipedia.language.Encodings;
import wikokit.base.wikipedia.sql.PageTableBase;

/**
 * Author of quotation and
 * operations with the table 'quot_author' in MySQL Wiktionary parsed database.
 *
 * Remark: quot_author table has UNIQUE compound KEY (name, wikilink),
 * and wikilink field could be NULL.
 */
public class TQuotAuthor {

    /**
     * Inique identifier of the author.
     */
    private int id;

    /**
     * Author's name of the quote.
     */
    private String name;

    /**
     * A wikilink to author's name in Wikipedia (format: [[w:name|]]),
     * it could not be NULL, though it can be empty ("").
     */
    private String wikilink;

    private final static TQuotAuthor[] NULL_TQUOTAUTHOR_ARRAY = new TQuotAuthor[0];

    public TQuotAuthor(int _id, String _name, String _wikilink) {
        id = _id;
        name = _name;
        wikilink = _wikilink;
    }

    public TQuotAuthor(int _id, String _name) {
        id = _id;
        name = _name;
        wikilink = "";
    }

    /**
     * Gets unique ID from database
     */
    public int getID() {
        return id;
    }

    /**
     * Gets author's name from database.
     */
    public String getName() {
        return name;
    }

    /**
     * Gets wikilink to Wikipedia (format: [[w:name|]]) for the author.
     */
    public String getWikilink() {
        return wikilink;
    }

    /**
     * Inserts record into the table 'quot_author'.

     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   _wikilink can be empty or NULL
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertName(Connect connect, String _name) {
        return insertNameWikilink(connect, _name, "");
    }

    /**
     * Inserts record into the table 'quot_author'.

     * INSERT INTO quot_author (name,wikilink) VALUES ("Isaac Asimov", "Isaac Asimov");
     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   it could be empty ("")
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertNameWikilink(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor.insertNameAndWikilink()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("INSERT INTO quot_author (name,wikilink) VALUES (\"");
        str_sql.append(safe_name);
        str_sql.append("\", \"");
        str_sql.append(safe_wikilink);
        str_sql.append("\")");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                s.executeUpdate(str_sql.toString());
                s = connect.conn.createStatement();
                ResultSet rs = s.executeQuery("SELECT LAST_INSERT_ID() as id");
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.insertName):: _name='" + _name + "'; _wikilink='" + _wikilink + "'; sql='" + str_sql.toString() + "' error=" + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's first record from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" LIMIT 1;
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor getFirst(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        result = new TQuotAuthor(_id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's array of records from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov";
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor[] get(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\";");
        List<TQuotAuthor> list_authors = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    while (rs.next()) {
                        if (null == list_authors)
                            list_authors = new ArrayList<TQuotAuthor>();
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        list_authors.add(new TQuotAuthor(_id, _name, _wikilink));
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        if (null == list_authors)
            return NULL_TQUOTAUTHOR_ARRAY;
        return (TQuotAuthor[]) list_authors.toArray(NULL_TQUOTAUTHOR_ARRAY);
    }

    /**
     * Get's first suitable row from the table 'quot_author' by the author's name and wikilink.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" AND wikilink="" LIMIT 1;
     *
     * @param _name author's name
     * @param _wikilink author's name, it could be NULL or empty ("")
     *
     * @return NULL if data is absent
     */
    public static TQuotAuthor get(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("SELECT id FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" AND wikilink=\"");
        str_sql.append(safe_wikilink);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Gets ID of a record or inserts record (if it is absent)
     * into the table 'quot_author'.
     *
     * @param _author author's name
     * @param _author_wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                          it could be empty ("")
     */
    public static TQuotAuthor getOrInsert(Connect connect, String _author, String _author_wikilink) {
        if (null == _author || 0 == _author.length())
            return null;
        TQuotAuthor a = TQuotAuthor.getFirst(connect, _author);
        if (null == a)
            a = TQuotAuthor.insertNameWikilink(connect, _author, _author_wikilink);
        return a;
    }

    /**
     * Selects row from the table 'quot_author' by ID.

     *
     * SELECT name,wikilink FROM quot_author WHERE id=1
     *
     * @return null if data is absent
     */
    public static TQuotAuthor getByID(Connect connect, int id) {
        StringBuilder str_sql = new StringBuilder();
        str_sql.append("SELECT name,wikilink FROM quot_author WHERE id=");
        str_sql.append(id);
        TQuotAuthor quot_author = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        byte[] bb = rs.getBytes("name");
                        String _name = null == bb ? null : Encodings.bytesToUTF8(bb);
                        bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? null : Encodings.bytesToUTF8(bb);
                        quot_author = new TQuotAuthor(id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.getByID()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return quot_author;
    }

    /**
     * Deletes row from the table 'quot_author' by a value of ID.

     * DELETE FROM quot_author WHERE id=4;
     */
    public void delete(Connect connect) {
        StringBuilder str_sql = new StringBuilder();
        str_sql.append("DELETE FROM quot_author WHERE id=");
        str_sql.append(id);


/* TQuotAuthor.java - author of quotation,
 * SQL operations with the table 'quot_author' in Wiktionary parsed database.
 *
 */
package wikokit.base.wikt.sql.quote;

import wikokit.base.wikipedia.sql.Connect;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import wikokit.base.wikipedia.language.Encodings;
import wikokit.base.wikipedia.sql.PageTableBase;

/**
 * Author of quotation and
 * operations with the table 'quot_author' in MySQL Wiktionary parsed database.
 *
 * Remark: quot_author table has UNIQUE compound KEY (name, wikilink),
 * and wikilink field could be NULL.
 */
public class TQuotAuthor {

    /**
     * Inique identifier of the author.
     */
    private int id;

    /**
     * Author's name of the quote.
     */
    private String name;

    /**
     * A wikilink to author's name in Wikipedia (format: [[w:name|]]),
     * it could not be NULL, though it can be empty ("").
     */
    private String wikilink;

    private final static TQuotAuthor[] NULL_TQUOTAUTHOR_ARRAY = new TQuotAuthor[0];

    public TQuotAuthor(int _id, String _name, String _wikilink) {
        id = _id;
        name = _name;
        wikilink = _wikilink;
    }

    public TQuotAuthor(int _id, String _name) {
        id = _id;
        name = _name;
        wikilink = "";
    }

    /**
     * Gets unique ID from database
     */
    public int getID() {
        return id;
    }

    /**
     * Gets author's name from database.
     */
    public String getName() {
        return name;
    }

    /**
     * Gets wikilink to Wikipedia (format: [[w:name|]]) for the author.
     */
    public String getWikilink() {
        return wikilink;
    }

    /**
     * Inserts record into the table 'quot_author'.

     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   _wikilink can be empty or NULL
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertName(Connect connect, String _name) {
        return insertNameWikilink(connect, _name, "");
    }

    /**
     * Inserts record into the table 'quot_author'.

     * INSERT INTO quot_author (name,wikilink) VALUES ("Isaac Asimov", "Isaac Asimov");
     *
     * @param _name author's name, it is not empty or NULL
     * @param _wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                   it could be empty ("")
     * @return inserted record, or null if insertion failed
     */
    public static TQuotAuthor insertNameWikilink(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor.insertNameAndWikilink()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("INSERT INTO quot_author (name,wikilink) VALUES (\"");
        str_sql.append(safe_name);
        str_sql.append("\", \"");
        str_sql.append(safe_wikilink);
        str_sql.append("\")");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                s.executeUpdate(str_sql.toString());
                s = connect.conn.createStatement();
                ResultSet rs = s.executeQuery("SELECT LAST_INSERT_ID() as id");
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.insertName):: _name='" + _name + "'; _wikilink='" + _wikilink + "'; sql='" + str_sql.toString() + "' error=" + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's first record from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" LIMIT 1;
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor getFirst(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        Strin

String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        result = new TQuotAuthor(_id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Get's array of records from the table 'quot_author' by the author's name.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov";
     *
     * @param _name author's name
     * @return NULL if data is absent
     */
    public static TQuotAuthor[] get(Connect connect, String _name) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor[] TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        str_sql.append("SELECT id,wikilink FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\";");
        List<TQuotAuthor> list_authors = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    while (rs.next()) {
                        if (null == list_authors)
                            list_authors = new ArrayList<TQuotAuthor>();
                        int _id = rs.getInt("id");
                        byte[] bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? "" : Encodings.bytesToUTF8(bb);
                        list_authors.add(new TQuotAuthor(_id, _name, _wikilink));
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        if (null == list_authors)
            return NULL_TQUOTAUTHOR_ARRAY;
        return (TQuotAuthor[]) list_authors.toArray(NULL_TQUOTAUTHOR_ARRAY);
    }

    /**
     * Get's first suitable row from the table 'quot_author' by the author's name and wikilink.

.
     * SELECT id,wikilink FROM quot_author WHERE name="Azimov" AND wikilink="" LIMIT 1;
     *
     * @param _name author's name
     * @param _wikilink author's name, it could be NULL or empty ("")
     *
     * @return NULL if data is absent
     */
    public static TQuotAuthor get(Connect connect, String _name, String _wikilink) {
        if (null == _name || 0 == _name.length()) {
            System.out.println("Error (TQuotAuthor TQuotAuthor.get()):: null argument: author's name.");
            return null;
        }
        if (null == _wikilink)
            _wikilink = "";
        StringBuilder str_sql = new StringBuilder();
        String safe_name = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _name);
        String safe_wikilink = PageTableBase.convertToSafeStringEncodeToDBWunderscore(connect, _wikilink);
        str_sql.append("SELECT id FROM quot_author WHERE name=\"");
        str_sql.append(safe_name);
        str_sql.append("\" AND wikilink=\"");
        str_sql.append(safe_wikilink);
        str_sql.append("\" LIMIT 1");
        TQuotAuthor result = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next())
                        result = new TQuotAuthor(rs.getInt("id"), _name, _wikilink);
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.get()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return result;
    }

    /**
     * Gets ID of a record or inserts record (if it is absent)
     * into the table 'quot_author'.
     *
     * @param _author author's name
     * @param _author_wikilink  link to author's name in Wikipedia (format: [[w:name|]]),
     *                          it could be empty ("")
     */
    public static TQuotAuthor getOrInsert(Connect connect, String _author, String _author_wikilink) {
        if (null == _author || 0 == _author.length())
            return null;
        TQuotAuthor a = TQuotAuthor.getFirst(connect, _author);
        if (null == a)
            a = TQuotAuthor.insertNameWikilink(connect, _author, _author_wikilink);
        return a;
    }

    /**
     * Selects row from the table 'quot_author' by ID.

     *
     * SELECT name,wikilink FROM quot_author WHERE id=1
     *
     * @return null if data is absent
     */
    public static TQuotAuthor getByID(Connect connect, int id) {
        StringBuilder str_sql = new StringBuilder();
        str_sql.append("SELECT name,wikilink FROM quot_author WHERE id=");
        str_sql.append(id);
        TQuotAuthor quot_author = null;
        try {
            Statement s = connect.conn.createStatement();
            try {
                ResultSet rs = s.executeQuery(str_sql.toString());
                try {
                    if (rs.next()) {
                        byte[] bb = rs.getBytes("name");
                        String _name = null == bb ? null : Encodings.bytesToUTF8(bb);
                        bb = rs.getBytes("wikilink");
                        String _wikilink = null == bb ? null : Encodings.bytesToUTF8(bb);
                        quot_author = new TQuotAuthor(id, _name, _wikilink);
                    }
                } finally {
                    rs.close();
                }
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.getByID()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
        return quot_author;
    }

    /**
     * Deletes row from the table 'quot_author' by a value of ID.

     * DELETE FROM quot_author WHERE id=4;
     */
    public void delete(Connect connect) {
        StringBuilder str_sql = new StringBuilder();
        str_sql.append("DELETE FROM quot_author WHERE id=");
        str_sql.append(id);
        try {
            Statement s = connect.conn.createStatement();
            try {
                s.execute(str_sql.toString());
            } finally {
                s.close();
            }
        } catch (SQLException ex) {
            System.out.println("SQLException (TQuotAuthor.delete()):: sql='" + str_sql.toString() + "' " + ex.getMessage());
        }
    }
}