You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Dmitry Mamonov (JIRA)" <ji...@apache.org> on 2009/10/09 14:29:31 UTC

[jira] Created: (PIVOT-324) WTKXSerializer get method enhancement

WTKXSerializer get method enhancement
-------------------------------------

                 Key: PIVOT-324
                 URL: https://issues.apache.org/jira/browse/PIVOT-324
             Project: Pivot
          Issue Type: Improvement
          Components: wtk-wtkx
    Affects Versions: 1.3
            Reporter: Dmitry Mamonov


Method get() of class WTKXSerializer returns value of type Object, you see:
http://incubator.apache.org/pivot/1.3/docs/api/org/apache/pivot/wtkx/WTKXSerializer.html#get(java.lang.String)

As demostrated in documentation it cause code like this: (http://incubator.apache.org/pivot/1.3/tutorials/push_buttons.html)
  private PushButton pushButton = null;
   ...
  pushButton = (PushButton)wtkxSerializer.get("pushButton");

In an alternative way, get() method may be declared as:
  <T> T get(String key){
     //implementation
  }

This way client code will be just:
  pushButton = wtkxSerializer.get("pushButton");

so the type-case will be implicit. This feature is widely used in HtmlUnit framework and I find it quite neat.
May be it coult be adopted to pivot project :)



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (PIVOT-324) WTKXSerializer get method enhancement

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown resolved PIVOT-324.
------------------------------

    Resolution: Fixed

I added the typed getValue() method, but I skipped the change to readObject(). I think that adding a type parameter to some readObject() overloads but not others could be confusing.


> WTKXSerializer get method enhancement
> -------------------------------------
>
>                 Key: PIVOT-324
>                 URL: https://issues.apache.org/jira/browse/PIVOT-324
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk-wtkx
>            Reporter: Dmitry Mamonov
>            Assignee: Greg Brown
>            Priority: Minor
>             Fix For: 1.4
>
>
> Method get() of class WTKXSerializer returns value of type Object, you see:
> http://incubator.apache.org/pivot/1.3/docs/api/org/apache/pivot/wtkx/WTKXSerializer.html#get(java.lang.String)
> As demostrated in documentation it cause code like this: (http://incubator.apache.org/pivot/1.3/tutorials/push_buttons.html)
>   private PushButton pushButton = null;
>    ...
>   pushButton = (PushButton)wtkxSerializer.get("pushButton");
> In an alternative way, get() method may be declared as:
>   <T> T get(String key){
>      //implementation
>   }
> This way client code will be just:
>   pushButton = wtkxSerializer.get("pushButton");
> so the type-case will be implicit. This feature is widely used in HtmlUnit framework and I find it quite neat.
> May be it coult be adopted to pivot project :)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIVOT-324) WTKXSerializer get method enhancement

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown updated PIVOT-324:
-----------------------------


We could additionally define readObject() as follows:

public <T> T readObject(URL location) {
  ...
}

With the exception of readObject(InputStream):Object, which is defined by the Serializer<Object> interface to return Object, this would also allow callers to assign the return value of this method without the need for a cast.


> WTKXSerializer get method enhancement
> -------------------------------------
>
>                 Key: PIVOT-324
>                 URL: https://issues.apache.org/jira/browse/PIVOT-324
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk-wtkx
>            Reporter: Dmitry Mamonov
>            Assignee: Greg Brown
>            Priority: Minor
>             Fix For: 1.4
>
>
> Method get() of class WTKXSerializer returns value of type Object, you see:
> http://incubator.apache.org/pivot/1.3/docs/api/org/apache/pivot/wtkx/WTKXSerializer.html#get(java.lang.String)
> As demostrated in documentation it cause code like this: (http://incubator.apache.org/pivot/1.3/tutorials/push_buttons.html)
>   private PushButton pushButton = null;
>    ...
>   pushButton = (PushButton)wtkxSerializer.get("pushButton");
> In an alternative way, get() method may be declared as:
>   <T> T get(String key){
>      //implementation
>   }
> This way client code will be just:
>   pushButton = wtkxSerializer.get("pushButton");
> so the type-case will be implicit. This feature is widely used in HtmlUnit framework and I find it quite neat.
> May be it coult be adopted to pivot project :)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-324) WTKXSerializer get method enhancement

Posted by "Dmitry Mamonov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12764046#action_12764046 ] 

Dmitry Mamonov commented on PIVOT-324:
--------------------------------------

About warning,

    @SuppressWarnings("unchecked")
    public <T> T getValue(String name) {
        return (T)get(name);
    } 

yes, in HtmlUnit methods declared exactly same:

package com.gargoylesoftware.htmlunit.html;
....
public abstract class HtmlElement extends DomElement {
.....
    /**
     * Simulates clicking on this element, returning the page in the window that has the focus
     * after the element has been clicked. Note that the returned page may or may not be the same
     * as the original page, depending on the type of element being clicked, the presence of JavaScript
     * action listeners, etc.
     *
     * @param <P> the page type
     * @return the page that occupies this element's window after the element has been clicked
     * @exception IOException if an IO error occurs
     */
    @SuppressWarnings("unchecked")
    public <P extends Page> P click() throws IOException {
        return (P) click(false, false, false);
    }

> WTKXSerializer get method enhancement
> -------------------------------------
>
>                 Key: PIVOT-324
>                 URL: https://issues.apache.org/jira/browse/PIVOT-324
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk-wtkx
>            Reporter: Dmitry Mamonov
>            Assignee: Greg Brown
>            Priority: Minor
>             Fix For: 1.4
>
>
> Method get() of class WTKXSerializer returns value of type Object, you see:
> http://incubator.apache.org/pivot/1.3/docs/api/org/apache/pivot/wtkx/WTKXSerializer.html#get(java.lang.String)
> As demostrated in documentation it cause code like this: (http://incubator.apache.org/pivot/1.3/tutorials/push_buttons.html)
>   private PushButton pushButton = null;
>    ...
>   pushButton = (PushButton)wtkxSerializer.get("pushButton");
> In an alternative way, get() method may be declared as:
>   <T> T get(String key){
>      //implementation
>   }
> This way client code will be just:
>   pushButton = wtkxSerializer.get("pushButton");
> so the type-case will be implicit. This feature is widely used in HtmlUnit framework and I find it quite neat.
> May be it coult be adopted to pivot project :)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIVOT-324) WTKXSerializer get method enhancement

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown updated PIVOT-324:
-----------------------------

             Priority: Minor  (was: Major)
    Affects Version/s:     (was: 1.3)
        Fix Version/s: 1.4

> WTKXSerializer get method enhancement
> -------------------------------------
>
>                 Key: PIVOT-324
>                 URL: https://issues.apache.org/jira/browse/PIVOT-324
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk-wtkx
>            Reporter: Dmitry Mamonov
>            Assignee: Greg Brown
>            Priority: Minor
>             Fix For: 1.4
>
>
> Method get() of class WTKXSerializer returns value of type Object, you see:
> http://incubator.apache.org/pivot/1.3/docs/api/org/apache/pivot/wtkx/WTKXSerializer.html#get(java.lang.String)
> As demostrated in documentation it cause code like this: (http://incubator.apache.org/pivot/1.3/tutorials/push_buttons.html)
>   private PushButton pushButton = null;
>    ...
>   pushButton = (PushButton)wtkxSerializer.get("pushButton");
> In an alternative way, get() method may be declared as:
>   <T> T get(String key){
>      //implementation
>   }
> This way client code will be just:
>   pushButton = wtkxSerializer.get("pushButton");
> so the type-case will be implicit. This feature is widely used in HtmlUnit framework and I find it quite neat.
> May be it coult be adopted to pivot project :)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-324) WTKXSerializer get method enhancement

Posted by "Todd Volkert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12764008#action_12764008 ] 

Todd Volkert commented on PIVOT-324:
------------------------------------

Yeah I think such a method would provide value.

> WTKXSerializer get method enhancement
> -------------------------------------
>
>                 Key: PIVOT-324
>                 URL: https://issues.apache.org/jira/browse/PIVOT-324
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk-wtkx
>            Reporter: Dmitry Mamonov
>            Assignee: Greg Brown
>            Priority: Minor
>             Fix For: 1.4
>
>
> Method get() of class WTKXSerializer returns value of type Object, you see:
> http://incubator.apache.org/pivot/1.3/docs/api/org/apache/pivot/wtkx/WTKXSerializer.html#get(java.lang.String)
> As demostrated in documentation it cause code like this: (http://incubator.apache.org/pivot/1.3/tutorials/push_buttons.html)
>   private PushButton pushButton = null;
>    ...
>   pushButton = (PushButton)wtkxSerializer.get("pushButton");
> In an alternative way, get() method may be declared as:
>   <T> T get(String key){
>      //implementation
>   }
> This way client code will be just:
>   pushButton = wtkxSerializer.get("pushButton");
> so the type-case will be implicit. This feature is widely used in HtmlUnit framework and I find it quite neat.
> May be it coult be adopted to pivot project :)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (PIVOT-324) WTKXSerializer get method enhancement

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown resolved PIVOT-324.
------------------------------

    Resolution: Won't Fix
      Assignee: Greg Brown

We have tried this in the past, and unfortunately, it doesn't work.  :-)  WTKXSerializer implements Dictionary<String, Object>, which requires the get() signature to return an Object, not a T.


> WTKXSerializer get method enhancement
> -------------------------------------
>
>                 Key: PIVOT-324
>                 URL: https://issues.apache.org/jira/browse/PIVOT-324
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk-wtkx
>    Affects Versions: 1.3
>            Reporter: Dmitry Mamonov
>            Assignee: Greg Brown
>
> Method get() of class WTKXSerializer returns value of type Object, you see:
> http://incubator.apache.org/pivot/1.3/docs/api/org/apache/pivot/wtkx/WTKXSerializer.html#get(java.lang.String)
> As demostrated in documentation it cause code like this: (http://incubator.apache.org/pivot/1.3/tutorials/push_buttons.html)
>   private PushButton pushButton = null;
>    ...
>   pushButton = (PushButton)wtkxSerializer.get("pushButton");
> In an alternative way, get() method may be declared as:
>   <T> T get(String key){
>      //implementation
>   }
> This way client code will be just:
>   pushButton = wtkxSerializer.get("pushButton");
> so the type-case will be implicit. This feature is widely used in HtmlUnit framework and I find it quite neat.
> May be it coult be adopted to pivot project :)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (PIVOT-324) WTKXSerializer get method enhancement

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown reopened PIVOT-324:
------------------------------


However, we could add a method such as this:

    @SuppressWarnings("unchecked")
    public <T> T getValue(String name) {
        return (T)get(name);
    }

Comments?


> WTKXSerializer get method enhancement
> -------------------------------------
>
>                 Key: PIVOT-324
>                 URL: https://issues.apache.org/jira/browse/PIVOT-324
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk-wtkx
>            Reporter: Dmitry Mamonov
>            Assignee: Greg Brown
>             Fix For: 1.4
>
>
> Method get() of class WTKXSerializer returns value of type Object, you see:
> http://incubator.apache.org/pivot/1.3/docs/api/org/apache/pivot/wtkx/WTKXSerializer.html#get(java.lang.String)
> As demostrated in documentation it cause code like this: (http://incubator.apache.org/pivot/1.3/tutorials/push_buttons.html)
>   private PushButton pushButton = null;
>    ...
>   pushButton = (PushButton)wtkxSerializer.get("pushButton");
> In an alternative way, get() method may be declared as:
>   <T> T get(String key){
>      //implementation
>   }
> This way client code will be just:
>   pushButton = wtkxSerializer.get("pushButton");
> so the type-case will be implicit. This feature is widely used in HtmlUnit framework and I find it quite neat.
> May be it coult be adopted to pivot project :)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.