CN105868270A - Android object storing framework based on reflection mechanism - Google Patents

Android object storing framework based on reflection mechanism Download PDF

Info

Publication number
CN105868270A
CN105868270A CN201610150224.XA CN201610150224A CN105868270A CN 105868270 A CN105868270 A CN 105868270A CN 201610150224 A CN201610150224 A CN 201610150224A CN 105868270 A CN105868270 A CN 105868270A
Authority
CN
China
Prior art keywords
database
data
function
data object
attribute
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201610150224.XA
Other languages
Chinese (zh)
Inventor
丑亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Entreat Wide Video Signal Medium Ltd Co
Original Assignee
Entreat Wide Video Signal Medium Ltd Co
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Entreat Wide Video Signal Medium Ltd Co filed Critical Entreat Wide Video Signal Medium Ltd Co
Priority to CN201610150224.XA priority Critical patent/CN105868270A/en
Publication of CN105868270A publication Critical patent/CN105868270A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses an android object storing framework based on a reflection mechanism. The storing framework comprises a simple database operation function module, a data operation auxiliary module, a data object list module and a data access object module. The storing framework is designed by use of the API, and by a inheriting selfdata object abstract base class, a to-be-stored data object is restrained. A major key and a method for judging whether auto-increment of the major key is required are provided. Operation is performed by adding all data objects inheriting the selfdata object abstract base class in a configuration list, acquiring all data object types during establishing of a database and automatically establishing a database list. According to the invention, required additional configuration is quite less; learning cost is low; and API is quite precise, simple and easy to use, so the storing framework is suitable to be used in small and medium enterprises, individual developers or an Android application where storage objects are too many but single object is quite simple.

Description

Android object storing framework based on reflex mechanism
Technical field
The present invention relates to a kind of object storing framework, particularly to a kind of Android based on reflex mechanism Object storing framework.
Background technology
Along with the raising developing demand locally stored with data rapidly in Android market, how to simplify The data object storage work of Android platform, easier for the offer of numerous Android application developer, General data object storing framework becomes numerous enterprises, tissue, technical staff's concern.Mesh Before, the data storage technology used in Android platform is mainly: use in Android API Data object is configured to the mode of key-value pair and stores by SharePreference class, protects in XML file mode Deposit;Serialized by Json or Java, data object is preserved in the way of text;Use The database frameworks such as greenDAO, OrmLite, AndrORM, are mapped as data object in database Literary name section preserves.
Above several solutions have many defects: stored by SharePreference class, Call format to data object is must to be single value, is not having the auxiliary of other object serialization technology Help down and cannot meet the storage of the unified approach to arbitrary data object type;When xml stores and resolves Wait inefficient;In the case of storage object is numerous, need developer's key to using in storing process Value is managed.Therefore, the storage of a small amount of simple data it is only applicable to.By Json or Java sequence The mode changed then is unfavorable for the amendment of data, after serializing batch data, if needing amendment The most a certain, then again serialize all data and again carry out file storage after needing amendment.Use The database relation mapping frameworks such as greenDAO, OrmLite, AndrORM can be good at data pair The additions and deletions of elephant change look into operation and efficiency higher.But the configuration of data above storehouse framework uses note, xml more The modes such as configuration, configure relatively complicated, learning cost is higher, API ease for use is not enough, too much increase The size of application package.
Summary of the invention
It is an object of the invention to provide a kind of Android object storing framework based on reflex mechanism.Should Needed for object storing framework, additional configuration is less, learning cost is low, API more simplifies easy-to-use.
A kind of Android object storing framework based on reflex mechanism, described storing framework includes:
Simple data storehouse handling function module, looks into function for providing the additions and deletions used by database manipulation to change;
Data manipulation supplementary module, for providing the opening of database, updating operation function;
Data object list module, needs to carry out the data object type of database manipulation for record;
DAO module, for recording the community set of data object.
Described simple data storehouse handling function module includes: database manipulation auxiliary object;Perform database Handling function;Retrieve the result array that all object types being inherited from DAO base class obtain; Retrieve and single be inherited from the object type of DAO base class, search condition, search condition attribute number The result array that group, arrangement mode obtain;Judge to insert data object the most successfully function;Judge more New data-objects the most successfully function;Judge to delete data object the most successfully function;Data object Set;Data object attribute set;Database statement set;Obtain the method function of attribute;Genus is set The method function of property.
Described data manipulation supplementary module includes: create database (): Void;Upgrade database (): Void; Type of database maps () String.
Described data object list module includes: be inherited from the list object of DAO base class;Number Building method is given tacit consent to according to list object;Single example data object;Obtain the function of data object list.
Described DAO module includes: obtains and wants conservation object major key function;Whether judge major key From increasing function.
Described conservation object includes: id attribute, name attribute, age attribute, commodity id attribute, commodity Name attribute and price attribute.
A kind of Android object based on reflex mechanism storage method, is carried out in accordance with the following steps:
(1) initialization data storehouse access tool class simpleDBUtil;
(2) check that database table creates the most, if it is obtain database manipulation object;If not Then by the establishment SQL statement of reflective construct database table, then create database table, then obtain number Object is operated according to storehouse;
(3) by reflective construct database manipulation SQL statement;
(4) perform database to increase, delete, change, look into operation, return operating result.
Compared with prior art, there is advantages that the framework of the present invention uses API to set Meter, by being inherited from data object abstract base class, retrain data object to be stored, it is provided that major key with sentence The fixed method certainly increased the need of major key, takes out by adding all data objects that is inherited from configured list As the data object of base class, and obtain all data object type when database creates and automatically create number Operate according to the mode of storehouse table.The data object storage mode greenDAO best with prior art, The database frameworks such as OrmLite, AndrORM are compared, and needed for the framework of the present invention, additional configuration is less, learn Practise low cost, API more simplify easy-to-use, be therefore more suitable for medium-sized and small enterprises, personal development person or Storage object is numerous but uses in Android application that single object is relatively simple.
Accompanying drawing explanation
Fig. 1 is present invention Android based on reflex mechanism object storing framework figure.
Fig. 2 is that data object of the present invention stores browsing process figure.
Detailed description of the invention
Below in conjunction with the accompanying drawings, the detailed description of the invention of the present invention is described in detail, it is to be understood that this The protection domain of invention is not limited by detailed description of the invention.
A kind of Android object storing framework based on reflex mechanism, as it is shown in figure 1, described storage box Frame includes:
Simple data storehouse handling function module, looks into function for providing the additions and deletions used by database manipulation to change;
Data manipulation supplementary module, for providing the opening of database, updating operation function;
Data object list module, needs to carry out the data object type of database manipulation for record;
DAO module, for recording the community set of data object.
Described simple data storehouse handling function module includes: database manipulation auxiliary object;Perform database Handling function;Retrieve the result array that all object types being inherited from DAO base class obtain; Retrieve and single be inherited from the object type of DAO base class, search condition, search condition attribute number The result array that group, arrangement mode obtain;Judge to insert data object the most successfully function;Judge more New data-objects the most successfully function;Judge to delete data object the most successfully function;Data object Set;Data object attribute set;Database statement set;Obtain the method function of attribute;Genus is set The method function of property.
Described data manipulation supplementary module includes: create database (): Void;Upgrade database (): Void; Type of database maps () String.
Described data object list module includes: be inherited from the list object of DAO base class;Number Building method is given tacit consent to according to list object;Single example data object;Obtain the function of data object list.
Described DAO module includes: obtains and wants conservation object major key function;Whether judge major key From increasing function.
Described conservation object includes: id attribute, name attribute, age attribute, commodity id attribute, commodity Name attribute and price attribute.
This technological frame core classes is SimpleDBUtil.java file.This document contains for counting According to all methods of object storage and for obtaining the MySqlLiteOpenHelper class of database object. Except comprising one for being converted into one by one by the attribute in Java object in MySqlLiteOpenHelper Outside the method for database field type, also it is initialized in its onCreate () method DaoListSingleton class, such is for configuring what record be there is a need to be saved in this technological frame Object, all these objects are all inherited from BaseDao.Abstract method getKey () defined in BaseDao Ensure that with autolncrease () object of all classes being inherited from BaseDao all can be right SimpleDBUtil tool-class provides method to illustrate that this object major key when being saved in database table is Whether what and major key be from increasing.
As in figure 2 it is shown, a kind of Android object based on reflex mechanism storage method, according to following step Suddenly carry out:
(1) initialization data storehouse access tool class simpleDBUtil;
(2) check that database table creates the most, if it is obtain database manipulation object;If not Then by the establishment SQL statement of reflective construct database table, then create database table, then obtain number Object is operated according to storehouse;
(3) by reflective construct database manipulation SQL statement;
(4) perform database to increase, delete, change, look into operation, return operating result.
In the use flow process of this technological frame, if user has constructed one is inherited from BaseDao Data object.The when that this data object being carried out storage operation, as long as newly-built one SimpleDBUtil tool-class, can use the data manipulation API provided in SimpleDBUtil tool-class. This framework can check that database table has created, and by the reflex mechanism of JAVA, maps data object In all fields, constructing SQL statement create number after changing into the field type in Sqlite database According to storehouse table, then construct again by reflex mechanism to change for additions and deletions and look into the data manipulation that middle user needs SQL statement carry out the additions and deletions of this data object are changed looking into operation.Wherein by reflective construct SQL statement Process approximately as, as a example by the insertion SQL statement of data object, first create one for character The StringBuffer object of string splicing, is spliced into " INSERT INTO " SQL statement with this object, The class name of data object is then obtained by clazz.getSimpleName (), and using this type of name as table Name, splices SQL again.Now SQL is " INSERT INTO (table name) ", splices " VAELUS after SQL (?,?,?) ", wherein placeholder "?" number, obtained by the number of all properties of iterative data object ?.The number of all properties of iterative data object obtains attribute-name simultaneously, then passes through GetGetMethodName (String valueName) method obtains the method name obtaining this attribute.With needing The method of data to be saved object obtains the property value array of data object, incoming as parameter CreatelnsertSQL () can obtain the SQL statement that complete data object inserts.If wall scroll Data, method is inserted just can to directly invoke insert (BaseDao dao), if data acquisition system, Then need circulation to generate SQL statement, carried out by insert (ArrayList<BaseDao>daoList) Affairs insert storing process in batches.
The specific embodiment being only the present invention disclosed above, but, the present invention is not limited to this, appoints What what those skilled in the art can think change all should fall into protection scope of the present invention.

Claims (7)

1. an Android object storing framework based on reflex mechanism, it is characterised in that described storage Framework includes:
Simple data storehouse handling function module, looks into function for providing the additions and deletions used by database manipulation to change;
Data manipulation supplementary module, for providing the opening of database, updating operation function;
Data object list module, needs to carry out the data object type of database manipulation for record;
DAO module, for recording the community set of data object.
Android object storing framework based on reflex mechanism the most according to claim 1, it is special Levying and be, described simple data storehouse handling function module includes: database manipulation auxiliary object;Perform number According to storehouse handling function;Retrieve the number of results that all object types being inherited from DAO base class obtain Group;Retrieve single be inherited from the object type of DAO base class, search condition, search condition belong to The result array that property array, arrangement mode obtain;Judge to insert data object the most successfully function;Sentence Disconnected more new data-objects the most successfully function;Judge to delete data object the most successfully function;Data Object set;Data object attribute set;Database statement set;Obtain the method function of attribute;If Put the method function of attribute.
Android object storing framework based on reflex mechanism the most according to claim 1, it is special Levying and be, described data manipulation supplementary module includes: create database (): Void;Upgrade database (): Void;Type of database maps () String.
Android object storing framework based on reflex mechanism the most according to claim 1, it is special Levying and be, described data object list module includes: be inherited from the list object of DAO base class; Data object list acquiescence building method;Single example data object;Obtain the function of data object list.
Android object storing framework based on reflex mechanism the most according to claim 1, it is special Levying and be, described DAO module includes: obtains and wants conservation object major key function;Judge major key Whether from increasing function.
Android object storing framework based on reflex mechanism the most according to claim 5, it is special Levying and be, described conservation object includes: id attribute, name attribute, age attribute, commodity id attribute, Trade name attribute and price attribute.
7. Android object based on a reflex mechanism storage method, it is characterised in that according to as follows Step is carried out:
(1) initialization data storehouse access tool class simpleDBUtil;
(2) check that database table creates the most, if it is obtain database manipulation object;If not Then by the establishment SQL statement of reflective construct database table, then create database table, then obtain number Object is operated according to storehouse;
(3) by reflective construct database manipulation SQL statement;
(4) perform database to increase, delete, change, look into operation, return operating result.
CN201610150224.XA 2016-03-17 2016-03-17 Android object storing framework based on reflection mechanism Pending CN105868270A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610150224.XA CN105868270A (en) 2016-03-17 2016-03-17 Android object storing framework based on reflection mechanism

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610150224.XA CN105868270A (en) 2016-03-17 2016-03-17 Android object storing framework based on reflection mechanism

Publications (1)

Publication Number Publication Date
CN105868270A true CN105868270A (en) 2016-08-17

Family

ID=56624753

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610150224.XA Pending CN105868270A (en) 2016-03-17 2016-03-17 Android object storing framework based on reflection mechanism

Country Status (1)

Country Link
CN (1) CN105868270A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108536711A (en) * 2017-03-03 2018-09-14 优信拍(北京)信息科技有限公司 A kind of date storage method and device
CN108595164A (en) * 2018-04-08 2018-09-28 浙江网盛数新软件股份有限公司 A kind of conversion method of data format and Java object
CN108920566A (en) * 2018-06-21 2018-11-30 吉林亿联银行股份有限公司 Operating method, device and the equipment of a kind of pair of SQLite database
CN110457013A (en) * 2019-07-12 2019-11-15 阿里巴巴集团控股有限公司 Program assembly configuration device and method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102694707A (en) * 2012-05-31 2012-09-26 李英祥 Bluetooth and android technology-based household information system and monitoring control method
CN103902634A (en) * 2012-12-30 2014-07-02 航天信息股份有限公司 Method for achieving automatic binding between View assembly and database fields through Adapter
US20150012924A1 (en) * 2013-03-14 2015-01-08 Tencent Technology (Shenzhen) Company Limited Method and Device for Loading a Plug-In
CN104392176A (en) * 2014-12-12 2015-03-04 北京奇虎科技有限公司 Mobile terminal and method for intercepting device manager authority thereof

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102694707A (en) * 2012-05-31 2012-09-26 李英祥 Bluetooth and android technology-based household information system and monitoring control method
CN103902634A (en) * 2012-12-30 2014-07-02 航天信息股份有限公司 Method for achieving automatic binding between View assembly and database fields through Adapter
US20150012924A1 (en) * 2013-03-14 2015-01-08 Tencent Technology (Shenzhen) Company Limited Method and Device for Loading a Plug-In
CN104392176A (en) * 2014-12-12 2015-03-04 北京奇虎科技有限公司 Mobile terminal and method for intercepting device manager authority thereof

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
罗多多: ""基于网络支付与移动客户端的集体食堂菜品购销系统设计与实现"", 《中国优秀硕士学位论文全文数据库信息科技辑》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108536711A (en) * 2017-03-03 2018-09-14 优信拍(北京)信息科技有限公司 A kind of date storage method and device
CN108536711B (en) * 2017-03-03 2021-06-25 优信拍(北京)信息科技有限公司 Data storage method and device
CN108595164A (en) * 2018-04-08 2018-09-28 浙江网盛数新软件股份有限公司 A kind of conversion method of data format and Java object
CN108920566A (en) * 2018-06-21 2018-11-30 吉林亿联银行股份有限公司 Operating method, device and the equipment of a kind of pair of SQLite database
CN108920566B (en) * 2018-06-21 2020-10-20 吉林亿联银行股份有限公司 Method, device and equipment for operating SQLite database
CN110457013A (en) * 2019-07-12 2019-11-15 阿里巴巴集团控股有限公司 Program assembly configuration device and method
CN110457013B (en) * 2019-07-12 2023-11-17 创新先进技术有限公司 Program component configuration device and method

Similar Documents

Publication Publication Date Title
US11656859B2 (en) Data model API for live applications in a cloud collaboration platform
US9575736B2 (en) Advanced interactive command-line front-end for graph analysis systems
US11733990B2 (en) Generating software artifacts from a conceptual data model
US9043757B2 (en) Identifying differences between source codes of different versions of a software when each source code is organized using incorporated files
CN109933571A (en) Database design documentation generation method, device and computer readable storage medium
CN105868270A (en) Android object storing framework based on reflection mechanism
US10394756B2 (en) System and method for customizing archive of a device driver generator tool for a user
US8201147B2 (en) Generic XAD processing model
CN106775696A (en) Data processing method and device
US9665601B1 (en) Using a member attribute to perform a database operation on a computing device
Miao et al. Formalizing UML models with Object-Z
Girbea et al. Efficient address space generation for an OPC UA server
Lee Concept-based method for extracting valid subsets from an EXPRESS schema
CN114138815A (en) Multi-database compatibility implementation method, device and medium for application program
CN112380142A (en) Interface document management method and device and test equipment
US20200201609A1 (en) Metadata-Driven Design-Time Tooling
EP1990736A1 (en) A processing method and system of custom object based on object storage library
US7694279B2 (en) Extensible web service
CN113342399B (en) Method and device for configuring structure of application program and readable storage medium
CN110018828A (en) Source code inspection method, device and terminal device
US11150955B2 (en) Generation and usage of a task-based programming platform
CN113760466A (en) Multi-transaction processing method, device, computer system and readable storage medium
Anderson et al. JavaFX Rich Client Programming on the NetBeans Platform
Purdum et al. Structures, Unions, and Data Storage
CN117707616A (en) Compatible method, device, terminal and storage medium of heterogeneous database

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20160817

WD01 Invention patent application deemed withdrawn after publication