jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
groovy
  • groovy
  • GROOVY-5761

getBytes for GString

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.1.0-rc-1, 1.8.9, 2.0.7
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

We could add the following methods to GString:

byte[] getBytes(Charset charset)
byte[] getBytes()

which could just call toString().getBytes()

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
blackdrag blackdrag added a comment - 17/Oct/12 1:13 AM - edited

if they are methods on String, then at least from Groovy they should work without adding anything. And I just checked, this works too. So what is this about?

Show
blackdrag blackdrag added a comment - 17/Oct/12 1:13 AM - edited if they are methods on String, then at least from Groovy they should work without adding anything. And I just checked, this works too. So what is this about?
Hide
Permalink
Paul King added a comment - 17/Oct/12 1:59 PM

The original use case was from Grails (within a service I think) but I think it is a Groovy issue:

def s = "Hello Oct 18, 2012 4:54:10 AM"
println s.bytes.encodeBase64()
// => SGVsbG8gT2N0IDE4LCAyMDEyIDQ6NTQ6MTAgQU0=
def gs = "Hello ${new Date()}"
println gs.bytes.encodeBase64()
// => groovy.lang.MissingPropertyException: No such property: bytes for class: org.codehaus.groovy.runtime.GStringImpl
Show
Paul King added a comment - 17/Oct/12 1:59 PM The original use case was from Grails (within a service I think) but I think it is a Groovy issue: def s = "Hello Oct 18, 2012 4:54:10 AM" println s.bytes.encodeBase64() // => SGVsbG8gT2N0IDE4LCAyMDEyIDQ6NTQ6MTAgQU0= def gs = "Hello ${ new Date()}" println gs.bytes.encodeBase64() // => groovy.lang.MissingPropertyException: No such property: bytes for class: org.codehaus.groovy.runtime.GStringImpl
Hide
Permalink
Pascal Schumacher added a comment - 31/Dec/12 10:45 AM

I created a pull request https://github.com/groovy/groovy-core/pull/99 for this.

The method "byte[] getBytes(Charset charset)" isn't in JDK 1.5 so I added "byte[] getBytes(String charset)" instead.

Show
Pascal Schumacher added a comment - 31/Dec/12 10:45 AM I created a pull request https://github.com/groovy/groovy-core/pull/99 for this. The method "byte[] getBytes(Charset charset)" isn't in JDK 1.5 so I added "byte[] getBytes(String charset)" instead.
Hide
Permalink
blackdrag blackdrag added a comment - 02/Jan/13 9:40 AM

pull request applied

Show
blackdrag blackdrag added a comment - 02/Jan/13 9:40 AM pull request applied

People

  • Assignee:
    blackdrag blackdrag
    Reporter:
    Paul King
Vote (0)
Watch (3)

Dates

  • Created:
    17/Oct/12 12:26 AM
    Updated:
    12/Jan/13 8:40 PM
    Resolved:
    02/Jan/13 9:40 AM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.