Package org.codehaus.groovy.runtime

Examples of org.codehaus.groovy.runtime.GStringImpl


    super(String.class, GString.class);
  }

  public Object coerce(Object original, Class target) {
    if (original instanceof String) {
      return new GStringImpl(new Object[0], new String[] { (String) original });
    } else if (original instanceof GString) {
      return original.toString();
    }
   
    throw new CoersionException("Cannot coerce: " + original + " to " + target);
View Full Code Here


    }

    // TODO also check case that a FQN is needed

    @Test public void gstring() throws Exception {
        assertEquals("UsesBase[Impl1[hello world]]", DescribableHelper.instantiate(UsesBase.class, map("base", map("$class", "Impl1", "text", new GStringImpl(new Object[] {"hello", "world"}, new String[] {"", " "})))).toString());
    }
View Full Code Here

     */
    @Test
    public void coercion() throws Exception {
        Map r = new HashMap();
        r.put("a",10L); // long -> int
        r.put("b",new GStringImpl(new Object[]{1},new String[]{"pre","post"})); // GString -> String
        BogusStep step = (BogusStep) d.newInstance(r);

        assertEquals(step.a, 10);
        assertEquals(step.b, "pre1post");
    }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.runtime.GStringImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.