Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement Java Sequential Interface

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "how to implement the Java sequential interface". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Order is an ordered collection of settings (settings). Each entry in the sequence has an index.

The key point of order is that the order of settings can be saved, and settings that span multiple different attributes can also be saved. Therefore, if attribute An is updated, then attribute B is updated, and finally attribute An is updated, an order can reflect the process.

Each setting is a property and value pair. For the SDO text property, there is a shortcut to use the text.

Unstructured text

Using the SDO text property, unstructured text can be added in order. The add (String text) method uses the SDO text property to add a new entry to the end of the order. The add (int index, String text) method uses the SDO text property to add a new entry to the specified index location in the order.

Use order

Order is often used when dealing with semi-structured business data, such as XML elements mixed with text. Suppose an order has two multi-valued attributes, numbers (integer attribute) and letters (string attribute). At the same time, suppose the order is initialized as follows:

A value of 1 is added to the numbers attribute.

The string annotation text is added to the order.

The value An is added to the letters attribute.

A value of 2 is added to the numbers attribute.

The value B is added to the letters attribute.

After initialization, the order contains the following settings:

{,}

The numbers property is set to {1,2}, and the letters property will be set to {"A", "B"}, but if you just use the accessors instead of the order, you will not be able to get the setting order across the numbers property and the letters property.

Comparison of order and data objects

The way in which data objects track the order of attributes and values is very different from that used by Sequence.

The data object does not save the order between the different attributes added to it. In the case of a multi-valued attribute, the order added to the different values of the attribute can be saved, but when the value is added to two different attributes, there is no way to know which property is set first. The order in which multiple attributes are set can be saved in one order.

The same properties that appear in the Sequence can also be obtained through the data object, but the data object does not hold the order in which multiple property settings are saved (order).

Note that if the type of the data object is a sequential type (that is, the return value of getType (). IsSequenced () is true), then the data object will have a Sequence (Sequence).

The method of order:

The size () method returns the number of entries in order.

The getProperty (int index) accessor returns the property of the specified index location.

The getValue (int index) accessor returns the value of the specified index location.

The setValue (int index, Object value) accessor updates the value of the specified index location and maintains the location of the order.

The Boolean add () accessor is added to the end of the order.

The add (int index, String text) accessor adds unstructured text at the specified index location.

The add (String text) accessor adds unstructured text to the end of the order.

Other add (int index) accessors add a specific location to the order, like java.util.List, adding one in turn to the interfaces at subsequent locations.

The remove () method removes the entry at the specified index location and decrements the index of the position after it by one in turn.

The move () method removes the entrance from fromIndex to toIndex.

To create a data object at the end of the order, you can use the create () method of the data object.

Sequential interface

Public interface Sequence

{

Int size ()

Property getProperty (int index)

Object getValue (int index)

Object setValue (int index, Object value)

Boolean add (String propertyName, Object value)

Boolean add (int propertyIndex, Object value)

Boolean add (Property property, Object value)

Void add (int index, String propertyName, Object value)

Void add (int index, int propertyIndex, Object value)

Void add (int index, Property property, Object value)

Void add (int index, String text)

Void add (String text)

Void remove (int index)

Void move (int toIndex, int fromIndex)

}

This is the end of the content of "how to implement the Java Sequential Interface". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report