Installation
You will need to download 2 files to use the plugin.
sqlitegen_eclipse_site_xxx.jar is a file containing an Eclipse plugin installation site in jar form. Download this file and configure it as a feature download site in the Eclipse software update panel; then you can install the plugin from it.
com.antlersoft.android.db_xxx.jar is a library jar with the dependencies required by the code generated by the plugin. Add this file as a library to the build path of any Eclipse project that will use the plugin.
Using the Plugin
The plugin will only work with Android projects. Enable it on a project by right-clicking on the project and setting the checkbox on the SQLiteGen... option in the project menu.
The plugin will look for interfaces in the project that have the annotation com.antlersoft.android.db.TableInterface Accessor methods within the interface annotated with com.antlersoft.android.db.FieldAccessor will define columns in the table. You can specify names and column types through fields in the annotation; refer to the (sadly incomplete) Javadoc for details. When the plugin sees the annotated interface, it will create an (optionally abstract) class implementing the interface that includes implementations of the accessor methods, static fields for field names and the table name, and methods for reading from, inserting and updating records in the table.
Example
This code:
/**
* Copyright (C) 2009 Michael A. MacDonald
*/
package android.androidVNC;
import com.antlersoft.android.db.*;
@TableInterface(ImplementingClassName="AbstractConnectionBean",TableName="CONNECTION_BEAN")
interface IConnectionBean {
@FieldAccessor
long get_Id();
@FieldAccessor
String getNickname();
@FieldAccessor
String getAddress();
@FieldAccessor
int getPort();
@FieldAccessor
String getPassword();
@FieldAccessor
String getColorModel();
@FieldAccessor
boolean getForceFull();
@FieldAccessor
String getRepeaterId();
}
generates this file:
// This class was generated from android.androidVNC.IConnectionBean by a tool
// Do not edit this file directly
package android.androidVNC;
public abstract class AbstractConnectionBean extends com.antlersoft.android.dbimpl.IdImplementationBase implements IConnectionBean {
public static final String GEN_TABLE_NAME = "CONNECTION_BEAN";
public static final int GEN_COUNT = 8;
// Field constants
public static final String GEN_FIELD__ID = "_ID";
public static final int GEN_ID__ID = 0;
public static final String GEN_FIELD_NICKNAME = "NICKNAME";
public static final int GEN_ID_NICKNAME = 1;
public static final String GEN_FIELD_ADDRESS = "ADDRESS";
public static final int GEN_ID_ADDRESS = 2;
public static final String GEN_FIELD_PORT = "PORT";
public static final int GEN_ID_PORT = 3;
public static final String GEN_FIELD_PASSWORD = "PASSWORD";
public static final int GEN_ID_PASSWORD = 4;
public static final String GEN_FIELD_COLORMODEL = "COLORMODEL";
public static final int GEN_ID_COLORMODEL = 5;
public static final String GEN_FIELD_FORCEFULL = "FORCEFULL";
public static final int GEN_ID_FORCEFULL = 6;
public static final String GEN_FIELD_REPEATERID = "REPEATERID";
public static final int GEN_ID_REPEATERID = 7;
// SQL Command for creating the table
public static String GEN_CREATE = "CREATE TABLE CONNECTION_BEAN (" +
"_ID INTEGER PRIMARY KEY AUTOINCREMENT," +
"NICKNAME TEXT," +
"ADDRESS TEXT," +
"PORT INTEGER," +
"PASSWORD TEXT," +
"COLORMODEL TEXT," +
"FORCEFULL INTEGER," +
"REPEATERID TEXT" +
")";
// Members corresponding to defined fields
private long gen__Id;
private java.lang.String gen_nickname;
private java.lang.String gen_address;
private int gen_port;
private java.lang.String gen_password;
private java.lang.String gen_colorModel;
private boolean gen_forceFull;
private java.lang.String gen_repeaterId;
public String Gen_tableName() { return GEN_TABLE_NAME; }
// Field accessors
public long get_Id() { return gen__Id; }
public void set_Id(long arg__Id) { gen__Id = arg__Id; }
public java.lang.String getNickname() { return gen_nickname; }
public void setNickname(java.lang.String arg_nickname) { gen_nickname = arg_nickname; }
public java.lang.String getAddress() { return gen_address; }
public void setAddress(java.lang.String arg_address) { gen_address = arg_address; }
public int getPort() { return gen_port; }
public void setPort(int arg_port) { gen_port = arg_port; }
public java.lang.String getPassword() { return gen_password; }
public void setPassword(java.lang.String arg_password) { gen_password = arg_password; }
public java.lang.String getColorModel() { return gen_colorModel; }
public void setColorModel(java.lang.String arg_colorModel) { gen_colorModel = arg_colorModel; }
public boolean getForceFull() { return gen_forceFull; }
public void setForceFull(boolean arg_forceFull) { gen_forceFull = arg_forceFull; }
public java.lang.String getRepeaterId() { return gen_repeaterId; }
public void setRepeaterId(java.lang.String arg_repeaterId) { gen_repeaterId = arg_repeaterId; }
public android.content.ContentValues Gen_getValues() {
android.content.ContentValues values=new android.content.ContentValues();
values.put(GEN_FIELD__ID,Long.toString(this.gen__Id));
values.put(GEN_FIELD_NICKNAME,this.gen_nickname);
values.put(GEN_FIELD_ADDRESS,this.gen_address);
values.put(GEN_FIELD_PORT,Integer.toString(this.gen_port));
values.put(GEN_FIELD_PASSWORD,this.gen_password);
values.put(GEN_FIELD_COLORMODEL,this.gen_colorModel);
values.put(GEN_FIELD_FORCEFULL,(this.gen_forceFull ? "1" : "0"));
values.put(GEN_FIELD_REPEATERID,this.gen_repeaterId);
return values;
}
/**
* Return an array that gives the column index in the cursor for each field defined
* @param cursor Database cursor over some columns, possibly including this table
* @return array of column indices; -1 if the column with that id is not in cursor
*/
public int[] Gen_columnIndices(android.database.Cursor cursor) {
int[] result=new int[GEN_COUNT];
result[0] = cursor.getColumnIndex(GEN_FIELD__ID);
result[1] = cursor.getColumnIndex(GEN_FIELD_NICKNAME);
result[2] = cursor.getColumnIndex(GEN_FIELD_ADDRESS);
result[3] = cursor.getColumnIndex(GEN_FIELD_PORT);
result[4] = cursor.getColumnIndex(GEN_FIELD_PASSWORD);
result[5] = cursor.getColumnIndex(GEN_FIELD_COLORMODEL);
result[6] = cursor.getColumnIndex(GEN_FIELD_FORCEFULL);
result[7] = cursor.getColumnIndex(GEN_FIELD_REPEATERID);
return result;
}
/**
* Populate one instance from a cursor
*/
public void Gen_populate(android.database.Cursor cursor,int[] columnIndices) {
if ( columnIndices[GEN_ID__ID] >= 0 && ! cursor.isNull(columnIndices[GEN_ID__ID])) {
gen__Id = cursor.getLong(columnIndices[GEN_ID__ID]);
}
if ( columnIndices[GEN_ID_NICKNAME] >= 0 && ! cursor.isNull(columnIndices[GEN_ID_NICKNAME])) {
gen_nickname = cursor.getString(columnIndices[GEN_ID_NICKNAME]);
}
if ( columnIndices[GEN_ID_ADDRESS] >= 0 && ! cursor.isNull(columnIndices[GEN_ID_ADDRESS])) {
gen_address = cursor.getString(columnIndices[GEN_ID_ADDRESS]);
}
if ( columnIndices[GEN_ID_PORT] >= 0 && ! cursor.isNull(columnIndices[GEN_ID_PORT])) {
gen_port = (int)cursor.getInt(columnIndices[GEN_ID_PORT]);
}
if ( columnIndices[GEN_ID_PASSWORD] >= 0 && ! cursor.isNull(columnIndices[GEN_ID_PASSWORD])) {
gen_password = cursor.getString(columnIndices[GEN_ID_PASSWORD]);
}
if ( columnIndices[GEN_ID_COLORMODEL] >= 0 && ! cursor.isNull(columnIndices[GEN_ID_COLORMODEL])) {
gen_colorModel = cursor.getString(columnIndices[GEN_ID_COLORMODEL]);
}
if ( columnIndices[GEN_ID_FORCEFULL] >= 0 && ! cursor.isNull(columnIndices[GEN_ID_FORCEFULL])) {
gen_forceFull = (cursor.getInt(columnIndices[GEN_ID_FORCEFULL]) != 0);
}
if ( columnIndices[GEN_ID_REPEATERID] >= 0 && ! cursor.isNull(columnIndices[GEN_ID_REPEATERID])) {
gen_repeaterId = cursor.getString(columnIndices[GEN_ID_REPEATERID]);
}
}
/**
* Populate one instance from a ContentValues
*/
public void Gen_populate(android.content.ContentValues values) {
gen__Id = values.getAsLong(GEN_FIELD__ID);
gen_nickname = values.getAsString(GEN_FIELD_NICKNAME);
gen_address = values.getAsString(GEN_FIELD_ADDRESS);
gen_port = (int)values.getAsInteger(GEN_FIELD_PORT);
gen_password = values.getAsString(GEN_FIELD_PASSWORD);
gen_colorModel = values.getAsString(GEN_FIELD_COLORMODEL);
gen_forceFull = (values.getAsInteger(GEN_FIELD_FORCEFULL) != 0);
gen_repeaterId = values.getAsString(GEN_FIELD_REPEATERID);
}
}
sqlitegen: http://code.google.com/p/sqlitegen/
android-vnc-viewer:http://code.google.com/p/android-vnc-viewer/
分享到:
相关推荐
Eclipse集成Android NDK说明 1 2 为什么要用NDK? 2 3 为什么要集成? 2 4 怎样操作? 2 4.1 预备条件 2 4.1.1 Cygwin 2 4.1.2 Eclipse 2 4.1.3 Eclipse CDT 3 4.1.4 Android SDK 3 4.1.5 Android NDK 3 ...
### 非常强大的Eclipse中Android NDK开发环境的配置说明 #### 一、概述 本文档将详细介绍如何在Eclipse中配置Android NDK开发环境,并实现C/C++代码的自动编译以及通过Eclipse使用Ant生成JNI所需的头文件。配置流程...
标题中的“Eclipse for PHP and Android”指的是Eclipse IDE(集成开发环境)的一个特定版本或配置,它集成了对PHP和Android开发的支持。Eclipse是一款开源的、跨平台的开发工具,广泛应用于Java、C++、PHP、Python...
希望对初学者有帮助!这是常用的Eclipse开发工具!和已经装好的SDK插件之后的完整版。免安装!
【基于Eclipse的Android音乐播放器】 在移动设备上开发应用程序是现代软件工程的重要组成部分,尤其是在Android平台上。Eclipse作为一款流行的集成开发环境(IDE),曾经是Android开发者的首选工具。本项目“基于...
Eclipse Android 开发插件是Android开发者在Eclipse集成开发环境中进行应用程序开发的重要工具。它极大地简化了Android项目创建、管理、调试以及构建的过程,使得开发者可以更专注于代码编写和功能实现。 首先,...
### Eclipse开发Android时创建工程出错解决办法 在使用Eclipse进行Android应用开发的过程中,可能会遇到创建项目时出现错误的情况,尤其是当使用较高版本的Eclipse与SDK时,这类问题更为常见。本文将针对此类问题...
VLC for Android Eclipse 工程是一个专为在Android平台上运行VLC媒体播放器而设计的开发项目,它基于Eclipse IDE进行构建。VLC是一款开源的、跨平台的多媒体播放器,支持各种视频和音频格式,以及网络流媒体。在这个...
【标题】"eclipse Android ADT" 是一个关键的开发工具,它专为在Eclipse集成开发环境中(IDE)创建Android应用程序而设计。这个工具集是Android开发者的重要武器,使得在Eclipse上进行Android开发变得可能和高效。 ...
在Android平台上开发应用程序,Eclipse是一款非常经典的集成开发环境(IDE),尤其对于早期的Android开发者而言,它是最常用的工具之一。本项目是一个基于Eclipse的简单计算器应用,它展示了如何在Android环境中创建...
**Eclipse 开发 Android 插件详解** 在 Android 应用程序开发中,Eclipse 作为一款经典的集成开发环境(IDE)曾广泛被开发者使用。其中,ADT(Android Developer Tools)是 Eclipse 针对 Android 开发的重要插件,...
【标题】"eclipse版AndroidTreeView" 是一个专为Eclipse IDE设计的Android开发项目,它实现了对GitHub上的原生AndroidTreeView库的移植,使得在Eclipse环境下也能方便地使用这个强大的树形视图组件。 【描述】"原来...
【标题】"android-code.rar_android_eclipse android" 暗示了这是一个与Android应用程序开发相关的压缩包,其中包含了可以在Eclipse集成开发环境中使用的源代码。Eclipse是Android开发者早期广泛使用的IDE,它提供了...
- **Eclipse**:选择安装了ADT(Android Developer Tools)的版本,这是Eclipse专门为Android开发设计的插件。 - **Eclipse CDT**:C/C++ Development Tooling,是Eclipse中的一个插件,用于支持C/C++的开发和调试。...
在Eclipse中关联Android源代码是为了更深入地理解Android系统的运行机制,以及便于进行调试和学习。以下是三种关联Android源代码的方法: ### 第一种方式:Source Attach 这种方法适用于已有的Android项目,通过...
《Eclipse Android 模仿Flappy Bird:初学者的Java Android开发之旅》 在移动应用开发的世界里,Android平台以其开源、灵活性和广泛的设备支持,吸引了无数开发者投身其中。对于初学者来说,选择一个合适的项目来...
Eclipse实现Android无尽战争小游戏,93分程序设计,详细注释! Eclipse实现Android无尽战争小游戏,93分程序设计,详细注释! Eclipse实现Android无尽战争小游戏,93分程序设计,详细注释! Eclipse实现Android无尽...
在本文中,我们将深入探讨如何使用Eclipse这一强大的集成开发环境(IDE)来开发Android源码。Android SDK和Eclipse的结合为开发者提供了高效、便捷的开发体验。首先,我们需要确保拥有正确的开发环境。 **一、Android...