Package speculoos.beans

Examples of speculoos.beans.SyntheticMap


  class MapHandler implements TagHandler {

    public void startElement(String uri, String localName, String qName,
        Attributes attributes) throws SAXException {
      SyntheticMap m = new SyntheticMap();
      String mn = attributes.getValue("name");
      /* inherited fields to map */
      String inh = attributes.getValue("inherits");
      if (inh != null) {
        String[] refs = inh.split("\\s+");
        for (int i = 0; i < refs.length; i++) {
          Object rm = maps.get(refs[i]);
          if (rm == null)
            throw new SAXException("Undefined map reference "
                + refs[i] + " in definition for map " + mn);
          m.addInherits(rm);
        }
      }
      /* add map to source */
      maps.put(mn, m);
      push(m);
View Full Code Here


    this.gen.setPack("speculoos");
  }

  public void test01SimpleFlatMap() throws IOException {
    this.gen.setName(getName());
    SyntheticMap map = new SyntheticMap();
    MapEntry me = new MapEntry("toto");
    map.put("toto", me);
    me = new MapEntry("tutuTiti");
    me.setType("int");
    me.setValue("0");
    map.put("tutuTiti", me);
    map.setName("GenTest");
    /* run */
    gen.generate(map);
    String ifas = iface.getBuffer().toString();
    System.err.print(ifas);
    String im = impl.getBuffer().toString();
View Full Code Here

    assertTrue(im.contains("private java.util.List foo = null"));
    assertTrue(im.contains("float getBar ()"));
  }
  */
  public void test03MapWithIfaceBeanAndMapParents() throws IOException {
    SyntheticMap map = new SyntheticMap();
    MapEntry me = new MapEntry("toto");
    map.put("toto", me);
    me = new MapEntry("tutuTiti");
    me.setType("int");
    me.setValue("0");
    map.put("tutuTiti", me);
    map.setName("GenTest");
    SyntheticMap par = new SyntheticMap();
    me = new MapEntry("foo");
    me.setType("java.util.List");
    par.put("foo", me);
    me = new MapEntry("bar");
    me.setType("float");
    me.setValue("0.0f");
    par.put("bar", me);
    par.setName("ParentMap");
    map.addInherits(par);
    BeanMap bean = new BeanMap(IPersonne.class);
    map.addInherits(bean);
    /* run */
    gen.generate(map);
 
View Full Code Here

    assertTrue(ifas.indexOf("void setToto (String toto)") != -1);
    assertTrue(im.indexOf("public int getChildNumber ()") != -1);
  }
 
  public void test04MapWithConcreteBeanAndMapParents() throws IOException {
    SyntheticMap map = new SyntheticMap();
    MapEntry me = new MapEntry("toto");
    map.put("toto", me);
    me = new MapEntry("tutuTiti");
    me.setType("int");
    me.setValue("0");
    map.put("tutuTiti", me);
    map.setName("GenTest");
    SyntheticMap par = new SyntheticMap();
    me = new MapEntry("foo");
    me.setType("java.util.List");
    par.put("foo", me);
    me = new MapEntry("bar");
    me.setType("float");
    me.setValue("0.0f");
    par.put("bar", me);
    par.setName("ParentMap");
    map.addInherits(par);
    BeanMap bean = new BeanMap(Personne.class);
    map.addInherits(bean);
    /* run */
    gen.generate(map);
 
View Full Code Here

    assertTrue(im.indexOf("public int getChildNumber ()") == -1);
  }
 

  public void test05MapWithIfaceBeanHierarchy() throws IOException {
    SyntheticMap map = new SyntheticMap();
    MapEntry me = new MapEntry("toto");
    map.put("toto", me);
    me = new MapEntry("tutuTiti");
    me.setType("int");
    me.setValue("0");
    map.put("tutuTiti", me);
    map.setName("GenTest");
    BeanMap bean = new BeanMap(IPersonne.class);
    map.addInherits(bean);
    /* run */
    gen.generate(map);
    String ifas = iface.getBuffer().toString();
    System.err.print(ifas);
    String im = impl.getBuffer().toString();
View Full Code Here

* @version $Id: SyntheticMapTest.java 65 2007-03-19 22:43:27Z trecloux $
*/
public class SyntheticMapTest extends TestCase {
 
  public void test01BasicInheritance() {
    SyntheticMap child = new SyntheticMap();
    MapEntry me = new MapEntry("toto");
    me.setValue("titi");
    me.setType("tata");
    child.put("toto",me);
    SyntheticMap parent = new SyntheticMap();
    me = new MapEntry("titi");
    me.setValue("null");
    me.setType("titi");
    parent.put("titi",me);
    child.addInherits(parent);
    assertEquals("toto", ((MapEntry)child.get("toto")).getName());
    assertEquals("titi", ((MapEntry)child.get("titi")).getType());
  }
View Full Code Here

    assertEquals("toto", ((MapEntry)child.get("toto")).getName());
    assertEquals("titi", ((MapEntry)child.get("titi")).getType());
  }

  public void test02MultipleInheritance() {
    SyntheticMap child = new SyntheticMap();
    MapEntry me = new MapEntry("toto");
    me.setValue("titi");
    me.setType("tata");
    child.put("toto",me);
    SyntheticMap parent = new SyntheticMap();
    me = new MapEntry("titi");
    me.setValue("null");
    me.setType("titi");
    parent.put("titi",me);
    child.addInherits(parent);
    parent = new SyntheticMap();
    me = new MapEntry("foo");
    me.setValue("bar");
    me.setType("baz");
    parent.put("foo",me);
    child.addInherits(parent);
    assertEquals("toto", ((MapEntry)child.get("toto")).getName());
    assertEquals("bar", ((MapEntry)child.get("foo")).getValue());
  }
View Full Code Here

    assertEquals("toto", ((MapEntry)child.get("toto")).getName());
    assertEquals("bar", ((MapEntry)child.get("foo")).getValue());
  }

  public void test03Hierarchy() {
    SyntheticMap child = new SyntheticMap();
    MapEntry me = new MapEntry("toto");
    me.setValue("titi");
    me.setType("tata");
    child.put("toto",me);
    SyntheticMap parent = new SyntheticMap();
    me = new MapEntry("titi");
    me.setValue("null");
    me.setType("titi");
    parent.put("titi",me);
    child.addInherits(parent);
    SyntheticMap parent2 = new SyntheticMap();
    me = new MapEntry("foo");
    me.setValue("bar");
    me.setType("baz");
    parent2.put("foo",me);
    parent.addInherits(parent2);
    assertEquals("toto", ((MapEntry)child.get("toto")).getName());
    assertEquals("bar", ((MapEntry)child.get("foo")).getValue());
  }
View Full Code Here

TOP

Related Classes of speculoos.beans.SyntheticMap

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.