Package java.beans

Examples of java.beans.PersistenceDelegate


        }

        @SuppressWarnings("unchecked")
        @Override
        public PersistenceDelegate getPersistenceDelegate(Class type) {
            PersistenceDelegate result = super.getPersistenceDelegate(type);
            return result;
        }
View Full Code Here


    e.setPersistenceDelegate(Direction.class, new EnumDelegate());
  }

  public static void addAntlrPersistenceDelegates(XMLEncoder e)
  {
    e.setPersistenceDelegate(ASTNode.class, new PersistenceDelegate()
    {

      protected Expression instantiate(Object oldInstance, Encoder out)
      {
        return new Expression(oldInstance, oldInstance.getClass(),
            "new", new Object[]
            { ((ASTNode) oldInstance).getToken() });
      }
    });
    e.setPersistenceDelegate(CommonTree.class, new PersistenceDelegate()
    {
      protected Expression instantiate(Object oldInstance, Encoder out)
      {
        return new Expression(oldInstance, oldInstance.getClass(),
            "new", new Object[]
            { ((CommonTree) oldInstance).getToken() });
      }
    });
    e.setPersistenceDelegate(BaseTree.class, new PersistenceDelegate()
    {
      protected Expression instantiate(Object oldInstance, Encoder out)
      {
        return new Expression(oldInstance, oldInstance.getClass(),
            "new", new Object[]
            {});
      }

      @SuppressWarnings("rawtypes")
      protected void initialize(Class type, Object oldInstance,
          Object newInstance, Encoder out)
      {
        super.initialize(type, oldInstance, newInstance, out);

        BaseTree t = (BaseTree) oldInstance;

        for (int i = 0; i < t.getChildCount(); i++)
        {
          out.writeStatement(new Statement(oldInstance, "addChild",
              new Object[]
              { t.getChild(i) }));
        }
      }
    });
    e.setPersistenceDelegate(CommonToken.class, new PersistenceDelegate()
    {
      protected Expression instantiate(Object oldInstance, Encoder out)
      {
        return new Expression(oldInstance, oldInstance.getClass(),
            "new", new Object[]
View Full Code Here

  }

  public static void addHivePersistenceDelegates(XMLEncoder e)
  {
    e.setPersistenceDelegate(PrimitiveTypeInfo.class,
        new PersistenceDelegate()
        {
          protected Expression instantiate(Object oldInstance,
              Encoder out)
          {
            return new Expression(oldInstance,
View Full Code Here

        }

        @SuppressWarnings("unchecked")
        @Override
        public PersistenceDelegate getPersistenceDelegate(Class type) {
            PersistenceDelegate result = super.getPersistenceDelegate(type);
            return result;
        }
View Full Code Here

     */
    public void testProxyPD() throws Exception {
        MyInterface o = (MyInterface) Proxy.newProxyInstance(ClassLoader
                .getSystemClassLoader(), new Class[] { MyInterface.class },
                new MyHandler(1));
        PersistenceDelegate pd = new PersistenceDelegate() {

            @Override
            public Expression instantiate(Object o, Encoder e) {
                return new Expression(o, ClassLoader.class,
                        "getSystemClassLoader", null);
View Full Code Here

    e.setPersistenceDelegate(Direction.class, new EnumDelegate());
  }

  public static void addAntlrPersistenceDelegates(XMLEncoder e)
  {
    e.setPersistenceDelegate(ASTNode.class, new PersistenceDelegate()
    {

      @Override
      protected Expression instantiate(Object oldInstance, Encoder out)
      {
        return new Expression(oldInstance, oldInstance.getClass(),
            "new", new Object[]
            { ((ASTNode) oldInstance).getToken() });
      }
    });
    e.setPersistenceDelegate(CommonTree.class, new PersistenceDelegate()
    {
      @Override
      protected Expression instantiate(Object oldInstance, Encoder out)
      {
        return new Expression(oldInstance, oldInstance.getClass(),
            "new", new Object[]
            { ((CommonTree) oldInstance).getToken() });
      }
    });
    e.setPersistenceDelegate(BaseTree.class, new PersistenceDelegate()
    {
      @Override
      protected Expression instantiate(Object oldInstance, Encoder out)
      {
        return new Expression(oldInstance, oldInstance.getClass(),
            "new", new Object[]
            {});
      }

      @Override
      @SuppressWarnings("rawtypes")
      protected void initialize(Class type, Object oldInstance,
          Object newInstance, Encoder out)
      {
        super.initialize(type, oldInstance, newInstance, out);

        BaseTree t = (BaseTree) oldInstance;

        for (int i = 0; i < t.getChildCount(); i++)
        {
          out.writeStatement(new Statement(oldInstance, "addChild",
              new Object[]
              { t.getChild(i) }));
        }
      }
    });
    e.setPersistenceDelegate(CommonToken.class, new PersistenceDelegate()
    {
      @Override
      protected Expression instantiate(Object oldInstance, Encoder out)
      {
        return new Expression(oldInstance, oldInstance.getClass(),
View Full Code Here

  }

  public static void addHivePersistenceDelegates(XMLEncoder e)
  {
    e.setPersistenceDelegate(PrimitiveTypeInfo.class,
        new PersistenceDelegate()
        {
          @Override
          protected Expression instantiate(Object oldInstance,
              Encoder out)
          {
View Full Code Here

     * Tests array persistence delegate
     */
    public void testArrayPD_Normal() {
        Encoder enc = new MockEncoder();
        int[] ia = new int[] { 1 };
        PersistenceDelegate pd = enc.getPersistenceDelegate(ia.getClass());
        pd.writeObject(ia, enc);
    }
View Full Code Here

        lastIndex = index;
    }

    public void testGetPersistenceDelegate_Null() {
        Encoder enc = new Encoder();
        PersistenceDelegate pd = enc.getPersistenceDelegate(null);
        assertNotNull(pd);
    }
View Full Code Here

        assertNotNull(pd);
    }

    public void testGetPersistenceDelegate_ArrayClass() {
        Encoder enc = new Encoder();
        PersistenceDelegate pd = enc.getPersistenceDelegate(int[].class);
        assertFalse(pd instanceof DefaultPersistenceDelegate);
    }
View Full Code Here

TOP

Related Classes of java.beans.PersistenceDelegate

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.