Ticket #88 (assigned enhancement)

Opened 3 years ago

Last modified 2 years ago

Simplify sequence node naming and manipulation in script

Reported by: dumoulin Owned by: dumoulin
Priority: normal Milestone: 0.4
Component: core Version:
Severity: normal Keywords:
Cc:

Description (last modified by dumoulin) (diff)

A sequence node is named by its nested node (recursively if it is a sequence node). For example, if I create such a structure :

ComplexNode : "myStructure"
  \__ SequenceNode
        \___ ComplexNode : "element"
                 \___ Prototype : "value" : Integer

The corresponding class is generated :

public class CmyStructure implements DataContainer, DataModifier {
  public List<CmyStructureCelement> element = [];

  @Override
  public Object getValue(String name) {
    return this[name];
  }
  @Override
  public void setValue(String name, Object value) {
    this[name] = value;
  }
}

Well. First, the naming of the sequence node is ambiguous : your inner node is singular, so you wan't use a plural form, and give the name "element". But, the attribute is a sequence and a plural form ("elements" in this exemple) would be more appropriate.

Then, we need a convenient way to populate the sequence with new elements, or else, user should populate the list like this :

myStructure.element[i] = new org.simexplorer.user.data.CmyStructureCelement();

Change History

  Changed 3 years ago by dumoulin

  • description modified (diff)

follow-up: ↓ 3   Changed 3 years ago by dumoulin

  • description modified (diff)

With r1796, an additional method is generate for each SequenceNode, and looks like :

  public CInputRootCelement newelement() {
    return new CInputRootCelement()
  }

It works fine with nested SequenceNode too.

in reply to: ↑ 2   Changed 3 years ago by dumoulin

Replying to dumoulin:

public CInputRootCelement newelement() {

You should read :

public CmyStructureCelement newelement() {

  Changed 3 years ago by dumoulin

  • milestone set to 0.3

  Changed 2 years ago by dumoulin

  • milestone changed from 0.3 to 0.4

  Changed 2 years ago by dumoulin

  • status changed from new to assigned

Debate about singular or plural form is closed, as we won't decide anything about that.

The method to populate the list created should be implemented. Before to close this ticket, please add an code example.

Note: See TracTickets for help on using tickets.

logo cemagref

logo iscpif

logo lifegrid

logo region auvergne

logo patres project