You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by "Kevin Brown (JIRA)" <ji...@apache.org> on 2008/06/05 02:01:45 UTC

[jira] Created: (SHINDIG-340) Support msg elements as children of Locale elements

Support msg elements as children of Locale elements
---------------------------------------------------

                 Key: SHINDIG-340
                 URL: https://issues.apache.org/jira/browse/SHINDIG-340
             Project: Shindig
          Issue Type: Sub-task
            Reporter: Kevin Brown
            Assignee: Kevin Brown




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


[jira] Closed: (SHINDIG-340) Support msg elements as children of Locale elements

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

Kevin Brown closed SHINDIG-340.
-------------------------------

    Resolution: Fixed

Applied with modifications. Thank you!

> Support msg elements as children of Locale elements
> ---------------------------------------------------
>
>                 Key: SHINDIG-340
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-340
>             Project: Shindig
>          Issue Type: Sub-task
>            Reporter: Kevin Brown
>            Assignee: Kevin Brown
>         Attachments: new-feature-SHINDIG-340.patch
>
>


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


[jira] Commented: (SHINDIG-340) Support msg elements as children of Locale elements

Posted by "Gonzalo Aune (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12603172#action_12603172 ] 

Gonzalo Aune commented on SHINDIG-340:
--------------------------------------

Dont worry, ill do the modifications and attach it to the issue =), thanks a lot!

> Support msg elements as children of Locale elements
> ---------------------------------------------------
>
>                 Key: SHINDIG-340
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-340
>             Project: Shindig
>          Issue Type: Sub-task
>            Reporter: Kevin Brown
>            Assignee: Kevin Brown
>         Attachments: new-feature-SHINDIG-340.patch
>
>


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


[jira] Updated: (SHINDIG-340) Support msg elements as children of Locale elements

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

Gonzalo Aune updated SHINDIG-340:
---------------------------------

    Attachment: new-feature-SHINDIG-340-v2.patch

New patch with Kevin's adds and fixed the toString method which was wrong in the first patch because i wasnt using the toString of MessageBundle. Thanks!  

> Support msg elements as children of Locale elements
> ---------------------------------------------------
>
>                 Key: SHINDIG-340
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-340
>             Project: Shindig
>          Issue Type: Sub-task
>            Reporter: Kevin Brown
>            Assignee: Kevin Brown
>         Attachments: new-feature-SHINDIG-340-v2.patch, new-feature-SHINDIG-340.patch
>
>


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


[jira] Commented: (SHINDIG-340) Support msg elements as children of Locale elements

Posted by "Gonzalo Aune (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12603344#action_12603344 ] 

Gonzalo Aune commented on SHINDIG-340:
--------------------------------------

Sorry, i didnt see your comment, i was writing this message when you closed the issue.

> Support msg elements as children of Locale elements
> ---------------------------------------------------
>
>                 Key: SHINDIG-340
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-340
>             Project: Shindig
>          Issue Type: Sub-task
>            Reporter: Kevin Brown
>            Assignee: Kevin Brown
>         Attachments: new-feature-SHINDIG-340-v2.patch, new-feature-SHINDIG-340.patch
>
>


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


[jira] Updated: (SHINDIG-340) Support msg elements as children of Locale elements

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

Gonzalo Aune updated SHINDIG-340:
---------------------------------

    Attachment: new-feature-SHINDIG-340.patch

This patch adds the new feature.

> Support msg elements as children of Locale elements
> ---------------------------------------------------
>
>                 Key: SHINDIG-340
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-340
>             Project: Shindig
>          Issue Type: Sub-task
>            Reporter: Kevin Brown
>            Assignee: Kevin Brown
>         Attachments: new-feature-SHINDIG-340.patch
>
>


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


[jira] Commented: (SHINDIG-340) Support msg elements as children of Locale elements

Posted by "Gonzalo Aune (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12603159#action_12603159 ] 

Gonzalo Aune commented on SHINDIG-340:
--------------------------------------

Im sorry Kevin, but i dont fully understand the second part of your comment. Could you be more specific?, thanks a lot!

> Support msg elements as children of Locale elements
> ---------------------------------------------------
>
>                 Key: SHINDIG-340
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-340
>             Project: Shindig
>          Issue Type: Sub-task
>            Reporter: Kevin Brown
>            Assignee: Kevin Brown
>         Attachments: new-feature-SHINDIG-340.patch
>
>


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


[jira] Commented: (SHINDIG-340) Support msg elements as children of Locale elements

Posted by "Kevin Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12603129#action_12603129 ] 

Kevin Brown commented on SHINDIG-340:
-------------------------------------

Thanks for the patch, Gonzalo, but this isn't quite right. -- the nested elements of Locale are "msg", not "messagebundle" (messagebundle is the root element of an external message bundle).

The cleanest thing would probably be for MessageBundle to take an Element as a ctor, and then have the current string-based ctor call that with the parsed element while LocaleSpec would pass itself to create the bundles.

> Support msg elements as children of Locale elements
> ---------------------------------------------------
>
>                 Key: SHINDIG-340
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-340
>             Project: Shindig
>          Issue Type: Sub-task
>            Reporter: Kevin Brown
>            Assignee: Kevin Brown
>         Attachments: new-feature-SHINDIG-340.patch
>
>


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


[jira] Commented: (SHINDIG-340) Support msg elements as children of Locale elements

Posted by "Kevin Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12603171#action_12603171 ] 

Kevin Brown commented on SHINDIG-340:
-------------------------------------

Sorry for not being clear.

I think you can simplify your patch a lot by adding this ctor to MessageBundle

public MessageBundle(Element element) {
  messages = extractMessages(element);
}

Modify the existing one as follows:

public MessageBundle(URI url, String xml) throws SpecParserException {
    Element doc;
    try {
      doc = XmlUtil.parse(xml);
    } catch (XmlException e) {
      throw new SpecParserException("Malformed XML in file " + url.toString()
          + ": " + e.getMessage());
    }

   messages = extractMessages(doc);
  }
}

and add this method (moving the functionality out of the existing ctor):

private Map<String, String> extractMessages(Element doc) {
 NodeList nodes = doc.getElementsByTagName("msg");
    Map<String, String> messages
        = new HashMap<String, String>(nodes.getLength(), 1);

    for (int i = 0, j = nodes.getLength(); i < j; ++i) {
      Element msg = (Element)nodes.item(i);
      String name = XmlUtil.getAttribute(msg, "name");
      if (name == null) {
        throw new SpecParserException(
            "All message bundle entries must have a name attribute.");
      }
      messages.put(name, msg.getTextContent().trim());
    }
    return Collections.unmodifiableMap(messages);
}

This would allow LocaleSpec's ctor to simply do:

if (messages == null) {
  this.messages = URI.create("");
  this.messageBundle = new MessageBundle(element);
}

All told, it's about half as much code change as would be required in the current patch.

Does that make sense?

I can go ahead and apply it with this modification if you'd like. The rest of the patch looks great.

> Support msg elements as children of Locale elements
> ---------------------------------------------------
>
>                 Key: SHINDIG-340
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-340
>             Project: Shindig
>          Issue Type: Sub-task
>            Reporter: Kevin Brown
>            Assignee: Kevin Brown
>         Attachments: new-feature-SHINDIG-340.patch
>
>


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