CN104360865B - A kind of sequencing method, unserializing method and relevant device - Google Patents

A kind of sequencing method, unserializing method and relevant device Download PDF

Info

Publication number
CN104360865B
CN104360865B CN201410712481.9A CN201410712481A CN104360865B CN 104360865 B CN104360865 B CN 104360865B CN 201410712481 A CN201410712481 A CN 201410712481A CN 104360865 B CN104360865 B CN 104360865B
Authority
CN
China
Prior art keywords
attribute
information
sequence
serializability
class
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.)
Active
Application number
CN201410712481.9A
Other languages
Chinese (zh)
Other versions
CN104360865A (en
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.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
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 China Construction Bank Corp filed Critical China Construction Bank Corp
Priority to CN201410712481.9A priority Critical patent/CN104360865B/en
Publication of CN104360865A publication Critical patent/CN104360865A/en
Application granted granted Critical
Publication of CN104360865B publication Critical patent/CN104360865B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

A kind of sequencing method provided by the invention, unserializing method and relevant device, obtain attribute and the attribute type information that the needs of general category serialize, by described the attribute serialized is needed to add seriation description information, so that general category is labeled as serializability class, it loads the serialization information and attribute type information and serializes configuration by by serialization information to memory, without additional configuration file, support static compilation inspection, reducing configuration error may, support the self-defined attribute for needing to serialize, support a variety of fundamental types and customization type, it realizes simple, treatment effeciency is high, extension is convenient.

Description

A kind of sequencing method, unserializing method and relevant device
Technical field
The invention belongs to computer realm, more particularly to a kind of sequencing method, unserializing method and relevant device.
Background technology
Object serialization/unserializing technology is widely used in computer realm, is largely used in system backup, network leads to News etc. are related to the scene of data exchange, and main realize throttles object serialization for binary word, and then can be stored in storage Equipment exchanges data with other systems.
The serializing technology of mainstream can all serialize all properties of object at present, self-defined can not need sequence The attribute of change, in often the sector application that big data quantity exchanges occurs in some, such as telecommunications, financial industry, it will usually self-defined Communication format, and only need to serialize the part attribute in object, serializing efficiency is improved to reach, saves transmission bandwidth Purpose can not directly use the serializing technology of mainstream.
In the prior art, the Chinese patent (patent No.:200910190251) a kind of object serialization method, object are disclosed Unserializing method, apparatus and system describe the problem of attribute increases and decreases, unserializing is caused to fail in object, Chinese patent (the patent No.:201310596703) a kind of object serialization method and apparatus are disclosed, describe serializing result must and mesh Mark object structure strictly maps, and can not meet flexible the problem of serializing demand, but all without solving User Defined sequence The problem of rowization attribute.
The content of the invention
In view of this, an embodiment of the present invention provides a kind of sequencing method, unserializing method and relevant devices.
It is an object of the present invention to provide a kind of sequencing method, the sequencing method includes:
It is explained in serializability class for the attribute serialized is needed to add serializability, attribute is labeled as serializability category Property;
To serializability class, load all serializability attribute informations in category information and class and, to memory, formed and preload sequence Rowization information;
According to preloading sequence information, all serializability attributes in pending byte sequence are obtained, and according to sequence Change order sorts;
Obtaining in instance object needs the attribute serialized;
According to the serialization information and attribute type information loaded in the memory to the instance object needs The sequence of attributes of serializing, and the property value after instance object serializing is exported to byte sequence.
As a preferred solution, in needing the attribute serialized in the acquisition instance object, the method It specifically includes:
The attribute that the needs of instance object serialize is obtained successively, and the attribute is sequentially sorted.
As a preferred solution, according to the serialization information and attribute type information loaded in the memory It is exported to the sequence of attributes that instance object needs serialize, and by the property value after instance object serializing Into byte sequence, the method specifically includes:
Corresponding serialization information is searched in the serialization information caching preloaded according to attribute name, is believed according to serializing Breath and attribute type information, property value Formatting Output after instance object is serialized to byte sequence.
As a preferred solution, it is described instance object is serialized after property value Formatting Output to byte In sequence, the method specifically includes:
It is described instance object is serialized after property value be output to using the formal mode of sequence number, length or coding In byte sequence.
It is a further object to provide a kind of unserializing method, the sequencing method includes:
It is explained in serializability class for the attribute serialized is needed to add serializability, attribute is labeled as serializability category Property;
To serializability class, load all serializability attribute informations in category information and class and, to memory, formed and preload sequence Rowization information;
According to preloading sequence information, all serializability attributes in pending byte sequence are obtained, and according to sequence Change order sorts;
Obtain the content of pending byte sequence;
It will be in the byte sequence according to the serialization information and attribute type information loaded in the memory Appearance is converted to property value.
As a preferred solution, in needing the attribute serialized in the acquisition instance object, the method It specifically includes:
The attribute that the needs of instance object serialize is obtained successively, and the attribute is sequentially sorted.
As a preferred solution, in the Content Transformation by the byte sequence is property value, the side Method specifically includes:
And be formatted the content according to attribute type information, the content of formatting is stored in the example Change in object's property value.
It is a further object to provide a kind of serializing devices, which is characterized in that the serializing device includes:
First acquisition unit for being explained in serializability class for the attribute serialized is needed to add serializability, will belong to Property be labeled as serializability attribute;
First indexing unit, for serializability class, loading all serializability attribute informations in category information and class and arriving Memory forms preloading sequence information;
First loading unit, for according to preloading sequence information, obtain it is all in pending byte sequence can sequence Change attribute, and sorted according to serializing order;
Second acquisition unit, for obtaining the attribute for needing to serialize in instance object;
First output unit, for according to the serialization information and attribute type information loaded in the memory to institute The sequence of attributes that instance object needs serialize is stated, and the property value after instance object serializing is exported to word Save sequence.
As a preferred solution, what the first acquisition unit was additionally operable to obtain instance object successively needs sequence The attribute of change, and the attribute is sequentially sorted.
As a preferred solution, the serializing that first output unit is additionally operable to be preloaded according to attribute name is believed Corresponding serialization information is searched in breath caching, according to serialization information and attribute type information, instance object is serialized Property value Formatting Output afterwards is to byte sequence.
As a preferred solution, first output unit be additionally operable to it is described instance object is serialized after category Property value be output to using the formal mode of sequence number, length or coding in byte sequence.
It is a further object to provide a kind of unserializing devices, which is characterized in that the serializing device bag It includes:
First acquisition unit for being explained in serializability class for the attribute serialized is needed to add serializability, will belong to Property be labeled as serializability attribute;
First indexing unit, for serializability class, loading all serializability attribute informations in category information and class and arriving Memory forms preloading sequence information;
First loading unit, for according to preloading sequence information, obtain it is all in pending byte sequence can sequence Change attribute, and sorted according to serializing order;
Second acquisition unit, for the content of pending byte sequence;
First converting unit, for according to the serialization information and attribute type information loaded in the memory by institute It is property value to state the Content Transformation in byte sequence.
As a preferred solution, what first indexing unit was additionally operable to obtain instance object successively needs sequence The attribute of change, and the attribute is sequentially sorted.
As a preferred solution, first converting unit be additionally operable to by the content according to attribute type information into The content of formatting is stored in the property value of the instance object by formatting lines.
As can be seen from the above technical solutions, the embodiment of the present invention has the following advantages:
A kind of sequencing method provided by the invention, unserializing method and relevant device, obtain general category needs sequence The attribute of rowization and attribute type information need the attribute serialized to add seriation description information, so that will be general by described Logical class loads the serialization information and attribute type information and is configured to memory serializing by by sequence labeled as serializability class Rowization information without additional configuration file, supports static compilation inspection, reduction configuration error is possible, supports self-defined needs The attribute of serializing supports a variety of fundamental types and customization type, realizes that simple, treatment effeciency is high, extension is convenient.
Description of the drawings
Fig. 1 is a kind of flow chart of embodiment of sequencing method of the present invention;
Fig. 2 is the flow chart of another embodiment of sequencing method of the present invention;
Fig. 3 is a kind of flow chart of embodiment of unserializing method of the present invention;
Fig. 4 is the flow chart of another embodiment of unserializing method of the present invention;
Fig. 5 is a kind of structure chart of embodiment of present invention serializing device;
Fig. 6 is a kind of structure chart of embodiment of unserializing method of the present invention.
Specific embodiment
An embodiment of the present invention provides a kind of sequencing method, unserializing method and relevant devices, realize simple, processing Efficient, extension is convenient.
In order to which those skilled in the art is made to more fully understand the present invention program, below in conjunction in the embodiment of the present invention The technical solution in the embodiment of the present invention is clearly and completely described in attached drawing, it is clear that described embodiment is only The embodiment of a part of the invention, instead of all the embodiments.Based on the embodiments of the present invention, ordinary skill people Member's all other embodiments obtained without making creative work should all belong to the model that the present invention protects It encloses.
Term " first ", " second ", " the 3rd " " in description and claims of this specification and above-mentioned attached drawing Four " etc. be the object for distinguishing similar, without being used to describe specific order or precedence.It should be appreciated that it so uses Data can exchange in the appropriate case, so that the embodiments described herein can be in except illustrating or describing herein Order beyond appearance is implemented.In addition, term " comprising " and " having " and their any deformation, it is intended that covering is non-exclusive Include, be not necessarily limited to clearly arrange for example, containing the process of series of steps or unit, method, system, product or equipment Those steps or unit gone out, but may include not list clearly or consolidate for these processes, method, product or equipment The other steps or unit having.
Below in conjunction with the attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete Site preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, the every other implementation that those skilled in the art are obtained without creative efforts Example, belongs to the scope of protection of the invention.
The present invention provides a kind of sequencing method, the sequencing method includes:
S101, the annotating information for adding serializability to class and its attribute declaration in class declaration file, by common category It is denoted as serializability class.
General category herein refers to the initial data not serialized, and user can need sequence by self-defined setting The attribute of rowization, can customize serialization format, can customize the attribute for needing to serialize, can support numerous types of data, such as Fundamental types such as shaping, floating number, byte, array and by the customized type of modes, the general category bag such as inheriting, combining Attribute and attribute type information are included, common breeding can include multiple attributes for needing to serialize, and attribute here is appreciated that It is each to need sequence in general category using the description information of structuring for a series of set of attributes for needing to serialize The attribute addition serialization information of change, serialization information can include information, the users such as sequence number, length, coding can be self-defined The attribute of serializing so that serialization process is more flexible.
S102, explained in serializability class for the attribute serialized is needed to add serializability, attribute is labeled as can sequence Rowization attribute.
It is that the attribute that each needs serialize adds serialization information in general category using the description information of structuring, Serialization information includes the information such as sequence number, length, coding, such as serializes or utilize length by general category according to sequence number Degree or number etc., do not limit, and general category is marked serializability class.
S103, to serializability class, load all serializability attribute informations in category information and class and, to memory, form pre-add Carry serialization information.
Search for all classes for being labeled serializability in class.path, the attribute that can be serialized in analysis classes, The serialization information and attribute type information cache of attribute make to memory convenient for being called in serializing or unserializing With.
It should be noted that these three steps of S101, S102, S103, can be pre-configured with completion, sequence can also carried out Rowization or unserializing carry out situ configuration when operating, this is not limited.
The attribute serialized is needed in S104, acquisition instance object.
Instance object is the object variable of instantiation, when carrying out serializing operation to instance object, is obtained real The attribute serialized is needed in exampleization object, the corresponding sequence of attribute can be inquired in residing memory according to the title of attribute Change information, further according to serialization information and the type information of attribute, the property value after instance object is serialized is exported to word Save sequence.
S105, according to the serialization information and attribute type information loaded in the memory to the instance object The sequence of attributes serialized is needed, and the property value after instance object serializing is exported to byte sequence.
Inquiry has loaded serialization information in memory, and traversal wherein needs the attribute serialized, according to attribute sequence Property value is output to byte sequence by rowization information and attribute type, and the output of property value can also use other modes, according to Actual needs makes choice, and does not limit specifically.
It explains (Annotation), is also metadata, for illustrating code rank, and class, interface, to enumerate be same Level.It can be stated before bag, class, field, method, local variable, method parameter etc., for being carried out to these elements Illustrate, annotate, write document:Document, code analysis are generated by the metadata identified in code:Pass through the member identified in code Data analyze code, and compiling checks:By the metadata identified in code compiler can be crossed and realize basic compiling It checks, those of ordinary skill in the art are it is to be appreciated that without repeating.
A kind of sequencing method provided by the invention, serialization information by being passed through note by serializing configuration in general category Solution expression, without additional configuration file, support static compilation inspection, reduction configuration error is possible, and support is self-defined to need sequence The attribute of rowization supports a variety of fundamental types and customization type, realizes that simple, treatment effeciency is high, extension is convenient.
Sequencing method of the present invention additionally provides another embodiment, and the sequencing method includes:
S201, to serializability class, load all serializability attribute informations in category information and class and, to memory, form pre-add Carry serialization information.
General category herein refers to the initial data not serialized, and user can need sequence by self-defined setting The attribute of rowization, can customize serialization format, can customize the attribute for needing to serialize, can support numerous types of data, such as Fundamental types such as shaping, floating number, byte, array and by the customized type of modes, the general category bag such as inheriting, combining Attribute and attribute type information are included, common breeding can include multiple attributes for needing to serialize, and attribute here is appreciated that It is each to need sequence in general category using the description information of structuring for a series of set of attributes for needing to serialize The attribute addition serialization information of change, serialization information can include information, the users such as sequence number, length, coding can be self-defined The attribute of serializing so that serialization process is more flexible.
S202, explained in serializability class for the attribute serialized is needed to add serializability, attribute is labeled as can sequence Rowization attribute.
It is that the attribute that each needs serialize adds serialization information in general category using the description information of structuring, Serialization information includes the information such as sequence number, length, coding, such as serializes or utilize length by general category according to sequence number Degree or number etc., do not limit, and general category is marked serializability class.
S203, to serializability class, load all serializability attribute informations in category information and class and, to memory, form pre-add Carry serialization information.
Search for all classes for being labeled serializability in class.path, the attribute that can be serialized in analysis classes, The serialization information and attribute type information cache of attribute make to memory convenient for being called in serializing or unserializing With.
It should be noted that these three steps of S201, S202, S203, can be pre-configured with completion, sequence can also carried out Rowization or unserializing carry out situ configuration when operating, this is not limited.
The attribute serialized is needed in S204, acquisition instance object.
Corresponding serialization information is searched in S205, the serialization information caching preloaded according to attribute name, according to sequence Rowization information and attribute type information, property value Formatting Output after instance object is serialized to byte sequence.
Particularly, specifically designed into byte sequence in the property value Formatting Output after instance object is serialized Arrive, it is described instance object is serialized after property value byte is output to using the formal mode of sequence number, length or coding In sequence.
A kind of sequencing method provided by the invention, serialization information by being passed through note by serializing configuration in general category Solution expression, without additional configuration file, support static compilation inspection, reduction configuration error is possible, and support is self-defined to need sequence The attribute of rowization supports a variety of fundamental types and customization type, realizes that simple, treatment effeciency is high, extension is convenient.
Below for sequencing method, the present invention provides a kind of application scenarios convenient for being illustrated to sequencing method:
1. add serialization information
In this step, it is necessary to which a kind of describing mode of structuring needs the class that serializes and attribute to explain:
Code snippet above has explained the class of a serializability using@Serializable, and to each field It is serialized and explained using@SerializableAttribute, the information for needing to use in some serializings is in@ It is listed behind SerializableAttribute using list ,@Serializable ,@SerializableAttribute are Customized note.
@Serializable notes may act on general category, can also act on and generate class by succession mode.
@SerializableAttribute notes may act on the fundamental types such as int, float and array, can also make For customization types such as String, Date;This note can add parameter, including:Optional parameters index, for collating sequence Change the order of field;Optional parameters maxLen, for specifying this attribute at most occupies how many byte in byte stream;Optional parameters Encoding, for specifying the coding mode that this attribute is used in serializing.
2. preloading sequence information
It is right in could afterwards the step of, it is necessary to analyze the serialization information in class file before serializing/antitone sequence Object serialize/unserializing, while by the result cache after analysis to memory, improves the treatment effeciency of serializing.Tool Body step
2.1 search for all classes that@Serializable are explained in class.path;
All@SerializableAttribute comment fields of 2.2 search in the class come is searched out in 2.1;
2.3 obtain the serialization informations such as the type that next each attribute is searched out in 2.2 and sequence number, length, coding, if Attribute is declared as privately owned, other classes cannot be accessed directly, can search corresponding get set methods, substituted using function call Common assignment statement.
The serialization informations such as 2.4 field types are put into caching.
3. serializing operation
3.1 obtain the attribute of object successively, and sequentially sort.
Corresponding serialization information is searched in the 3.2 serialization information cachings preloaded in step 2 using attribute name.
3.3 according to serialization information and attribute type, by fundamental type property value Formatting Output to byte sequence or Customization type is decomposed into fundamental type and according to the Formatting Outputs such as sequence number, length, coding to byte sequence.
A kind of sequencing method provided by the invention, serialization information by being passed through note by serializing configuration in general category Solution expression, without additional configuration file, support static compilation inspection, reduction configuration error is possible, and support is self-defined to need sequence The attribute of rowization supports a variety of fundamental types and customization type, realizes that simple, treatment effeciency is high, extension is convenient.
It is described above for the method for serializing, lower mask body introduces unserializing method.
With reference to shown in Fig. 3, the present invention provides a kind of embodiment of unserializing method, the sequencing method includes:
S301, the annotating information for adding serializability to class and its attribute declaration in class declaration file, by common category It is denoted as serializability class.
General category herein refers to the initial data not serialized, and user can need sequence by self-defined setting The attribute of rowization, can customize serialization format, can customize the attribute for needing to serialize, can support numerous types of data, such as Fundamental types such as shaping, floating number, byte, array and by the customized type of modes, the general category bag such as inheriting, combining Attribute and attribute type information are included, common breeding can include multiple attributes for needing to serialize, and attribute here is appreciated that It is each to need sequence in general category using the description information of structuring for a series of set of attributes for needing to serialize The attribute addition serialization information of change, serialization information can include information, the users such as sequence number, length, coding can be self-defined The attribute of serializing so that serialization process is more flexible.
S302, explained in serializability class for the attribute serialized is needed to add serializability, attribute is labeled as can sequence Rowization attribute.
It is that the attribute that each needs serialize adds serialization information in general category using the description information of structuring, Serialization information includes the information such as sequence number, length, coding, such as serializes or utilize length by general category according to sequence number Degree or number etc., do not limit, and general category is marked serializability class.
S303, to serializability class, load all serializability attribute informations in category information and class and, to memory, form pre-add Carry serialization information.
Search for all classes for being labeled serializability in class.path, the attribute that can be serialized in analysis classes, The serialization information and attribute type information cache of attribute make to memory convenient for being called in serializing or unserializing With.
It should be noted that these three steps of S101, S102, S103, can be pre-configured with completion, sequence can also carried out Rowization or unserializing carry out situ configuration when operating, and have been described above, therefore not to repeat here.
S304, the content for obtaining pending byte sequence.
Corresponding serialization information is searched in the serialization information caching preloaded using attribute name in S303, according to The serialization information of preloading reads byte sequence, according to sequence of attributes information and attribute type, by the current of byte sequence Content is converted to property value according to the type of attribute.
S305, will be in the byte sequence according to the serialization information and attribute type information that are loaded in the memory Content Transformation be property value.
The content according to attribute type information is formatted, the content of formatting is stored in the instantiation In object's property value, according to serialization information and attribute type, the content of reading specific length from byte sequence, according to volume Code mode formats reading of content, is stored in property value, and Ke Yiwei can be according in serialization information in byte sequence Size reads corresponding byte number, and is converted to property value according to type.
A kind of unserializing method provided by the invention, serializing configuration is by the way that serialization information is passed through in general category Expression is explained, without additional configuration file, supports static compilation inspection, reduction configuration error is possible, supports self-defined needs The attribute of serializing supports a variety of fundamental types and customization type, realizes that simple, treatment effeciency is high, extension is convenient.
With reference to shown in Fig. 4, sequencing method of the present invention additionally provides another embodiment, and the sequencing method includes:
S401, the annotating information for adding serializability to class and its attribute declaration in class declaration file, by common category It is denoted as serializability class.
General category herein refers to the initial data not serialized, and user can need sequence by self-defined setting The attribute of rowization, can customize serialization format, can customize the attribute for needing to serialize, can support numerous types of data, such as Fundamental types such as shaping, floating number, byte, array and by the customized type of modes, the general category bag such as inheriting, combining Attribute and attribute type information are included, common breeding can include multiple attributes for needing to serialize, and attribute here is appreciated that It is each to need sequence in general category using the description information of structuring for a series of set of attributes for needing to serialize The attribute addition serialization information of change, serialization information can include information, the users such as sequence number, length, coding can be self-defined The attribute of serializing so that serialization process is more flexible.
S402, explained in serializability class for the attribute serialized is needed to add serializability, attribute is labeled as can sequence Rowization attribute.
It is that the attribute that each needs serialize adds serialization information in general category using the description information of structuring, Serialization information includes the information such as sequence number, length, coding, such as serializes or utilize length by general category according to sequence number Degree or number etc., do not limit, and general category is marked serializability class.
S403, to serializability class, load all serializability attribute informations in category information and class and, to memory, form pre-add Carry serialization information.
Search for all classes for being labeled serializability in class.path, the attribute that can be serialized in analysis classes, The serialization information and attribute type information cache of attribute make to memory convenient for being called in serializing or unserializing With.
It should be noted that these three steps of S401, S402, S403, can be pre-configured with completion, sequence can also carried out Rowization or unserializing carry out situ configuration when operating, this is not limited.
S404, the content for obtaining pending byte sequence.
According to the serialization information of preloading, byte sequence is read, according to sequence of attributes information and attribute type, by word The Current Content of section sequence is converted to property value according to the type of attribute.
S405, will be in the byte sequence according to the serialization information and attribute type information that are loaded in the memory Content Transformation be property value.
The content according to attribute type information is formatted, the content of formatting is stored in the instantiation Can be to read corresponding byte number, and root according to the size in serialization information in byte sequence in object's property value Property value is converted to according to type.
A kind of unserializing method provided by the invention, serializing configuration is by the way that serialization information is passed through in general category Expression is explained, without additional configuration file, supports static compilation inspection, reduction configuration error is possible, supports self-defined needs The attribute of serializing supports a variety of fundamental types and customization type, realizes that simple, treatment effeciency is high, extension is convenient.
For unserializing method, a kind of application scenarios are provided and are introduced:
S1, addition serialization information
The class for needing to serialize and attribute are explained using the describing mode of structuring, is specially:
Code snippet above has explained the class of a serializability using@Serializable, and to each field It is serialized and explained using@SerializableAttribute, the information for needing to use in some serializings is in@ It is listed behind SerializableAttribute using list ,@Serializable ,@SerializableAttribute are Customized note.
@Serializable notes may act on general category, can also act on and generate class by succession mode.
@SerializableAttribute notes may act on the fundamental types such as int, float and array, can also make For customization types such as String, Date;This note can add parameter, including:Optional parameters index, for collating sequence Change the order of field;Optional parameters maxLen, for specifying this attribute at most occupies how many byte in byte stream;Optional parameters Encoding, for specifying the coding mode that this attribute is used in serializing.
S2, preloading sequence information
It is right in could afterwards the step of, it is necessary to analyze the serialization information in class file before unserializing operation Object carries out unserializing, while by the result cache after analysis to memory, improves the treatment effeciency of serializing.
Step S2 specific steps:
S2.1, all classes that@Serializable are explained are searched in class.path.
All@SerializableAttribute comment fields of S2.2, search in the class come is searched out in 2.1.
S2.3, acquisition search out the serialization informations such as the type for carrying out each attribute and sequence number, length, coding in S2.2, If attribute is declared as privately owned, other classes cannot be accessed directly, can search corresponding get set methods, use function call Substitute common assignment statement.
It is S2.4, last, the serialization informations such as field type are put into caching.
S4, unserializing operation
S4.1, the attribute for obtaining object successively, and sequentially sort
Corresponding serializing letter is searched in S4.2, the serialization information preloaded in step s 2 using attribute name caching Breath
S4.3, according to serialization information and attribute type, the content of specific length is read from byte sequence, according to coding Mode formats reading of content, and formatted content is stored in property value, completes unserializing operation.
It is described above for sequencing method, serializing is provided for the sequencing method present invention also correspondence Device is specifically introduced below.
With reference to shown in Fig. 5, the present invention provides a kind of embodiment of serializing device, and the serializing device includes:
First acquisition unit 501, for adding the note of serializability to class and its attribute declaration in class declaration file General category is labeled as serializability class by information.
Preferably, the first acquisition unit 501 is additionally operable to obtain the attribute that the needs of instance object serialize successively, And the attribute is sequentially sorted.
First indexing unit 502, will for being explained in serializability class for the attribute serialized is needed to add serializability Attribute is labeled as serializability attribute.
First loading unit 503, for serializability class, loading all serializability attribute informations in category information and class To memory, preloading sequence information is formed.
Second acquisition unit 504, for obtaining the attribute for needing to serialize in instance object.
First output unit 505, for according to the serialization information and attribute type information loaded in the memory It is exported to the sequence of attributes that instance object needs serialize, and by the property value after instance object serializing To byte sequence.
Preferably, first output unit 505 is additionally operable in the serialization information caching preloaded according to attribute name Corresponding serialization information is searched, according to serialization information and attribute type information, the attribute after instance object is serialized It is worth Formatting Output to byte sequence.
Preferably, first output unit 505 be additionally operable to it is described instance object is serialized after property value use The formal mode of sequence number, length or coding is output in byte sequence.
It is described above for unserializing method, inverted sequence is provided for the sequencing method present invention also correspondence Row makeup is put, and the present invention provides a kind of embodiment of unserializing device, and the unserializing device includes:
With reference to shown in Fig. 6, a kind of embodiment of unserializing device provided by the invention, the serializing device includes:
First acquisition unit 601, for adding the note of serializability to class and its attribute declaration in class declaration file General category is labeled as serializability class by information.
First indexing unit 602, will for being explained in serializability class for the attribute serialized is needed to add serializability Attribute is labeled as serializability attribute.
First loading unit 603, for serializability class, loading all serializability attribute informations in category information and class To memory, preloading sequence information is formed.
Second acquisition unit 604, for obtaining the attribute that unserializing is needed in instance object.
First query unit 605, for according to the serialization information and attribute type information loaded in the memory Inquiry serialization information corresponding with attribute and attribute type information.
Second acquisition unit 606, for the content of pending byte sequence.
First converting unit 607, for according to the serialization information and attribute type information loaded in the memory It is property value by the Content Transformation in the byte sequence.
Preferably, first indexing unit 602 is additionally operable to obtain the attribute that the needs of instance object serialize successively, And the attribute is sequentially sorted.
Preferably, first converting unit 607 is additionally operable to the content being formatted according to attribute type information, The content of formatting is stored in the property value of the instance object.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description, The specific work process of device and unit may be referred to the corresponding process in preceding method embodiment, and details are not described herein.
In several embodiments provided herein, it should be understood that disclosed system, apparatus and method can be with It realizes by another way.For example, the apparatus embodiments described above are merely exemplary, for example, the unit Division is only a kind of division of logic function, can there is other dividing mode, such as multiple units or component in actual implementation It may be combined or can be integrated into another system or some features can be ignored or does not perform.It is another, it is shown or The mutual coupling, direct-coupling or communication connection discussed can be the indirect coupling by some interfaces, device or unit It closes or communicates to connect, can be electrical, machinery or other forms.
The unit illustrated as separating component may or may not be physically separate, be shown as unit The component shown may or may not be physical location, you can be located at a place or can also be distributed to multiple In network element.Some or all of unit therein can be selected to realize the mesh of this embodiment scheme according to the actual needs 's.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, it can also That unit is individually physically present, can also two or more units integrate in a unit.Above-mentioned integrated list The form that hardware had both may be employed in member is realized, can also be realized in the form of SFU software functional unit.
One of ordinary skill in the art will appreciate that all or part of step in the various methods of above-described embodiment is can Relevant hardware to be instructed to complete by program, which can be stored in a computer readable storage medium, storage Medium can include:Read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), disk or CD etc..
One of ordinary skill in the art will appreciate that implement the method for the above embodiments be can be with Relevant hardware is instructed to complete by program, the program can be stored in a kind of computer readable storage medium, on It can be read-only memory to state the storage medium mentioned, disk or CD etc..
Detailed Jie has been carried out to a kind of sequencing method provided by the present invention, unserializing method and relevant device above It continues, for those of ordinary skill in the art, according to the thought of the embodiment of the present invention, in specific embodiments and applications There will be changes, in conclusion this specification content should not be construed as limiting the invention.

Claims (14)

1. a kind of sequencing method, which is characterized in that the sequencing method includes:
To the annotating information of class and its attribute declaration addition serializability in class declaration file, general category is labeled as can sequence Change class;
It is explained in serializability class for the attribute serialized is needed to add serializability, attribute is labeled as serializability attribute;
To serializability class, load all serializability attribute informations in category information and class and, to memory, form preloading sequence Information;
Serialization information, which is obtained in instance object, needs the attribute serialized;
The serialization information and attribute type information according to being loaded in the memory need sequence to the instance object The sequence of attributes of change, and the property value after instance object serializing is exported to byte sequence.
2. according to the method described in claim 1, it is characterized in that, need the category serialized in the acquisition instance object In property, the method specifically includes:
The attribute that the needs of instance object serialize is obtained successively, and the attribute is sequentially sorted.
3. according to the method described in claim 1, it is characterized in that, according to the serialization information loaded in the memory The sequence of attributes that instance object needs are serialized with attribute type information, and the instance object is serialized Property value afterwards is exported into byte sequence, and the method specifically includes:
Search corresponding serialization information in the serialization information caching preloaded according to attribute name, according to serialization information and Attribute type information, property value Formatting Output after instance object is serialized to byte sequence.
4. according to the method described in claim 1, it is characterized in that, the property value formatting after instance object is serialized is defeated Go out into byte sequence, the method specifically includes:
It is described instance object is serialized after property value byte is output to using the formal mode of sequence number, length or coding In sequence.
A kind of 5. unserializing method, which is characterized in that the sequencing method includes:
To the annotating information of class and its attribute declaration addition serializability in class declaration file, general category is labeled as can sequence Change class;
It is explained in serializability class for the attribute serialized is needed to add serializability, attribute is labeled as serializability attribute;
To serializability class, load all serializability attribute informations in category information and class and, to memory, form preloading sequence Information;
According to preloading sequence information, all serializability attributes in pending byte sequence are obtained, and it is suitable according to serializing Sequence sorts;
Obtain the content of pending byte sequence;
The content in the byte sequence is turned according to the serialization information and attribute type information loaded in the memory It is changed to property value.
6. according to the method described in claim 5, it is characterized in that, need the category serialized in the acquisition instance object In property, the method specifically includes:
The attribute that the needs of instance object serialize is obtained successively, and the attribute is sequentially sorted.
7. according to the method described in claim 5, it is characterized in that, it is property value by the Content Transformation in the byte sequence In, the method specifically includes:
And be formatted the content according to attribute type information, by the content deposit instance object of formatting In property value.
8. a kind of serializing device, which is characterized in that the serializing device includes:
First acquisition unit, for obtaining attribute and the attribute type information that the needs of general category serialize;
First indexing unit, for by described the attribute that serializes being needed to add seriation description information, so that by general category Labeled as serializability class;
First loading unit, for loading the serialization information and attribute type information to memory;
Second acquisition unit, for obtaining the attribute for needing to serialize in instance object;
First output unit, for according to the serialization information and attribute type information loaded in the memory to the reality The sequence of attributes that exampleization object needs serialize, and the property value after instance object serializing is exported to syllable sequence Row.
9. device according to claim 8, which is characterized in that the first acquisition unit is additionally operable to obtain instantiation successively The attribute that the needs of object serialize, and the attribute is sequentially sorted.
10. device according to claim 8, which is characterized in that first output unit is additionally operable to according to attribute name Corresponding serialization information is searched in the serialization information caching of preloading, it, will according to serialization information and attribute type information Property value Formatting Output after instance object serializing is to byte sequence.
11. device according to claim 8, which is characterized in that first output unit is additionally operable to described by instantiation Property value after object serialization is output to using the formal mode of sequence number, length or coding in byte sequence.
12. a kind of unserializing device, which is characterized in that the serializing device includes:
First acquisition unit, for obtaining attribute and the attribute type information that the needs of general category serialize;
First indexing unit, for by described the attribute that serializes being needed to add seriation description information, so that by general category Labeled as serializability class;
First loading unit, for loading the serialization information and attribute type information to memory;
Second acquisition unit, for the content of pending byte sequence;
First converting unit, for according to the serialization information and attribute type information loaded in the memory by the word It is property value to save the Content Transformation in sequence.
13. device according to claim 12, which is characterized in that first indexing unit is additionally operable to obtain example successively Change the attribute that the needs of object serialize, and the attribute is sequentially sorted.
14. device according to claim 12, which is characterized in that first converting unit be additionally operable to by the content by It is formatted according to attribute type information, it will be in the property value of the content deposit instance object of formatting.
CN201410712481.9A 2014-11-28 2014-11-28 A kind of sequencing method, unserializing method and relevant device Active CN104360865B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410712481.9A CN104360865B (en) 2014-11-28 2014-11-28 A kind of sequencing method, unserializing method and relevant device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410712481.9A CN104360865B (en) 2014-11-28 2014-11-28 A kind of sequencing method, unserializing method and relevant device

Publications (2)

Publication Number Publication Date
CN104360865A CN104360865A (en) 2015-02-18
CN104360865B true CN104360865B (en) 2018-05-18

Family

ID=52528129

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410712481.9A Active CN104360865B (en) 2014-11-28 2014-11-28 A kind of sequencing method, unserializing method and relevant device

Country Status (1)

Country Link
CN (1) CN104360865B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107038022B (en) * 2015-07-13 2021-01-29 阿里巴巴集团控股有限公司 Deserialization method and deserialization device
CN106570018B (en) * 2015-10-10 2021-01-15 阿里巴巴集团控股有限公司 Serialization and deserialization method, device and system and electronic equipment
CN106648569B (en) * 2015-11-02 2021-04-20 腾讯科技(深圳)有限公司 Target serialization realization method and device
CN106843819B (en) * 2015-12-03 2020-10-09 北京国双科技有限公司 Object serialization method and device
CN106933644A (en) * 2015-12-31 2017-07-07 北京国双科技有限公司 Data processing method and device
CN105468793B (en) * 2016-01-20 2019-02-22 北京华如科技股份有限公司 A kind of automatic management method of simulation model data
CN107818118B (en) 2016-09-14 2019-04-30 北京百度网讯科技有限公司 Date storage method and device
CN106843851A (en) * 2016-12-28 2017-06-13 上海大汉三通数据通信有限公司 Implementation method and device based on ActiveMQ isomery Classloader unserializings
CN107451237B (en) * 2017-07-26 2020-09-15 阿里巴巴集团控股有限公司 Serialization and deserialization method, device and equipment
CN107463668B (en) * 2017-08-02 2019-03-26 湖南新航动力信息科技有限公司 Method and device, computer equipment and the storage medium of serializing and unserializing
CN108876628A (en) * 2018-06-28 2018-11-23 深圳数字动能信息技术有限公司 Financial quantitative analysis data transmission method
WO2020000484A1 (en) * 2018-06-30 2020-01-02 华为技术有限公司 Deserialization method, apparatus, and computing device
CN111611235A (en) * 2020-05-27 2020-09-01 华中师范大学 Student space-time model based on campus WiFi big data and data cleaning method
CN111930531B (en) * 2020-07-01 2023-08-18 北京奇艺世纪科技有限公司 Data processing, data production and data consumption methods, devices, equipment and media
CN111931200B (en) * 2020-07-13 2024-02-23 车智互联(北京)科技有限公司 Data serialization method, mobile terminal and readable storage medium
JP7253172B2 (en) * 2021-04-30 2023-04-06 株式会社ソフトギア Serialization method, deserialization method, information processing program, information processing apparatus, and communication system
CN114500647B (en) * 2022-01-18 2023-07-11 聚好看科技股份有限公司 Data transmission method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567083A (en) * 2010-12-10 2012-07-11 金蝶软件(中国)有限公司 Object transmission method, object transmission device and object transmission system applying RPC (remote procedure call)
CN102750268A (en) * 2012-06-19 2012-10-24 山东中创软件商用中间件股份有限公司 Object serializing method as well as object de-serializing method, device and system
CN103036641A (en) * 2011-09-29 2013-04-10 北京新媒传信科技有限公司 Method and system of data exchange and deserialization method
CN103425632A (en) * 2013-08-30 2013-12-04 深圳市路畅科技股份有限公司 Serializing method, device and processor
CN103593194A (en) * 2013-11-21 2014-02-19 北京国双科技有限公司 Object serialization method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567083A (en) * 2010-12-10 2012-07-11 金蝶软件(中国)有限公司 Object transmission method, object transmission device and object transmission system applying RPC (remote procedure call)
CN103036641A (en) * 2011-09-29 2013-04-10 北京新媒传信科技有限公司 Method and system of data exchange and deserialization method
CN102750268A (en) * 2012-06-19 2012-10-24 山东中创软件商用中间件股份有限公司 Object serializing method as well as object de-serializing method, device and system
CN103425632A (en) * 2013-08-30 2013-12-04 深圳市路畅科技股份有限公司 Serializing method, device and processor
CN103593194A (en) * 2013-11-21 2014-02-19 北京国双科技有限公司 Object serialization method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
未标记为可序列化什么意思呢?类的序列化[Serializable];onlyou930;《blog.csdn.net/onlyou930/article/details/5566532》;20100507;第4节(基本序列化)、第5节(选择性序列化)、第6节(自定义序列化) *

Also Published As

Publication number Publication date
CN104360865A (en) 2015-02-18

Similar Documents

Publication Publication Date Title
CN104360865B (en) A kind of sequencing method, unserializing method and relevant device
Oesper et al. WordCloud: a Cytoscape plugin to create a visual semantic summary of networks
JP4213378B2 (en) Method and system for mapping strings for comparison
US8935575B2 (en) Test data generation
CN104753540B (en) Data compression method, data decompression method and apparatus
CN109284145A (en) The generation of multilingual configuration file and methods of exhibiting and device, equipment and medium
CN102750268A (en) Object serializing method as well as object de-serializing method, device and system
WO2017189026A1 (en) System and method for querying a graph model
CN101620636B (en) Method and apparatus for displaying tabular data
CN108369497B (en) Learning from input patterns in example programming
CN109614329B (en) Software test case aided design method based on interface control file
JP2009003541A (en) Index preparation system, method and program for database
CN108829884B (en) Data mapping method and device
US20100251227A1 (en) Binary resource format and compiler
CN104969188A (en) A method for modeling source code having code segments that lack source location
CN105706092A (en) Methods and systems of four-valued simulation
CN107895018A (en) Database update SQL generation methods, system, storage medium and computer equipment
CN107066246A (en) A kind of software development methodology and device
CN107133263A (en) POI recommends method, device, equipment and computer-readable recording medium
CN114090671A (en) Data import method and device, electronic equipment and storage medium
KR20210121921A (en) Method and device for extracting key keywords based on keyword joint appearance network
CN115525580A (en) Namespace setting method and device and readable storage medium
EP3193260A2 (en) Encoding program, encoding method, encoding device, decoding program, decoding method, and decoding device
CN110347673A (en) Data file loading method, device, computer equipment and storage medium
CN101770367A (en) Compressing method and compressing device of .NET file

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant