# SocketReadEventArgs.java

    /*
    ** Module   : SocketReadEventArgs.java
    ** Abstract : Implementation of the OpenEdge/Net/ServerConnection/SocketReadEventArgs
    **            builtin class.
    **
    ** Copyright (c) 2019-2023, Golden Code Development Corporation.
    **
    ** -#- -I- --Date-- ---------------------------------------Description----------------------------------------
    ** 001 MP  20200528 Created the first version, by converting the legacy skeleton .cls file and using that
    **                  output.
    ** 002 MP  20200707 Add code in constructors to run like legacy class
    **     CA  20210219 OO input parameter definitions for functions/procedures must not register with  ObjectOps
    **                  - TypeFactory.initInput will take care of this.
    ** 003 CA  20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy signature.
    ** 004 ME  20210318 Drop StringUtils, use addInterval instead, update support levels.
    ** 005 CA  20230817 Removed ObjectOps.register, as this registration is handled by runtime.
    ** 005 CA  20231113 The 'execute' method must be annotated with LegacySignature Type.Execute, and also can be
    **                  dropped if is a no-op.
    */

    /*
    ** This program is free software: you can redistribute it and/or modify
    ** it under the terms of the GNU Affero General Public License as
    ** published by the Free Software Foundation, either version 3 of the
    ** License, or (at your option) any later version.
    **
    ** This program 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 Affero General Public License for more details.
    **
    ** You may find a copy of the GNU Affero GPL version 3 at the following
    ** location: https://www.gnu.org/licenses/agpl-3.0.en.html
    **
    ** Additional terms under GNU Affero GPL version 3 section 7:
    **
    **   Under Section 7 of the GNU Affero GPL version 3, the following additional
    **   terms apply to the works covered under the License.  These additional terms
    **   are non-permissive additional terms allowed under Section 7 of the GNU
    **   Affero GPL version 3 and may not be removed by you.
    **
    **   0. Attribution Requirement.
    **
    **     You must preserve all legal notices or author attributions in the covered
    **     work or Appropriate Legal Notices displayed by works containing the covered
    **     work.  You may not remove from the covered work any author or developer
    **     credit already included within the covered work.
    **
    **   1. No License To Use Trademarks.
    **
    **     This license does not grant any license or rights to use the trademarks
    **     Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
    **     of Golden Code Development Corporation. You are not authorized to use the
    **     name Golden Code, FWD, or the names of any author or contributor, for
    **     publicity purposes without written authorization.
    **
    **   2. No Misrepresentation of Affiliation.
    **
    **     You may not represent yourself as Golden Code Development Corporation or FWD.
    **
    **     You may not represent yourself for publicity purposes as associated with
    **     Golden Code Development Corporation, FWD, or any author or contributor to
    **     the covered work, without written authorization.
    **
    **   3. No Misrepresentation of Source or Origin.
    **
    **     You may not represent the covered work as solely your work.  All modified
    **     versions of the covered work must be marked in a reasonable way to make it
    **     clear that the modified work is not originating from Golden Code Development
    **     Corporation or FWD.  All modified versions must contain the notices of
    **     attribution required in this license.
    */

    package com.goldencode.p2j.oo.net.serverconnection;

    import com.goldencode.p2j.util.*;
    import com.goldencode.p2j.util.BlockManager.Action;
    import com.goldencode.p2j.util.BlockManager.Condition;
    import com.goldencode.p2j.oo.lang.*;
    import com.goldencode.p2j.oo.core.Assert;
    import com.goldencode.p2j.oo.core.Memptr;

    import static com.goldencode.p2j.report.ReportConstants.*;
    import static com.goldencode.p2j.util.BlockManager.*;
    import static com.goldencode.p2j.util.InternalEntry.Type;

    /**
     * Business logic (converted to Java from the 4GL source code
     * in OpenEdge/Net/ServerConnection/SocketReadEventArgs.cls).
     */
    @LegacyResource(resource = "OpenEdge.Net.ServerConnection.SocketReadEventArgs")
    @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
    public class SocketReadEventArgs
    extends BaseObject
    {
       @LegacySignature(type = Type.PROPERTY, name = "ReadComplete")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       private logical readComplete = TypeFactory.logical();

       @LegacySignature(type = Type.PROPERTY, name = "ReadTimeout")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       private logical readTimeout = TypeFactory.logical();

       @LegacySignature(type = Type.PROPERTY, name = "ReadTerminated")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       private logical readTerminated = TypeFactory.logical();

       @LegacySignature(type = Type.PROPERTY, name = "Data")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       private object<? extends Memptr> data = TypeFactory.object(Memptr.class);

       @LegacySignature(type = Type.PROPERTY, name = "TimeoutEnd")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       private datetimetz timeoutEnd = TypeFactory.datetimetz();

       @LegacySignature(type = Type.PROPERTY, name = "BytesRead")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       private int64 bytesRead = TypeFactory.int64();

       @LegacySignature(type = Type.EXECUTE)
       public void __net_serverconnection_SocketReadEventArgs_execute__()
       {
          onBlockLevel(Condition.ERROR, Action.THROW);
       }

       @LegacySignature(returns = "LOGICAL", type = Type.GETTER, name = "ReadComplete")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public logical getReadComplete()
       {
          return function(SocketReadEventArgs.class, this, "ReadComplete", logical.class, new Block((Body) () ->
          {
             returnNormal(readComplete);
          }));
       }

       @LegacySignature(type = Type.SETTER, name = "ReadComplete", parameters =
       {
          @LegacyParameter(name = "var", type = "LOGICAL", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public void setReadComplete(final logical _var)
       {
          logical var = TypeFactory.initInput(_var);

          internalProcedure(SocketReadEventArgs.class, this, "ReadComplete", new Block((Body) () ->
          {
             readComplete.assign(var);
          }));
       }

       @LegacySignature(returns = "LOGICAL", type = Type.GETTER, name = "ReadTimeout")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public logical getReadTimeout()
       {
          return function(SocketReadEventArgs.class, this, "ReadTimeout", logical.class, new Block((Body) () ->
          {
             returnNormal(readTimeout);
          }));
       }

       @LegacySignature(type = Type.SETTER, name = "ReadTimeout", parameters =
       {
          @LegacyParameter(name = "var", type = "LOGICAL", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public void setReadTimeout(final logical _var)
       {
          logical var = TypeFactory.initInput(_var);

          internalProcedure(SocketReadEventArgs.class, this, "ReadTimeout", new Block((Body) () ->
          {
             readTimeout.assign(var);
          }));
       }

       @LegacySignature(returns = "LOGICAL", type = Type.GETTER, name = "ReadTerminated")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public logical getReadTerminated()
       {
          return function(SocketReadEventArgs.class, this, "ReadTerminated", logical.class, new Block((Body) () ->
          {
             returnNormal(readTerminated);
          }));
       }

       @LegacySignature(type = Type.SETTER, name = "ReadTerminated", parameters =
       {
          @LegacyParameter(name = "var", type = "LOGICAL", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public void setReadTerminated(final logical _var)
       {
          logical var = TypeFactory.initInput(_var);

          internalProcedure(SocketReadEventArgs.class, this, "ReadTerminated", new Block((Body) () ->
          {
             readTerminated.assign(var);
          }));
       }

       @LegacySignature(returns = "OBJECT", qualified = "OpenEdge.Core.Memptr", type = Type.GETTER, name = "Data")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public object<? extends Memptr> getData()
       {
          return function(SocketReadEventArgs.class, this, "Data", object.class, new Block((Body) () ->
          {
             returnNormal(data);
          }));
       }

       @LegacySignature(type = Type.SETTER, name = "Data", parameters =
       {
          @LegacyParameter(qualified = "OpenEdge.Core.Memptr", name = "var", type = "OBJECT", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public void setData(final object<? extends Memptr> _var)
       {
          object<? extends Memptr> var = TypeFactory.initInput(_var);

          internalProcedure(SocketReadEventArgs.class, this, "Data", new Block((Body) () ->
          {
             data.assign(var);
          }));
       }

       @LegacySignature(returns = "DATETIMETZ", type = Type.GETTER, name = "TimeoutEnd")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public datetimetz getTimeoutEnd()
       {
          return function(SocketReadEventArgs.class, this, "TimeoutEnd", datetimetz.class, new Block((Body) () ->
          {
             returnNormal(timeoutEnd);
          }));
       }

       @LegacySignature(returns = "INT64", type = Type.GETTER, name = "BytesRead")
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public int64 getBytesRead()
       {
          return function(SocketReadEventArgs.class, this, "BytesRead", int64.class, new Block((Body) () ->
          {
             returnNormal(bytesRead);
          }));
       }

       @LegacySignature(type = Type.SETTER, name = "BytesRead", parameters =
       {
          @LegacyParameter(name = "var", type = "INT64", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public void setBytesRead(final int64 _var)
       {
          int64 var = TypeFactory.initInput(_var);

          internalProcedure(SocketReadEventArgs.class, this, "BytesRead", new Block((Body) () ->
          {
             bytesRead.assign(var);
          }));
       }

       @LegacySignature(type = Type.CONSTRUCTOR, parameters =
       {
          @LegacyParameter(name = "pdTimeoutOffset", type = "DECIMAL", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public void __net_serverconnection_SocketReadEventArgs_constructor__(final decimal _pdTimeoutOffset)
       {
          decimal pdTimeoutOffset = TypeFactory.initInput(_pdTimeoutOffset);

          internalProcedure(SocketReadEventArgs.class, this, "__net_serverconnection_SocketReadEventArgs_constructor__", new Block((Body) () ->
          {
             this.__net_serverconnection_SocketReadEventArgs_constructor__(new integer(pdTimeoutOffset));
          }));
       }

       @LegacySignature(type = Type.CONSTRUCTOR, parameters =
       {
          @LegacyParameter(name = "piTimeoutOffset", type = "INTEGER", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public void __net_serverconnection_SocketReadEventArgs_constructor__(final integer _piTimeoutOffset)
       {
          integer piTimeoutOffset = TypeFactory.initInput(_piTimeoutOffset);

          internalProcedure(SocketReadEventArgs.class, this, "__net_serverconnection_SocketReadEventArgs_constructor__", new Block((Body) () ->
          {
             this.__net_serverconnection_SocketReadEventArgs_constructor__();
             Assert.isZeroOrPositive(piTimeoutOffset, new character("Timeout"));
             if(piTimeoutOffset.intValue() > 0)
             {
                this.timeoutEnd.assign(DateOps.addInterval(datetime.now(), piTimeoutOffset, new character("seconds")));
             }
          }));
       }

       @LegacySignature(type = Type.CONSTRUCTOR, parameters =
       {
          @LegacyParameter(name = "poData", type = "OBJECT", qualified = "openedge.core.memptr", mode = "INPUT")
       })
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public void __net_serverconnection_SocketReadEventArgs_constructor__(final object<? extends Memptr> _poData)
       {
          object<? extends Memptr> poData = TypeFactory.initInput(_poData);

          internalProcedure(SocketReadEventArgs.class, this, "__net_serverconnection_SocketReadEventArgs_constructor__", new Block((Body) () ->
          {
             this.__net_serverconnection_SocketReadEventArgs_constructor__();
             Assert.notNull(poData, new character("data bucket"));
             this.data.assign(poData);
             this.bytesRead.assign(poData.ref().getSize());
          }));
       }

       @LegacySignature(type = Type.CONSTRUCTOR)
       @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
       public void __net_serverconnection_SocketReadEventArgs_constructor__()
       {
          internalProcedure(SocketReadEventArgs.class, this, "__net_serverconnection_SocketReadEventArgs_constructor__", new Block((Body) () ->
          {
             __lang_BaseObject_constructor__();
             this.readComplete.assign(false);
             this.readTerminated.assign(false);
             this.readTimeout.assign(false);
             this.timeoutEnd.setUnknown();
          }));
       }
    }