HoGenericDataContainer.java :  » J2EE » WiSerFramework » de » ug2t » channel » ho » Java Open Source

Java Open Source » J2EE » WiSerFramework 
WiSerFramework » de » ug2t » channel » ho » HoGenericDataContainer.java
// @@
// @@
/*
 * Wi.Ser Framework
 *
 * LGPL Version: 1.8.1, 20-September-2007  
 * Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library located in LGPL.txt in the 
 * license directory; if not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 * 
 * If this agreement does not cover your requirements, please contact us
 * via email to get detailed information about the commercial license 
 * or our service offerings!
 *
 */
// @@

package de.ug2t.channel.ho;

import java.io.*;
import java.util.*;

import de.ug2t.channel.ho.session.*;
import de.ug2t.kernel.*;
import de.ug2t.unifiedGui.interfaces.*;
import de.ug2t.xmlScript.*;

public class HoGenericDataContainer extends KeRegisteredObject implements IUnLazyComponent
{
  private transient IHoSession pem_session = null;
  private ArrayList            pem_values  = new ArrayList();
  private String               pem_sep     = ";";

  // @@

  public HoGenericDataContainer()
  {
    this.pem_session = (IHoSession) KeRegisteredObject.pcmf_getObjByName(IHoSession.SESSION_NAME);

    if (this.pem_session != null && this.pem_session.pcmf_isClientSide() == false)
    {
      KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");
      // Deklaration
      if (this.pem_session.pcmf_isInTransaction())
      {
        ScXmlScript.pcmf_createPBody(l_remCall);
      }
      else
      {
        ScXmlScript.pcmf_createxScriptString(l_remCall, null);
        ScXmlScript.pcmf_addProc(l_remCall, null);
      };
      ScXmlScript.pcmf_addDecl(l_remCall, this.pcmf_getRemName(), "de.ug2t.channel.ho.HoGenericDataContainer", "global");
      ScXmlScript.pcmf_endAll(l_remCall);
      this.pem_session.pcmf_call(l_remCall.toString(), this);
    };

    return;
  };

  public boolean equals(Object o)
  {
    if (o instanceof HoGenericDataContainer)
      return (this.pem_values.equals((((HoGenericDataContainer) o).pcmf_getOrgValueArray())));
    else
      return (false);
  }

  public void pcmf_addRemoteValue_S2C(String xString)
  {
    if (pem_session != null)
    {
      KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

      if (this.pem_session.pcmf_isInTransaction())
      {
        ScXmlScript.pcmf_createPBody(l_remCall);
      }
      else
      {
        ScXmlScript.pcmf_createxScriptString(l_remCall, null);
        ScXmlScript.pcmf_addProc(l_remCall, null);
      };
      ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_addValue");
      ScXmlScript.pcmf_addCallPar(l_remCall, xString, "false", "java.lang.String");
      ScXmlScript.pcmf_endAll(l_remCall);

      this.pem_session.pcmf_call(l_remCall.toString(), this);
    };
    this.pcmf_addValue(xString);

    return;
  }

  public void pcmf_addRemoteValue_S2C(KeRegisteredObject xObj)
  {
    if (pem_session != null)
    {
      KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

      if (this.pem_session.pcmf_isInTransaction())
      {
        ScXmlScript.pcmf_createPBody(l_remCall);
      }
      else
      {
        ScXmlScript.pcmf_createxScriptString(l_remCall, null);
        ScXmlScript.pcmf_addProc(l_remCall, null);
      };
      ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_addValue");
      ScXmlScript.pcmf_addCallPar(l_remCall, xObj.pcmf_getRemName(), "true", "de.ug2t.kernel.KeRegisteredObject");
      ScXmlScript.pcmf_endAll(l_remCall);

      this.pem_session.pcmf_call(l_remCall.toString(), this);
    };
    this.pcmf_addValue(xObj);

    return;
  }

  public void pcmf_addRemoteValue_C2S(String xString)
  {
    if (pem_session != null)
    {
      KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

      if (this.pem_session.pcmf_isInTransaction())
      {
        ScXmlScript.pcmf_createPBody(l_remCall);
      }
      else
      {
        ScXmlScript.pcmf_createxScriptString(l_remCall, null);
        ScXmlScript.pcmf_addProc(l_remCall, null);
      };
      ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getObjName(), "pcmf_addValue");
      ScXmlScript.pcmf_addCallPar(l_remCall, xString, "false", "java.lang.String");
      ScXmlScript.pcmf_endAll(l_remCall);

      this.pem_session.pcmf_call(l_remCall.toString(), this);
    };
    this.pcmf_addValue(xString);

    return;
  }

  public void pcmf_setRemoteValues_C2S(ArrayList xValues)
  {
    if (pem_session != null)
    {
      KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

      if (this.pem_session.pcmf_isInTransaction())
      {
        ScXmlScript.pcmf_createPBody(l_remCall);
      }
      else
      {
        ScXmlScript.pcmf_createxScriptString(l_remCall, null);
        ScXmlScript.pcmf_addProc(l_remCall, null);
      };

      ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getObjName(), "pcmf_clearValues");
      ScXmlScript.pcmf_endCall(l_remCall);

      this.pcmf_clearValues();
      
      Iterator l_it = xValues.iterator();
      while (l_it.hasNext())
      {
        String l_value = l_it.next().toString();
        ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getObjName(), "pcmf_addValue");
        ScXmlScript.pcmf_addCallPar(l_remCall, l_value, "false", "java.lang.String");
        ScXmlScript.pcmf_endCall(l_remCall);
        this.pcmf_addValue(l_value);
      }
      
      ScXmlScript.pcmf_endAll(l_remCall);

      this.pem_session.pcmf_call(l_remCall.toString(), this);
    };
    return;
  }

  public void pcmf_setRemoteValueObjects_C2S(ArrayList xValues)
  {
    if (pem_session != null)
    {
      KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

      if (this.pem_session.pcmf_isInTransaction())
      {
        ScXmlScript.pcmf_createPBody(l_remCall);
      }
      else
      {
        ScXmlScript.pcmf_createxScriptString(l_remCall, null);
        ScXmlScript.pcmf_addProc(l_remCall, null);
      };

      ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getObjName(), "pcmf_clearValues");
      ScXmlScript.pcmf_endCall(l_remCall);

      this.pcmf_clearValues();
      
      Iterator l_it = xValues.iterator();
      while (l_it.hasNext())
      {
        KeRegisteredObject l_value = (KeRegisteredObject)l_it.next();
        ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getObjName(), "pcmf_addValue");
        ScXmlScript.pcmf_addCallPar(l_remCall, l_value.pcmf_getObjName(), "true", "de.ug2t.kernel.KeRegisteredObject");
        ScXmlScript.pcmf_endCall(l_remCall);
        this.pcmf_addValue(l_value);
      }
      
      ScXmlScript.pcmf_endAll(l_remCall);

      this.pem_session.pcmf_call(l_remCall.toString(), this);
    };
    return;
  }

  public void pcmf_addRemoteValue_C2S(KeRegisteredObject xObj)
  {
    if (pem_session != null)
    {
      KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

      if (this.pem_session.pcmf_isInTransaction())
      {
        ScXmlScript.pcmf_createPBody(l_remCall);
      }
      else
      {
        ScXmlScript.pcmf_createxScriptString(l_remCall, null);
        ScXmlScript.pcmf_addProc(l_remCall, null);
      };
      ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getObjName(), "pcmf_addValue");
      ScXmlScript.pcmf_addCallPar(l_remCall, xObj.pcmf_getObjName(), "true", "de.ug2t.kernel.KeRegisteredObject");
      ScXmlScript.pcmf_endAll(l_remCall);

      this.pem_session.pcmf_call(l_remCall.toString(), this);
    };
    this.pcmf_addValue(xObj);

    return;
  }

  public void pcmf_clearRemoteValues_S2C()
  {
    if (pem_session != null)
    {
      KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

      if (this.pem_session.pcmf_isInTransaction())
      {
        ScXmlScript.pcmf_createPBody(l_remCall);
      }
      else
      {
        ScXmlScript.pcmf_createxScriptString(l_remCall, null);
        ScXmlScript.pcmf_addProc(l_remCall, null);
      };
      ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_clearValues");
      ScXmlScript.pcmf_endAll(l_remCall);

      this.pem_session.pcmf_call(l_remCall.toString(), this);
    };

    this.pcmf_clearValues();
  }

  public void pcmf_clearRemoteValues_C2S()
  {
    if (pem_session != null)
    {
      KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

      if (this.pem_session.pcmf_isInTransaction())
      {
        ScXmlScript.pcmf_createPBody(l_remCall);
      }
      else
      {
        ScXmlScript.pcmf_createxScriptString(l_remCall, null);
        ScXmlScript.pcmf_addProc(l_remCall, null);
      };
      ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getObjName(), "pcmf_clearValues");
      ScXmlScript.pcmf_endAll(l_remCall);

      this.pem_session.pcmf_call(l_remCall.toString(), this);
    };

    this.pcmf_clearValues();
  }

  public void pcmf_addValue(String xString)
  {
    this.pem_values.add(xString);
  }

  public int pcmf_size()
  {
    return (this.pem_values.size());
  }

  public boolean pcmf_contains(Object xObj)
  {
    return (this.pem_values.contains(xObj));
  }

  public void pcmf_removeValue(Object xObj)
  {
    this.pem_values.remove(xObj);
  }

  public void pcmf_addValue(KeRegisteredObject xObj)
  {
    this.pem_values.add(xObj);
  }

  public void pcmf_clearValues()
  {
    this.pem_values.clear();
  }

  public Iterator pcmf_getValueIt()
  {
    return (new ArrayList(this.pem_values).iterator());
  }

  public ArrayList pcmf_getValueArray()
  {
    return (new ArrayList(this.pem_values));
  }

  protected ArrayList pcmf_getOrgValueArray()
  {
    return (this.pem_values);
  }

  public Object pcmf_getValueAt(int xIdx)
  {
    return (this.pem_values.get(xIdx));
  }

  public void pcmf_setSep(String xSep)
  {
    this.pem_sep = xSep;
  }

  public String toString(Object xObj)
  {
    StringBuffer l_ret = new StringBuffer();
    Iterator l_it = this.pem_values.iterator();

    while (l_it.hasNext())
    {
      Object l_obj = l_it.next();
      if (l_obj == xObj)
        l_ret.append("this");
      else
        l_ret.append(l_obj.toString());

      if (l_it.hasNext())
        l_ret.append(this.pem_sep);
    }

    return (l_ret.toString());
  }

  public String toString()
  {
    StringBuffer l_ret = new StringBuffer();
    Iterator l_it = this.pem_values.iterator();

    while (l_it.hasNext())
    {
      l_ret.append(l_it.next().toString());
      if (l_it.hasNext())
        l_ret.append(this.pem_sep);
    }

    return (l_ret.toString());
  }

  public void pcmf_delete() throws Exception
  {
    if (this.pdm_deleted == true)
      return;

    String l_remName = this.pcmf_getRemName();
    super.pcmf_delete();

    if (pem_session != null && pem_session.pcmf_isClientSide() == false)
    {
      if (l_remName != null)
      {
        KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

        if (this.pem_session.pcmf_isInTransaction())
        {
          ScXmlScript.pcmf_createPBody(l_remCall);
        }
        else
        {
          ScXmlScript.pcmf_createxScriptString(l_remCall, null);
          ScXmlScript.pcmf_addProc(l_remCall, null);
        };

        ScXmlScript.pcmf_addCall(l_remCall, null, l_remName, "pcmf_delete");
        ScXmlScript.pcmf_endAll(l_remCall);

        this.pem_session.pcmf_call(l_remCall.toString(), this);
      }
    };

    return;
  }

  public void pcmf_copy(HoGenericDataContainer xtoCopy)
  {
    if (xtoCopy == this)
      return;

    this.pem_values = new ArrayList(xtoCopy.pcmf_getValueArray());
    return;
  }

  public void pcmf_echoValues()
  {
    if (pem_session != null)
    {
      KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

      if (this.pem_session.pcmf_isInTransaction())
      {
        ScXmlScript.pcmf_createPBody(l_remCall);
      }
      else
      {
        ScXmlScript.pcmf_createxScriptString(l_remCall, null);
        ScXmlScript.pcmf_addProc(l_remCall, null);
      };
      ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_clearValues");
      ScXmlScript.pcmf_endAll(l_remCall);

      this.pem_session.pcmf_echoCall(l_remCall.toString());
    };

    Iterator l_it = this.pem_values.iterator();
    while (l_it.hasNext())
    {
      Object l_obj = l_it.next();

      if (l_obj == null)
        continue;

      if (pem_session != null)
      {
        KeStringTemplateWrapper l_remCall = new KeStringTemplateWrapper("");

        if (this.pem_session.pcmf_isInTransaction())
        {
          ScXmlScript.pcmf_createPBody(l_remCall);
        }
        else
        {
          ScXmlScript.pcmf_createxScriptString(l_remCall, null);
          ScXmlScript.pcmf_addProc(l_remCall, null);
        };
        ScXmlScript.pcmf_addCall(l_remCall, null, this.pcmf_getRemName(), "pcmf_addValue");

        if (l_obj instanceof KeRegisteredObject)
          ScXmlScript.pcmf_addCallPar(l_remCall, ((KeRegisteredObject) l_obj).pcmf_getRemName(), "true", "de.ug2t.kernel.KeRegisteredObject");
        else
          ScXmlScript.pcmf_addCallPar(l_remCall, l_obj.toString(), "false", "java.lang.String");

        ScXmlScript.pcmf_endAll(l_remCall);

        this.pem_session.pcmf_echoCall(l_remCall.toString());
      };
    }
  }
}

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.