Projects tigase _server tigase-xmltools Issues #18
Deprecate Element API based on findings from #14 (#18)
Wojciech Kapcia (Tigase) opened 6 days ago

In #14 we made extensive research into how we want to have Element API. In order to move forward we should deprecate all members that will be removed when new API from #14 is introduced.

  • Wojciech Kapcia (Tigase) changed fields 6 days ago
    Name Previous Value Current Value
    Version
    8.5.0
    4.3.0
  • Andrzej Wójcik (Tigase) commented 2 days ago

    I've deprecated methods and fields that will be removed, would have changed access level, or will have different parameter types. I did that in 4.4.0-SNAPSHOT and not in 4.3.0 as 4.3.0 is already released.

    Changes for now are in branch xmltools-18 for a review.

  • Andrzej Wójcik (Tigase) changed state to 'In QA' 2 days ago
    Previous Value Current Value
    Open
    In QA
  • Andrzej Wójcik (Tigase) changed fields 2 days ago
    Name Previous Value Current Value
    Assignee
    andrzej.wojcik
    wojtek
  • Wojciech Kapcia (Tigase) added "Related" tigase/_server/server-core#1572 17 hours ago
  • Wojciech Kapcia (Tigase) changed fields 17 hours ago
    Name Previous Value Current Value
    Version
    4.3.0
    4.4.0
  • Wojciech Kapcia (Tigase) commented 17 hours ago

    Good point about version.

    @andrzej.wojcik Are we dropping Comparator interface?

    	@Deprecated
    	@Override
    	public int compareTo(Element elem) {
    		return toStringNoChildren().compareTo(elem.toStringNoChildren());
    	}
    

    Are we dropping XMLNodeIfc interface?

    	// Deprecated due to change of parameter type from XMLNodeIfc to Element
    	@Deprecated
    	public void addChild(XMLNodeIfc child) {]
    
  • Andrzej Wójcik (Tigase) commented 17 hours ago

    We are dropping Compararor especially as order of attributes is not fixed, so comparison may be returning incorrect values.

    As for XMLNodeIfc we are going to use it internally (see addNode()) but I wouldn't expose it if possible. Children as elements as List<Element> is returned by getChildren() and CData is CData. I would keep those separate. In this particular case we would be accepting Element that implements XMLNodeIfc, but in my opinion addChild() should accept only Element.

  • Wojciech Kapcia (Tigase) added "Related" #14 16 hours ago
  • Wojciech Kapcia (Tigase) commented 16 hours ago

    We are dropping Compararor especially as order of attributes is not fixed, so comparison may be returning incorrect values.

    But attributes are just a Map<String,String> here? Pondering it - order of children in XML is significant so I don't see much point in Comparable here (?)

    As for XMLNodeIfc we are going to use it internally (see addNode()) but I wouldn't expose it if possible. Children as elements as List<Element> is returned by getChildren() and CData is CData. I would keep those separate. In this particular case we would be accepting Element that implements XMLNodeIfc, but in my opinion addChild() should accept only Element.

    +1

    From what it looks we need XMLNodeIfc just to handle CData?

    Shouldn't we also deprecate public void setAttributeStaticStr(String elementPath[], String att_name, String att_value) {} ?

  • Andrzej Wójcik (Tigase) commented 16 hours ago

    But attributes are just a Map<String,String> here? Pondering it - order of children in XML is significant so I don't see much point in Comparable here (?)

    Comparable used toStringNoChildren() that means it used just attributes for comparison even without ordering. I do not see how we could implement comparison on Element so it is more reasonable to deprecate and just leave it to the user to implement correct comparator for their use case.

    From what it looks we need XMLNodeIfc just to handle CData?

    No, we have List as each Element may have subnodes that are either CData or Element and their order mattters, ie.: <x>1<y/>2</x> is different from <x>12<y/></x> so we need CData and Element in a single list to not lose their order - for that we use XMLNodeIfc.

  • Andrzej Wójcik (Tigase) commented 16 hours ago

    Shouldn't we also deprecate public void setAttributeStaticStr(String elementPath[], String att_name, String att_value) {} ?

    I was wondering about it, but I think it may be used in many places... but sure we can deprecate it as well.

  • Wojciech Kapcia (Tigase) commented 9 hours ago

    But attributes are just a Map<String,String> here? Pondering it - order of children in XML is significant so I don't see much point in Comparable here (?)

    Comparable used toStringNoChildren() that means it used just attributes for comparison even without ordering. I do not see how we could implement comparison on Element so it is more reasonable to deprecate and just leave it to the user to implement correct comparator for their use case.

    Makes sense.

    From what it looks we need XMLNodeIfc just to handle CData?

    No, we have List as each Element may have subnodes that are either CData or Element and their order mattters, ie.: <x>1<y/>2</x> is different from <x>12<y/></x> so we need CData and Element in a single list to not lose their order - for that we use XMLNodeIfc.

    This is what I meant by " just to handle CData " :)

    Shouldn't we also deprecate public void setAttributeStaticStr(String elementPath[], String att_name, String att_value) {} ?

    I was wondering about it, but I think it may be used in many places... but sure we can deprecate it as well.

    I'd be in favour of deprecating it. If someone needs to set attribute deep inside element IMHO it's better to get that element via top-level api and then set the value via setAttribute(key,val). Basically it would result in more explicit code and less ways to do the same thing which would result in cleaner API IMHO.

issue 1 of 1
Type
New Feature
Priority
Normal
Assignee
Version
4.4.0
Sprints
n/a
Customer
n/a
Iterations
Issue Votes (0)
Watchers (3)
Reference
tigase/_server/tigase-xmltools#18
Please wait...
Page is in error, reload to recover