/// <summary>
        /// Method for copying contents of the current event
        /// <b>and following events that it encloses</b>
        /// the given parser instance points to.
        /// </summary>
        /// <remarks>
        /// Method for copying contents of the current event
        /// <b>and following events that it encloses</b>
        /// the given parser instance points to.
        /// <p>
        /// So what constitutes enclosing? Here is the list of
        /// events that have associated enclosed events that will
        /// get copied:
        /// <ul>
        /// <li>
        /// <see cref="JsonToken.START_OBJECT"/>
        /// :
        /// all events up to and including matching (closing)
        /// <see cref="JsonToken.END_OBJECT"/>
        /// will be copied
        /// </li>
        /// <li>
        /// <see cref="JsonToken.START_ARRAY"/>
        /// all events up to and including matching (closing)
        /// <see cref="JsonToken.END_ARRAY"/>
        /// will be copied
        /// </li>
        /// <li>
        /// <see cref="JsonToken.FIELD_NAME"/>
        /// the logical value (which
        /// can consist of a single scalar value; or a sequence of related
        /// events for structured types (Json Arrays, Objects)) will
        /// be copied along with the name itself. So essentially the
        /// whole <b>field entry</b> (name and value) will be copied.
        /// </li>
        /// </ul>
        /// <p>
        /// After calling this method, parser will point to the
        /// <b>last event</b> that was copied. This will either be
        /// the event parser already pointed to (if there were no
        /// enclosed events), or the last enclosed event copied.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        public virtual void copyCurrentStructure(com.fasterxml.jackson.core.JsonParser jp
            )
        {
            com.fasterxml.jackson.core.JsonToken t = jp.getCurrentToken();
            if (t == null)
            {
                _reportError("No current event to copy");
            }
            // Let's handle field-name separately first
            int id = t.id();
            if (id == JsonTokenIdConstants.ID_FIELD_NAME)
            {
                writeFieldName(jp.getCurrentName());
                t = jp.nextToken();
                id = t.id();
            }
            switch (id)
            {
                case JsonTokenIdConstants.ID_START_OBJECT:
                {
                    // fall-through to copy the associated value
                    writeStartObject();
                    while (jp.nextToken() != com.fasterxml.jackson.core.JsonToken.END_OBJECT)
                    {
                        copyCurrentStructure(jp);
                    }
                    writeEndObject();
                    break;
                }

                case JsonTokenIdConstants.ID_START_ARRAY:
                {
                    writeStartArray();
                    while (jp.nextToken() != com.fasterxml.jackson.core.JsonToken.END_ARRAY)
                    {
                        copyCurrentStructure(jp);
                    }
                    writeEndArray();
                    break;
                }

                default:
                {
                    copyCurrentEvent(jp);
                    break;
                }
            }
        }
        /*
        /**********************************************************
        /* Public API, copy-through methods
        /**********************************************************
        */
        /// <summary>
        /// Method for copying contents of the current event that
        /// the given parser instance points to.
        /// </summary>
        /// <remarks>
        /// Method for copying contents of the current event that
        /// the given parser instance points to.
        /// Note that the method <b>will not</b> copy any other events,
        /// such as events contained within Json Array or Object structures.
        /// <p>
        /// Calling this method will not advance the given
        /// parser, although it may cause parser to internally process
        /// more data (if it lazy loads contents of value events, for example)
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        public virtual void copyCurrentEvent(com.fasterxml.jackson.core.JsonParser jp)
        {
            com.fasterxml.jackson.core.JsonToken t = jp.getCurrentToken();
            // sanity check; what to do?
            if (t == null)
            {
                _reportError("No current event to copy");
            }
            switch (t.id())
            {
                case JsonTokenIdConstants.ID_NOT_AVAILABLE:
                {
                    _reportError("No current event to copy");
                    goto case JsonTokenIdConstants.ID_START_OBJECT;
                }

                case JsonTokenIdConstants.ID_START_OBJECT:
                {
                    writeStartObject();
                    break;
                }

                case JsonTokenIdConstants.ID_END_OBJECT:
                {
                    writeEndObject();
                    break;
                }

                case JsonTokenIdConstants.ID_START_ARRAY:
                {
                    writeStartArray();
                    break;
                }

                case JsonTokenIdConstants.ID_END_ARRAY:
                {
                    writeEndArray();
                    break;
                }

                case JsonTokenIdConstants.ID_FIELD_NAME:
                {
                    writeFieldName(jp.getCurrentName());
                    break;
                }

                case JsonTokenIdConstants.ID_STRING:
                {
                    if (jp.hasTextCharacters())
                    {
                        writeString(jp.getTextCharacters(), jp.getTextOffset(), jp.getTextLength());
                    }
                    else
                    {
                        writeString(jp.getText());
                    }
                    break;
                }

                case JsonTokenIdConstants.ID_NUMBER_INT:
                {
                    com.fasterxml.jackson.core.JsonParser.NumberType n = jp.getNumberType();
                    if (n == com.fasterxml.jackson.core.JsonParser.NumberType.INT)
                    {
                        writeNumber(jp.getIntValue());
                    }
                    else
                    {
                        if (n == com.fasterxml.jackson.core.JsonParser.NumberType.BIG_INTEGER)
                        {
                            writeNumber(jp.getBigIntegerValue());
                        }
                        else
                        {
                            writeNumber(jp.getLongValue());
                        }
                    }
                    break;
                }

                case JsonTokenIdConstants.ID_NUMBER_FLOAT:
                {
                    com.fasterxml.jackson.core.JsonParser.NumberType n = jp.getNumberType();
                    if (n == com.fasterxml.jackson.core.JsonParser.NumberType.BIG_DECIMAL)
                    {
                        writeNumber(jp.getDecimalValue());
                    }
                    else
                    {
                        if (n == com.fasterxml.jackson.core.JsonParser.NumberType.FLOAT)
                        {
                            writeNumber(jp.getFloatValue());
                        }
                        else
                        {
                            writeNumber(jp.getDoubleValue());
                        }
                    }
                    break;
                }

                case JsonTokenIdConstants.ID_TRUE:
                {
                    writeBoolean(true);
                    break;
                }

                case JsonTokenIdConstants.ID_FALSE:
                {
                    writeBoolean(false);
                    break;
                }

                case JsonTokenIdConstants.ID_NULL:
                {
                    writeNull();
                    break;
                }

                case JsonTokenIdConstants.ID_EMBEDDED_OBJECT:
                {
                    writeObject(jp.getEmbeddedObject());
                    break;
                }

                default:
                {
                    _throwInternal();
                    break;
                }
            }
        }