JsonArray.java

/*
** Module   : JsonArray.java
** Abstract : Implementation of the Progress.Json.Objectmodel.JsonArray builtin class.
**
** Copyright (c) 2018-2023, Golden Code Development Corporation.
**
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------
** 001 OM  20181218 First version.
** 002 GES 20190308 Added a basic implementation.
** 003 CA  20190423 Added LegacyResource annotation.
** 004 CA  20190509 Always use <? extends _BaseObject_>.
** 005 CA  20190706 Added Write(OUTPUT target AS CHARACTER).
** 006 HC  20190701 Implemented most of the legacy methods.
** 007 CA  20191024 Added method support levels and updated the class support level.
** 008 ME  20210130 Add missing methods (OE12.2), implement error handling 4GL compatible.
**         20210215 Fix write method return.
** 009 CA  20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy signature.
**     CA  20210304 Fixed date, datetime and datetimetz literal parsing.
**     ME  20210319 Fix remove, serialization,error on stream not found.
**     OM  20210809 Added missing add() methods. Widened argument type of setLength().
**     CA  20220923 Variable definitions (including associated with parameters) must be done always outside of 
**                  the BlockManager API
**     TJD 20220504 Upgrade do Java 11 minor changes
**     CA  20220513 Renamed _BaseObject_.clone() to legacyClone(), as it can be overriden by sub-classes and
**                  the access mode may collide with the Java's Object.clone().
**     SVL 20230108 Improved performance by replacing some "for-each" loops with indexed "for" loops.
**     CA  20230116 Avoid using handle.unwrap, handle.getReference or other BDT usage from within FWD runtime.
** 010 CA  20230215 Sanitized the LegacySignature parameters, so their type match their Java method definition.
** 011 GBB 20230512 Logging methods replaced by CentralLogger/ConversionStatus.
** 012 ME  20230503 Reconvert skeleton and update ctor/method signatures (#6410).
** 013 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.json.objectmodel;

import com.goldencode.p2j.oo.json.*;
import com.goldencode.p2j.oo.lang.*;
import com.goldencode.p2j.persist.BufferReference;
import com.goldencode.p2j.persist.TempTable;
import com.goldencode.p2j.persist.TemporaryBuffer;
import com.goldencode.p2j.persist.serial.JsonExport;
import com.goldencode.p2j.security.*;
import com.goldencode.p2j.util.*;
import com.goldencode.p2j.util.ErrorManager;
import com.goldencode.p2j.util.BlockManager.Action;
import com.goldencode.p2j.util.BlockManager.Condition;
import com.goldencode.p2j.util.logging.*;

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.logging.*;

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

/**
 * Implementation of the Progress.Json.Objectmodel.JsonArray builtin class.
 */
@LegacyResource(resource = "Progress.Json.Objectmodel.JsonArray")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL_RESTR|RT_LVL_PARTIAL)
public class JsonArray
extends JsonConstruct
{
   /** Logger. */
   private static final CentralLogger LOG = CentralLogger.get(JsonArray.class);

   /** Array elements */
   private ArrayList<Object> elements = new ArrayList<>();

   private static ContextLocal<integer> endOfArray = new ContextLocal<integer>()
   {
      protected integer initialValue()
      {
         return TypeFactory.integer(-1L);
      }
   };

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

   @LegacySignature(type = Type.CONSTRUCTOR)
   public static void __json_objectmodel_JsonArray_constructor__static__()
   {
      externalProcedure(JsonArray.class, new Block((Body) () -> 
      {
         onBlockLevel(Condition.ERROR, Action.THROW);
      }));
   }
   
   @LegacySignature(type = Type.CONSTRUCTOR)
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__()
   {
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () ->
      {
         __json_objectmodel_JsonConstruct_constructor__();
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "sz", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final integer _sz)
   {
      integer sz = TypeFactory.initInput(_sz);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();

         if (sz.isUnknown() || sz.intValue() < 0)
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("initial-size", this,
                     "JsonArray", "Can not be less than 0 or UNKNOWN (?)."), 16074));
         }

         setLength(sz);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "CHARACTER", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final character[] val)
   {
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "COMHANDLE", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final comhandle[] _val)
   {
      comhandle[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "DATE", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final date[] _val)
   {
      date[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "DATETIME", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final datetime[] _val)
   {
      datetime[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "DATETIMETZ", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final datetimetz[] _val)
   {
      datetimetz[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "DECIMAL", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final decimal[] _val)
   {
      decimal[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "HANDLE", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final handle[] _val)
   {
      handle[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "INT64", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final int64[] _val)
   {
      int64[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "INTEGER", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final integer[] _val)
   {
      integer[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "LOGICAL", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final logical[] _val)
   {
      logical[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "LONGCHAR", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final longchar[] _val)
   {
      longchar[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "MEMPTR", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final memptr[] _val)
   {
      memptr[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "RAW", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final raw[] _val)
   {
      raw[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "RECID", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final recid[] _val)
   {
      recid[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "ROWID", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final rowid[] _val)
   {
      rowid[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "OBJECT", extent = -1, qualified = "progress.json.objectmodel.jsonobject", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_constructor__(final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject>[] _val)
   {
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject>[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }
   
   @LegacySignature(type = Type.CONSTRUCTOR, parameters = 
   {
      @LegacyParameter(name = "val", type = "OBJECT", extent = -1, qualified = "progress.json.objectmodel.jsonarray", mode = "INPUT")
   })
   public void __json_objectmodel_JsonArray_1_constructor__(final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray>[] _val)
   {
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray>[] val = TypeFactory.initInput(_val);
      
      internalProcedure(this, "__json_objectmodel_JsonArray_1_constructor__", new Block((Body) () -> 
      {
         __json_objectmodel_JsonConstruct_constructor__();
         addElementsCtorImpl(val);
      }));
   }

   /**
    * Destructor for this class.  Cleanup/delete any created resources.
    */
   @LegacySignature(type = Type.DESTRUCTOR)
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void __json_objectmodel_JsonArray_destructor__()
   {
      internalProcedure(this, "__json_objectmodel_JsonArray_destructor__", new Block((Body) () ->
      {
         clear();
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.GETTER, name = "END_OF_ARRAY")
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public static integer getEndOfArray()
   {
      ObjectOps.load(JsonArray.class);
      
      return function(JsonArray.class, "END_OF_ARRAY", integer.class, new Block((Body) () -> 
      {
         returnNormal(endOfArray.get());
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.GETTER, name = "Length")
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer getLength()
   {
      return function(this, "Length", integer.class, new Block((Body) () -> 
      {
         returnNormal(elements.size());
      }));
   }

   @LegacySignature(type = Type.SETTER, name = "Length", parameters = 
   {
      @LegacyParameter(name = "var", type = "INT64", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public void setLength(final int64 _var)
   {
      int64 var = TypeFactory.initInput(_var);
      
      internalProcedure(this, "Length", new Block((Body) () -> 
      {
         if (var.isUnknown() || var.intValue() < 0)
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("length", this,
                     "Length", "Can not be less than 0 or UNKNOWN (?)."), 16074));
         }
         
         int newLength = var.intValue();
         int size = elements.size();
         
         if (newLength == size)
         {
            return;
         }
         
         if (newLength < size)
         {
            List<Object> sublist = elements.subList(0, newLength);
            elements = new ArrayList<>(newLength);
            elements.addAll(sublist);
         }
         else
         {
            Object[] nulls = new Object[newLength - elements.size()];
            Arrays.fill(nulls, null);
            elements.addAll(Arrays.asList(nulls));
         }
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "CHARACTER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final character _val)
   {
      character val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "COMHANDLE", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final comhandle _val)
   {
      comhandle val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "DATE", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final date _val)
   {
      date val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "DATETIME", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final datetime _val)
   {
      datetime val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "DATETIMETZ", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final datetimetz _val)
   {
      datetimetz val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "DECIMAL", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final decimal _val)
   {
      decimal val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "HANDLE", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final handle _val)
   {
      handle val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "INT64", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final int64 _val)
   {
      int64 val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _val)
   {
      integer val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "LOGICAL", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final logical _val)
   {
      logical val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "LONGCHAR", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final longchar _val)
   {
      longchar val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "MEMPTR", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final memptr _val)
   {
      memptr val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "RAW", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final raw _val)
   {
      raw val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "RECID", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final recid _val)
   {
      recid val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "ROWID", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final rowid _val)
   {
      rowid val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   // Not part of 4GL API, used only for JSON temp-table serialization.
   public integer add(blob _val)
   {
      blob val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () -> addElementImpl(val)));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "OBJECT", qualified = "progress.json.objectmodel.jsonarray", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add_1(final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray> _val)
   {
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray> val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "OBJECT", qualified = "progress.json.objectmodel.jsonobject", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add_2(final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject> _val)
   {
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject> val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "CHARACTER", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final character[] _val)
   {
      character[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "COMHANDLE", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final comhandle[] _val)
   {
      comhandle[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "DATE", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final date[] _val)
   {
      date[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "DATETIME", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final datetime[] _val)
   {
      datetime[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "DATETIMETZ", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final datetimetz[] _val)
   {
      datetimetz[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "DECIMAL", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final decimal[] _val)
   {
      decimal[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "HANDLE", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final handle[] _val)
   {
      handle[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "INT64", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final int64[] _val)
   {
      int64[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "INTEGER", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer[] _val)
   {
      integer[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "LOGICAL", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final logical[] _val)
   {
      logical[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "LONGCHAR", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final longchar[] _val)
   {
      longchar[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "MEMPTR", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final memptr[] _val)
   {
      memptr[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "RAW", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final raw[] _val)
   {
      raw[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "RECID", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final recid[] _val)
   {
      recid[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "ROWID", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final rowid[] _val)
   {
      rowid[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "OBJECT", extent = -1, qualified = "progress.json.objectmodel.jsonarray", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add_3(final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray>[] _val)
   {
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray>[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "val", type = "OBJECT", extent = -1, qualified = "progress.json.objectmodel.jsonobject", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add_4(final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject>[] _val)
   {
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject>[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "CHARACTER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final character _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      character val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "CHARACTER", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final character[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      character[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "COMHANDLE", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final comhandle _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      comhandle val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "COMHANDLE", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final comhandle[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      comhandle[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DATE", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final date _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      date val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DATE", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final date[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      date[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DATETIME", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final datetime _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      datetime val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DATETIME", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final datetime[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      datetime[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DATETIMETZ", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final datetimetz _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      datetimetz val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DATETIMETZ", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final datetimetz[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      datetimetz[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DECIMAL", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final decimal _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      decimal val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DECIMAL", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final decimal[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      decimal[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "HANDLE", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final handle _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      handle val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "HANDLE", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final handle[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      handle[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "INT64", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final int64 _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      int64 val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "INT64", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final int64[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      int64[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final integer _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "INTEGER", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final integer[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "LOGICAL", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final logical _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      logical val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "LOGICAL", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final logical[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      logical[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "LONGCHAR", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final longchar _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      longchar val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "LONGCHAR", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final longchar[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      longchar[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "MEMPTR", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final memptr _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      memptr val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "MEMPTR", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final memptr[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      memptr[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "RAW", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final raw _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      raw val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "RAW", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final raw[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      raw[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "RECID", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final recid _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      recid val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "RECID", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final recid[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      recid[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "ROWID", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final rowid _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      rowid val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "ROWID", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final rowid[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      rowid[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "OBJECT", qualified = "progress.json.objectmodel.jsonarray", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray> _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray> val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val",  type = "OBJECT", qualified = "progress.json.objectmodel.jsonarray", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add(final integer _idx, final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray>[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray>[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "OBJECT", qualified = "progress.json.objectmodel.jsonobject", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add_1(final integer _idx, final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject> _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject> val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "Add", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val",  type = "OBJECT", qualified = "progress.json.objectmodel.jsonobject", mode = "INPUT", extent = -1)
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer add_1(final integer _idx, final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject>[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject>[] val = TypeFactory.initInput(_val);
      
      return function(this, "Add", integer.class, new Block((Body) () ->
      {
         addElementsImpl(idx, val);
      }));
   }
   
   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "AddNull")
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer addNull()
   {
      return function(this, "AddNull", integer.class, new Block((Body) () ->
      {
         addElement((Object) null);
         returnNormal(elements.size());
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "AddNull", parameters = 
   {
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer addNull(final integer _count)
   {
      integer count = TypeFactory.initInput(_count);
      
      return function(this, "AddNull", integer.class, new Block((Body) () ->
      {
         int cnt = count.isUnknown() ? 0 : count.intValue();
         
         if (cnt < 1)
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("count", this,
                     "AddNull", "Can not be less than 1 or UNKNOWN (?)."), 16074));
         }
         else
         {
            for (int i = 0; i < cnt; i++)
            {
               addElement((Object) null);
            }
            returnNormal(elements.size());
         }
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "AddNull", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer addNull(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return function(this, "AddNull", integer.class, new Block((Body) () ->
      {
         int idx2 = idx.isUnknown() ? 0 : idx.intValue();
         int cnt = count.isUnknown() ? 0 : count.intValue();
         
         if (idx2 < 1 || idx2 > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                     "AddNull", "Can not be less than 0, UNKNOWN (?) or larger than the size of the array."), 16073));
         }
         else if (cnt < 1)
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("count", this,
                     "AddNull", "Can not be less than 1 or UNKNOWN (?)."), 16074));
         }
         else
         {
            for (int i = 0; i < cnt; i++)
            {
               addSetElementImpl(idx2, (Object) null, true);
               idx2++;
            }

            returnNormal(elements.size());
         }
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "AddNumber", parameters = 
   {
      @LegacyParameter(name = "val", type = "CHARACTER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer addNumber(final character val)
   {
      return function(this, "AddNumber", integer.class, new Block((Body) () -> {
         returnNormal(addNumber(new integer(elements.size()), val));
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "AddNumber", parameters = 
   {
      @LegacyParameter(name = "val", type = "CHARACTER", extent = -1, mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer addNumber(final character[] _val)
   {
      character[] val = TypeFactory.initInput(_val);
      
      return function(this, "AddNumber", integer.class, new Block((Body) () ->
      {
         returnNormal(addNumber(new integer(elements.size()), val));
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "AddNumber", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "CHARACTER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer addNumber(final integer _idx, final character _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      character val = TypeFactory.initInput(_val);
      
      return function(this, "AddNumber", integer.class, new Block((Body) () ->
      {
         int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
         
         // index zero means add it to the start
         if (pos < 0 || pos > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                     "AddNumber", "Can not be less than 0, UNKNOWN (?) or larger than the size of the array."), 16073));
         }

         try
         {
            addSetElementImpl(pos, val.isUnknown() ? (Object) null : Double.parseDouble(val.getValue()), true);
         }
         catch (NumberFormatException e)
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("value", this,
                     "AddNumber", "Not a valid JSON number."), 16053));
         }
         
         returnNormal(pos + 1);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "AddNumber", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "CHARACTER", extent = -1, mode = "INPUT")
   })
   public integer addNumber(final integer _idx, final character[] _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      character[] val = TypeFactory.initInput(_val);
      
      return function(this, "AddNumber", integer.class, new Block((Body) () ->
      {
         int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
         
         // index zero means add it to the start
         if (pos < 0 || pos > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                     "AddNumber", "Can not be less than 0, UNKNOWN (?) or larger than the size of the array."), 16073));
         }

         if (val == null || val.length == 0)
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("array-value", this,
                     "AddNumber", "Can not be an indeterminate array."), 16081));
         }
         
         try
         {
            for (int i = 0; i < val.length; i++)
            {
               addSetElementImpl(pos + i, val[i].isUnknown() ? (Object) null : Double.parseDouble(val[i].getValue()), true);
            }
         }
         catch (Exception e)
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("value", this,
                     "AddNumber", "Not a valid JSON number."), 16053));
         }
         
         returnNormal(pos + val.length);
      }));
   }

   @LegacySignature(returns = "OBJECT", type = Type.METHOD, name = "Clone", qualified = "progress.lang.object")
   @Override
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public object<? extends com.goldencode.p2j.oo.lang._BaseObject_> legacyClone()
   {
      return function(this, "Clone", object.class, new Block((Body) () ->
      {
         object<JsonArray> cloned = ObjectOps.newInstance(JsonArray.class);
         for (int i = 0; i < elements.size(); i++)
         {
            Object val = elements.get(i);
            if (val instanceof JsonConstruct)
            {
               val = ((JsonConstruct) val).legacyClone().ref();
            }
            cloned.ref().addElement(val);
         }

         returnNormal(cloned);
      }));
   }

   @LegacySignature(returns = "CHARACTER", type = Type.METHOD, name = "GetCharacter", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public character getCharacter(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetCharacter", character.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetCharacter", 1, o -> new character((String) o), unknown::new);
      }));
   }

   @LegacySignature(returns = "CHARACTER", type = Type.METHOD, name = "GetCharacter", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public character[] getCharacter(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetCharacter", character.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetCharacter", 1, o -> new character((String) o), character::new);
      }));
   }

   @LegacySignature(returns = "COMHANDLE", type = Type.METHOD, name = "GetCOMHandle", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public comhandle getComhandle(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetCOMHandle", comhandle.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetCOMHandle", 2, o -> comhandle.fromResourceId(((Number) o).longValue()), comhandle::new);
      }));
   }

   @LegacySignature(returns = "COMHANDLE", type = Type.METHOD, name = "GetCOMHandle", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public comhandle[] getComhandle(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);

      return extentFunction(this, "GetCOMHandle", comhandle.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetCOMHandle", 2, o -> comhandle.fromResourceId(((Number) o).longValue()), comhandle::new);
      }));
   }

   @LegacySignature(returns = "DATE", type = Type.METHOD, name = "GetDate", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public date getDate(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);

      return function(this, "GetDate", date.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetDate", 1, o -> date.parseLiteral((String) o), date::new);
      }));
   }

   @LegacySignature(returns = "DATE", type = Type.METHOD, name = "GetDate", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public date[] getDate(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);

      return extentFunction(this, "GetDate", date.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetDate", 1, o -> date.parseLiteral((String) o), date::new);
      }));
   }

   @LegacySignature(returns = "DATETIME", type = Type.METHOD, name = "GetDatetime", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public datetime getDatetime(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetDatetime", datetime.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetDatetime", 1, o -> datetime.parseLiteral((String) o), datetime::new);
      }));
   }

   @LegacySignature(returns = "DATETIME", type = Type.METHOD, name = "GetDatetime", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public datetime[] getDatetime(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetDatetime", datetime.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetDatetime", 1, o -> datetime.parseLiteral((String) o), datetime::new);
      }));
   }

   @LegacySignature(returns = "DATETIMETZ", type = Type.METHOD, name = "GetDatetimeTZ", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public datetimetz getDatetimeTz(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetDatetimeTZ", datetimetz.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetDatetimeTZ", 1, o -> datetimetz.parseLiteral((String) o), datetimetz::new);
      }));
   }

   @LegacySignature(returns = "DATETIMETZ", type = Type.METHOD, name = "GetDatetimeTZ", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public datetimetz[] getDatetimeTz(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetDatetimeTZ", datetimetz.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetDatetimeTZ", 1, o -> datetimetz.parseLiteral((String) o), datetimetz::new);
      }));
   }

   @LegacySignature(returns = "DECIMAL", type = Type.METHOD, name = "GetDecimal", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public decimal getDecimal(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetDecimal", decimal.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetDecimal", 2, o -> new decimal((Number) o), decimal::new);
      }));
   }

   @LegacySignature(returns = "DECIMAL", type = Type.METHOD, name = "GetDecimal", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public decimal[] getDecimal(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetDecimal", decimal.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetDecimal", 2, o -> new decimal((Number) o), decimal::new);
      }));
   }

   @LegacySignature(returns = "HANDLE", type = Type.METHOD, name = "GetHandle", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public handle getHandle(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetHandle", handle.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetHandle", 2, o -> handle.fromResourceId(((Number) o).longValue()), handle::new);
      }));
   }

   @LegacySignature(returns = "HANDLE", type = Type.METHOD, name = "GetHandle", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public handle[] getHandle(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetHandle", handle.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetHandle", 2, o -> handle.fromResourceId(((Number) o).longValue()), handle::new);
      }));
   }

   @LegacySignature(returns = "INT64", type = Type.METHOD, name = "GetInt64", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public int64 getInt64(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetInt64", int64.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetInt64", 2, o -> new int64((Number) o), int64::new);
      }));
   }

   @LegacySignature(returns = "INT64", type = Type.METHOD, name = "GetInt64", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public int64[] getInt64(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetInt64", int64.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetInt64", 2, o -> new int64((Number) o), int64::new);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "GetInteger", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer getInteger(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetInteger", integer.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetInteger", 2, o -> new integer((Number) o), integer::new);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "GetInteger", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer[] getInteger(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetInteger", integer.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetInteger", 2, o -> new integer((Number) o), integer::new);
      }));
   }

   @LegacySignature(returns = "OBJECT", type = Type.METHOD, name = "GetJsonArray", qualified = "progress.json.objectmodel.jsonarray", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray> getJsonArray(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetJsonArray", object.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetJsonArray", 5, o -> new object((JsonArray) o), object::new);
      }));
   }

   @LegacySignature(returns = "OBJECT", type = Type.METHOD, name = "GetJsonArray", qualified = "progress.json.objectmodel.jsonarray", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray>[] getJsonArray(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetJsonArray", object.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetJsonArray", 5, o -> new object((JsonArray) o), object::new);
      }));
   }

   @LegacySignature(returns = "OBJECT", type = Type.METHOD, name = "GetJsonObject", qualified = "progress.json.objectmodel.jsonobject", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject> getJsonObject(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetJsonObject", object.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetJsonObject", 4, o -> new object((JsonObject) o), object::new);
      }));
   }

   @LegacySignature(returns = "OBJECT", type = Type.METHOD, name = "GetJsonObject", qualified = "progress.json.objectmodel.jsonobject", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject>[] getJsonObject(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetJsonObject", object.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetJsonObject", 4, o -> new object((JsonObject) o), object::new);
      }));
   }

   @LegacySignature(returns = "LONGCHAR", type = Type.METHOD, name = "GetJsonText")
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public longchar getJsonText()
   {
      return function(this, "GetJsonText", longchar.class, new Block((Body) () ->
      {
         getJsonTextImpl(this);
      }));
   }

   @LegacySignature(returns = "LONGCHAR", type = Type.METHOD, name = "GetJsonText", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public longchar getJsonText(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);

      return function(this, "GetJsonText", longchar.class, new Block((Body) () -> {
         int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
         
         if (pos < 1 || pos > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                     "GetJsonText", "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."), 16073));
         }
         
         Object val = elements.get(idx.intValue() - 1);
         
         try
         {
            returnNormal(getJsonText(val));
         }
         catch (IOException e)
         {
            LOG.severe("", e);
         }
      }));
   }

   @LegacySignature(returns = "LONGCHAR", type = Type.METHOD, name = "GetJsonText", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public longchar[] getJsonText(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetJsonText", longchar.class, new Block((Body) () ->
      {
         int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
         int cnt = count == null || count.isUnknown() ? -1 : count.intValue();

         if (pos < 1 || pos > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                     "GetJsonText",
                     "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."),
                     16073));
         }

         if (cnt < 1 || pos + cnt > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("count", this,
                     "GetJsonText",
                     "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."),
                     16073));
         }

         longchar[] res = new longchar[cnt];
         for (int i = 0; i < cnt; i++)
         {
            Object val = elements.get(pos + i - 1);

            try
            {
               res[i] = getJsonText(val);
            }
            catch (IOException e)
            {
               LOG.severe("", e);
            }
         }
         
         returnExtentNormal(res);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "GetLogical", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical getLogical(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetLogical", logical.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetLogical", 3, o -> new logical((Boolean) o), logical::new);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "GetLogical", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical[] getLogical(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetLogical", logical.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetLogical", 3, o -> new logical((Boolean) o), logical::new);
      }));
   }

   @LegacySignature(returns = "LONGCHAR", type = Type.METHOD, name = "GetLongchar", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public longchar getLongchar(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetLongchar", longchar.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetLongchar", 1, o -> new longchar((String) o), longchar::new);
      }));
   }

   @LegacySignature(returns = "LONGCHAR", type = Type.METHOD, name = "GetLongchar", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public longchar[] getLongchar(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetLongchar", longchar.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetLongchar", 1, o -> new longchar((String) o), longchar::new);
      }));
   }

   @LegacySignature(returns = "LONGCHAR", type = Type.METHOD, name = "GetLongchar", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "cp", type = "CHARACTER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public longchar getLongchar(final integer _idx, final character _cp)
   {
      integer idx = TypeFactory.initInput(_idx);
      character cp = TypeFactory.initInput(_cp);
      longchar res = TypeFactory.longchar();
      
      return function(this, "GetLongchar", longchar.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetLongchar", 1, o ->
         {
            if (!TextOps.isEmpty(cp))
               res.fixCodePage(cp);
            res.assign(o);
            
            return res;
         },
            longchar::new);
      }));
   }

   @LegacySignature(returns = "LONGCHAR", type = Type.METHOD, name = "GetLongchar", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "cp", type = "CHARACTER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public longchar[] getLongchar(final integer _idx, final integer _count, final character _cp)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      character cp = TypeFactory.initInput(_cp);
      longchar res = TypeFactory.longchar();
      
      return extentFunction(this, "GetLongchar", longchar.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetLongchar", 1, o ->
         {
            if (!TextOps.isEmpty(cp))
               res.fixCodePage(cp);
            res.assign(o);
            
            return res;
         },
            longchar::new);
      }));
   }

   @LegacySignature(returns = "MEMPTR", type = Type.METHOD, name = "GetMemptr", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public memptr getMemptr(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetMemptr", memptr.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetMemptr", 1, o -> new memptr(Base64.getDecoder().decode((String) o)), unknown::new);
      }));
   }

   @LegacySignature(returns = "MEMPTR", type = Type.METHOD, name = "GetMemptr", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public memptr[] getMemptr(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetMemptr", memptr.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetMemptr", 1, o -> new memptr(Base64.getDecoder().decode((String) o)), unknown::new);
      }));
   }

   @LegacySignature(returns = "RAW", type = Type.METHOD, name = "GetRaw", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public raw getRaw(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetRaw", raw.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetRaw", 1,
                        o -> new raw(Base64.getDecoder().decode((String) o)),
                        raw::instantiateUnknownRaw);
      }));
   }

   @LegacySignature(returns = "RAW", type = Type.METHOD, name = "GetRaw", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public raw[] getRaw(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetRaw", raw.class, new Block((Body) () ->
      {
         getElementsImpl(idx,
                         count,
                         "GetRaw", 1,
                         o -> new raw(Base64.getDecoder().decode((String) o)),
                         raw::instantiateUnknownRaw);
      }));
   }

   @LegacySignature(returns = "RECID", type = Type.METHOD, name = "GetRecid", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public recid getRecid(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetRecid", recid.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetRecid", 2, o -> new recid(((Number) o).longValue()), recid::new);
      }));
   }

   @LegacySignature(returns = "RECID", type = Type.METHOD, name = "GetRecid", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public recid[] getRecid(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetRecid", recid.class, new Block((Body) () ->
      {
         getElementsImpl(idx, count, "GetRecid", 2, o -> new recid(((Number) o).longValue()), recid::new);
      }));
   }

   @LegacySignature(returns = "ROWID", type = Type.METHOD, name = "GetRowid", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public rowid getRowid(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetRowid", rowid.class, new Block((Body) () ->
      {
         getElementImpl(idx, "GetRowid", 1, o ->
         {
            Base64.Decoder dec = Base64.getDecoder();
            return new rowid(Utils.bytesToLongLE(dec.decode((String) o)));
         },
            rowid::new);
      }));
   }

   @LegacySignature(returns = "ROWID", type = Type.METHOD, name = "GetRowid", extent = -1, parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public rowid[] getRowid(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return extentFunction(this, "GetRowid", rowid.class, new Block((Body) () ->
      {
         final Base64.Decoder dec = Base64.getDecoder();
         getElementsImpl(idx, count, "GetRowid", 1, o -> new rowid(Utils.bytesToLongLE(dec.decode((String) o))), rowid::new);
      }));
   }

   @LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "GetType", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public integer getType(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "GetType", integer.class, new Block((Body) () ->
      {
         int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
         
         if (pos < 1 || pos > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                     "GetType", "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."), 16073));
         }
         
         Object value = elements.get(pos - 1);
         returnNormal(new integer(JsonBackend.getJsonDataType(value)));
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "IsNull", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical isNull(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "IsNull", logical.class, new Block((Body) () ->
      {
         int idx2 = idx.isUnknown() ? 0 : idx.intValue();
         
         if (idx2 < 1 || idx2 > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                     "IsNull", "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."), 16073));
         }
         else 
         {
            Object val = elements.get(idx2 - 1);
            returnNormal(new logical(val == null));
         }
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Remove", parameters =
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical remove(final integer idx)
   {
      return function(this, "Remove", logical.class, new Block((Body) () ->
      {
         returnNormal(remove(idx, new integer(1)));
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Remove", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "count", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical remove(final integer _idx, final integer _count)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer count = TypeFactory.initInput(_count);
      
      return function(this, "Remove", logical.class, new Block((Body) () ->
      {
         int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue() - 1;
         int cnt = count == null || count.isUnknown() ? -1 : count.intValue();

         if (pos < 0 || pos >= elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                     "Remove",
                     "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."),
                     16073));
         }

         if (cnt < 1 || pos + cnt > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("count", this,
                     "Remove",
                     "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."),
                     16073));
         }
         
         for (int i = 0; i < cnt; i++)
         {
            Object o = elements.remove(pos);
            if (o instanceof JsonConstruct)
            {
               ObjectOps.decrement((_BaseObject_) o);
            }
         }
         
         returnNormal(new logical(true));
         
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "CHARACTER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final character _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      character val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "COMHANDLE", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final comhandle _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      comhandle val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DATE", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final date _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      date val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DATETIME", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final datetime _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      datetime val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DATETIMETZ", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final datetimetz _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      datetimetz val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "DECIMAL", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final decimal _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      decimal val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "HANDLE", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final handle _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      handle val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "INT64", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final int64 _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      int64 val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final integer _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      integer val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "LOGICAL", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final logical _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      logical val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "LONGCHAR", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final longchar _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      longchar val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "MEMPTR", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final memptr _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      memptr val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "RAW", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final raw _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      raw val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "RECID", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final recid _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      recid val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "ROWID", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final rowid _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      rowid val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "OBJECT", qualified = "progress.json.objectmodel.jsonarray", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set(final integer _idx, final object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray> _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonArray> val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Set", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "OBJECT", qualified = "progress.json.objectmodel.jsonobject", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical set_1(final integer _idx, final object<?
   extends com.goldencode.p2j.oo.json.objectmodel.JsonObject> _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      object<? extends com.goldencode.p2j.oo.json.objectmodel.JsonObject> val = TypeFactory.initInput(_val);
      
      return function(this, "Set", logical.class, new Block((Body) () ->
      {
         setElementImpl(idx, val);
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "SetNull", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical setNull(final integer _idx)
   {
      integer idx = TypeFactory.initInput(_idx);
      
      return function(this, "SetNull", logical.class, new Block((Body) () ->
      {
         int idx2 = idx.isUnknown() ? 0 : idx.intValue();
         
         if (idx2 < 1 || idx2 > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                     "SetNull", "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."), 16073));
         }
         else 
         {
            addSetElementImpl(idx2 - 1, (Object) null, false);
            returnNormal(idx2 + 1);
         }
      }));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "SetNumber", parameters = 
   {
      @LegacyParameter(name = "idx", type = "INTEGER", mode = "INPUT"),
      @LegacyParameter(name = "val", type = "CHARACTER", mode = "INPUT")
   })
   @LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
   public logical setNumber(final integer _idx, final character _val)
   {
      integer idx = TypeFactory.initInput(_idx);
      character val = TypeFactory.initInput(_val);
      
      return function(this, "SetNumber", logical.class, new Block((Body) () ->
      {
         int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
         
         if (pos < 1 || pos > elements.size())
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                     "SetNumber", "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."), 16073));
         }

         try
         {
            addSetElementImpl(pos - 1, val.isUnknown() ? null : Double.parseDouble(val.getValue()), false);
         }
         catch (Exception e)
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("value", this,
                     "SetNumber", "Not a valid JSON number."), 16053));
         }
         
         returnNormal(pos + 1);
      }));
   }

   /**
    * Adds a json element (object property or array element) to the json object.
    *
    * @param   name
    *          Name of the json element. This parameter is ignored if this is a json array.
    * @param   value
    *          Value of the json element.
    */
   @Override
   public void addElement(String name, object<? extends JsonConstruct> value)
   {
      addElement(value.ref());
   }

   /**
    * Adds a json element (object property or array element) to the json object.
    *
    * @param   name
    *          Name of the json element. This parameter is ignored if this is a json array.
    * @param   value
    *          Value of the json element.
    */
   @Override
   public void addElement(String name, String value)
   {
      addElement(value);
   }

   /**
    * Adds a json element (object property or array element) to the json object.
    *
    * @param   name
    *          Name of the json element. This parameter is ignored if this is a json array.
    * @param   value
    *          Value of the json element.
    */
   @Override
   public void addElement(String name, Number value)
   {
      addElement(value);
   }

   /**
    * Adds a json element (object property or array element) to the json object.
    *
    * @param   name
    *          Name of the json element. This parameter is ignored if this is a json array.
    * @param   value
    *          Value of the json element.
    */
   @Override
   public void addElement(String name, Boolean value)
   {
      addElement(value);
   }

   /**
    * Adds null json element (object property or array element) to the json object.
    *
    * @param   name
    *          Name of the json element. This parameter is ignored if this is a json array.
    */
   @Override
   public void addElementNull(String name)
   {
      addElement(null);
   }

   /**
    * Returns the array elements of this json array instance.
    *
    * @return  see above.
    */
   public Iterable<Object> getElements()
   {
      return elements;
   }

   /**
    * Removes all values from this json object or array.
    */
   protected void clear()
   {
      for (int i = 0; i < elements.size(); i++)
      {
         Object o = elements.get(i);
         if (o instanceof JsonConstruct)
         {
            ObjectOps.decrement((_BaseObject_) o);
         }
      }

      elements.clear();
   }

   /**
    * Implements the class constructor for adding multiple array elements to this instance.
    *
    * @param   elements
    *          The values to use as the initial json elements.
    */
   private void addElementsCtorImpl(BaseDataType[] elements)
   {
      if (elements == null || elements.length == 0)
      {
         undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("initial-value", this,
                  "JsonArray", "Can not be an indeterminate array."), 16081));
      }
      
      for (BaseDataType element : elements)
      {
         addElement(JsonBackend.convertLegacyValueToJson(element));
      }
   }

   /**
    * Implements the {@code add} legacy methods for adding multiple array elements to this instance.
    *
    * @param   elements
    *          The values to use as the initial json elements.
    */
   private void addElementsImpl(BaseDataType[] elements)
   {
      addElementsImpl(new integer(this.elements.size()), elements);
   }

   /**
    * Implements the {@code add} legacy methods for adding multiple array elements to this instance.
    *
    * @param   idx
    *          The 1-based array index where the element should be added.
    * @param   items
    *          The values to use as the initial json elements.
    */
   private void addElementsImpl(integer idx, BaseDataType[] items)
   {
      returnNormal(addElements(idx, items));
   }
   
   /**
    * Implements the {@code add} legacy methods for adding multiple array elements to this instance.
    *
    * @param   idx
    *          The 1-based array index where the element should be added.
    * @param   items
    *          The values to use as the initial json elements.
    */
   private int addElements(integer idx, BaseDataType[] items)
   {
      int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
      
      // index zero means add it to the start
      if (pos < 0 || pos > elements.size())
      {
         undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                  "Add", "Can not be less than 0, UNKNOWN (?) or larger than the size of the array."), 16073));
      }
      
      if (items == null || items.length == 0)
      {
         undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("array-value", this,
                  "Add", "Can not be an indeterminate array."), 16081));
      }
      
      for (int i = 0; i < items.length; i++)
      {
         addSetElementImpl(pos + i, JsonBackend.convertLegacyValueToJson(items[i]), true);
      }

      return pos + items.length;
   }
   
   /**
    * Implements the {@code add} legacy methods for adding single element to this instance.
    *
    * @param   element
    *          The values to use as the initial json elements.
    */
   private void addElementImpl(BaseDataType element)
   {
      addElementImpl(new integer(elements.size()), element);
   }

   /**
    * Implements the {@code add} legacy methods for adding single element to this instance.
    *
    * @param   idx
    *          The 1-based array index where the element should be added.
    * @param   element
    *          The values to use as the initial json elements.
    */
   private void addElementImpl(integer idx, BaseDataType element)
   {
      int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
      
      // index zero means add it to the start
      if (pos < 0 || pos > elements.size())
      {
         undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                  "Add", "Can not be less than 0, UNKNOWN (?) or larger than the size of the array."), 16073));
      }
      
      addSetElementImpl(pos, element, true);
   }

   /**
    * Implements the {@code set} legacy methods for adding single element to this instance.
    *
    * @param   idx
    *          The 1-based array index where the element should be added.
    * @param   element
    *          The values to use as the initial json elements.
    */
   private void setElementImpl(integer idx, BaseDataType element)
   {
      int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
      
      if (pos < 1 || pos > elements.size())
      {
         undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                  "Set", "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."), 16073));
      }
      
      addSetElementImpl(pos - 1, element, false);
   }

   /**
    * Implements the {@code add} and {@code set} legacy methods for adding single element to this instance.
    *
    * @param   idx
    *          The 1-based array index where the element should be added.
    * @param   element
    *          The values to use as the initial json elements.
    * @param   add
    *          If set to {@code true} the method will implement semantics of {@code add} legacy methods. If
    *          {@code false} the method will implement semantics of the {@code set} legacy methods.
    */
   private void addSetElementImpl(int idx, BaseDataType element, boolean add)
   {
      addSetElementImpl(idx, JsonBackend.convertLegacyValueToJson(element), add);
      
      returnNormal(add ? new integer(idx + 1) : new logical(true));
   }
   
   /**
    * Implements the {@code add} and {@code set} legacy methods for adding single element to this instance.
    *
    * @param   idx
    *          The 1-based array index where the element should be added.
    * @param   element
    *          The values to use as the initial json elements.
    * @param   add
    *          If set to {@code true} the method will implement semantics of {@code add} legacy methods. If
    *          {@code false} the method will implement semantics of the {@code set} legacy methods.
    */
   private void addSetElementImpl(int idx, Object element, boolean add)
   {
      
      if (element != null && element instanceof JsonConstruct)
      {
         ObjectOps.increment((_BaseObject_) element);
      }

      if (add)
      {
         if (idx > elements.size()) 
         {
            elements.add(element);
         }
         else 
         {
            elements.add(idx, element);
         }
      }
      else
      {
         elements.set(idx, element);
      }
   }

   /**
    * Adds an element to the json array instance. The supported types are {@linkplain JsonConstruct},
    * {@linkplain String}, {@linkplain Number}, {@linkplain Boolean}, or {@code null}. It is up to the
    * caller to supply the correct type.
    *
    * @param   value
    *          The value to add.
    */
   private void addElement(Object value)
   {
      addSetElementImpl(elements.size() + 1, value, true);
   }

   /**
    * Implements the {@code get} legacy methods.
    *
    * @param   idx
    *          The 1-based index of the json array element to retrieve.
    * @param   method
    *          The actual 'get' method name, used for error message.
    * @param   type
    *          The expected JSON type.
    * @param   converter
    *          The function that will convert the stored Java element instance to a legacy instance.
    * @param   nullSupplier
    *          When the stored element is {@code null} this supplier will be used to retrieve the
    *          corresponding legacy value.
    */
   private void getElementImpl(integer idx,
                               String method,
                               int type,
                               Function<Object, BaseDataType> converter,
                               Supplier<BaseDataType> nullSupplier)
   {
      int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
      
      if (pos < 1 || pos > elements.size())
      {
         undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                  method, "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."), 16073));
      }
      
      Object val = elements.get(pos - 1);
      int vtype = JsonBackend.getJsonDataType(val);
      
      if (vtype == 6)
         returnNormal(nullSupplier.get());
      
      if (vtype != type)
      {
         undoThrow(JsonError.newInstance(String.format("Call to Progress.Json.ObjectModel.JsonArray:%s( ) failed. Expected a JSON %s value, found a JSON %s value.", 
                  method, JsonBackend.getJsonDataTypeName(type), JsonBackend.getJsonDataTypeName(vtype)), 16060));
      }

      BaseDataType res = null;
      try
      {
         res = converter.apply(val);
      }
      catch(Exception ex)
      {
         LOG.log(Level.WARNING, "", ex);
         returnError(ObjectOps.newInstance(JsonError.class));
      }

      returnNormal(res);
   }

   /**
    * Implements the {@code get} legacy methods.
    *
    * @param   idx
    *          The 1-based index of the json array element to retrieve.
    * @param   count
    *          The number of array elements to retrieve.
    * @param   converter
    *          The function that will convert the stored Java element instance to a legacy instance.
    * @param   nullSupplier
    *          When the stored element is {@code null} this supplier will be used to retrieve the
    *          corresponding legacy value.
    */
   private void getElementsImpl(integer idx, integer count, String method, int type,
            Function<Object, BaseDataType> converter, Supplier<BaseDataType> nullSupplier)
   {
      int pos = idx == null || idx.isUnknown() ? -1 : idx.intValue();
      int cnt = count == null || count.isUnknown() ? -1 : count.intValue();

      if (pos < 1 || pos > elements.size())
      {
         undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("index", this,
                  method,
                  "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."),
                  16073));
      }

      if (cnt < 1 || pos + cnt - 1 > elements.size())
      {
         undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("count", this,
                  method,
                  "Can not be less than 1, UNKNOWN (?) or larger than the size of the array."),
                  16073));
      }

      BaseDataType[] res = new BaseDataType[cnt];
      for (int i = 0; i < cnt; i++)
      {
         Object val = elements.get(pos + i - 1);

         int vtype = JsonBackend.getJsonDataType(val);

         if (vtype == 6)
            res[i] = nullSupplier.get();

         if (vtype != type)
         {
            undoThrow(JsonError.newInstance(String.format(
                     "Call to Progress.Json.ObjectModel.JsonArray:%s( ) failed. Expected a JSON %s value, found a JSON %s value.",
                     method, JsonBackend.getJsonDataTypeName(type), JsonBackend.getJsonDataTypeName(vtype)), 16060));
         }

         res[i] = converter.apply(val);

      }

      returnExtentNormal(res);

   }
   
   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Read", parameters = 
   {
      @LegacyParameter(name = "htt", type = "HANDLE", mode = "INPUT")
   })
   public logical read(final handle htt)
   {
      return read(htt, new logical(false));
   }

   @LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "Read", parameters = 
   {
      @LegacyParameter(name = "htt", type = "HANDLE", mode = "INPUT"),
      @LegacyParameter(name = "omit", type = "LOGICAL", mode = "INPUT")
   })
   public logical read(final handle _htt, final logical _omit)
   {
      handle htt = TypeFactory.initInput(_htt);
      logical omit = TypeFactory.initInput(_omit);
      
      return function(this, "Read", logical.class, new Block((Body) () -> {
         if (!htt._isValid() || !htt.isType("TEMP-TABLE")) 
         {
            undoThrow(JsonError.newInstance(ErrorManager.getInvalidParameterError("temp-table handle", this,
                     "Read", "Not initialized or not a handle to a TEMP-TABLE."), 16070));
         }
         
         TempTable tmpTable = htt.unwrapTempTable();
         TemporaryBuffer tmpBuffer = 
            (TemporaryBuffer) ((BufferReference) tmpTable.defaultBufferHandleNative()).buffer();
         
         // remove current content
         clear();
         
         ObjectBuilder jb = new ObjectBuilder(this);
         JsonExport export = new JsonExport();
         try
         {
            export.serializeTempTable(jb, tmpBuffer, true, !omit.isUnknown() && omit.booleanValue());
            returnNormal(true);
         }
         catch (IOException e)
         {
            LOG.log(Level.WARNING, "", e);
            returnError(ObjectOps.newInstance(JsonError.class));
         }
      }));
   }
   
   @Override
   protected void throwStreamNotFound (String streamName) {
      undoThrow(JsonError.newInstance(String.format("Invalid stream parameter to Progress.Json.ObjectModel.JsonArray:WriteStream( ). Could not find open stream \"%s\".", streamName), 16062));
   }
}