Package org.apache.derby.iapi.types

Examples of org.apache.derby.iapi.types.StringDataValue


    boolean pushStack = false;
    try {

            useStreamOrLOB(columnIndex);

            StringDataValue dvd = (StringDataValue)getColumn(columnIndex);

      if (wasNull = dvd.isNull()) { return null; }

      pushStack = true;
      setupContextStack();

            java.io.Reader ret; // The reader we will return to the user
            if (dvd.hasStream()) {
                CharacterStreamDescriptor csd = dvd.getStreamWithDescriptor();
                // See if we have to enforce a max field size.
                if (lmfs > 0) {
                    csd = new CharacterStreamDescriptor.Builder().copyState(csd).
                            maxCharLength(lmfs).build();
                }
                ret = new UTF8Reader(csd, this, syncLock);
            } else {
        String val = dvd.getString();
        if (lmfs > 0) {
          if (val.length() > lmfs)
            val = val.substring(0, lmfs);
        }
                ret = new java.io.StringReader(val);
View Full Code Here


    ValueNode evaluateConstantExpressions() throws StandardException {
        if (leftOperand instanceof CharConstantNode &&
                rightOperand instanceof CharConstantNode) {
            CharConstantNode leftOp = (CharConstantNode) leftOperand;
            CharConstantNode rightOp = (CharConstantNode) rightOperand;
            StringDataValue leftValue = (StringDataValue) leftOp.getValue();
            StringDataValue rightValue = (StringDataValue) rightOp.getValue();

            StringDataValue resultValue =
                    (StringDataValue) getTypeServices().getNull();
            resultValue.concatenate(leftValue, rightValue, resultValue);

            return (ValueNode) getNodeFactory().getNode(
                    C_NodeTypes.CHAR_CONSTANT_NODE,
                    resultValue.getString(),
                    getContextManager());
        }

        return this;
    }
View Full Code Here

    boolean pushStack = false;
    try {

            useStreamOrLOB(columnIndex);

            StringDataValue dvd = (StringDataValue)getColumn(columnIndex);

      if (wasNull = dvd.isNull()) { return null; }

      pushStack = true;
      setupContextStack();

            java.io.Reader ret; // The reader we will return to the user
            if (dvd.hasStream()) {
                CharacterStreamDescriptor csd = dvd.getStreamWithDescriptor();
                // See if we have to enforce a max field size.
                if (lmfs > 0) {
                    csd = new CharacterStreamDescriptor.Builder().copyState(csd).
                            maxCharLength(lmfs).build();
                }
                ret = new UTF8Reader(csd, this, syncLock);
            } else {
        String val = dvd.getString();
        if (lmfs > 0) {
          if (val.length() > lmfs)
            val = val.substring(0, lmfs);
        }
                ret = new java.io.StringReader(val);
View Full Code Here

            {
                updateNull(columnIndex);
                return;
            }
           
            final StringDataValue dvd = (StringDataValue)
                    getDVDforColumnToBeUpdated(columnIndex, updateMethodName);
            // In the case of updatable result sets, we cannot guarantee that a
            // context is pushed when the header needs to be generated. To fix
            // this, tell the DVD/generator which header format to use.
            dvd.setStreamHeaderFormat(Boolean.valueOf(
                    !getEmbedConnection().getDatabase().getDataDictionary().
                    checkVersion(DataDictionary.DD_VERSION_DERBY_10_5, null)));
            ReaderToUTF8Stream utfIn;
            int usableLength = DataValueDescriptor.UNKNOWN_LOGICAL_LENGTH;
            if (!lengthLess) {
                // check for -ve length here
                if (length < 0)
                    throw newSQLException(SQLState.NEGATIVE_STREAM_LENGTH);

                // max number of characters that can be set to be inserted
                // in Derby is 2Gb-1 (ie Integer.MAX_VALUE).
                // (e.g into a CLOB column).
                if (length > Integer.MAX_VALUE ) {
                    throw newSQLException(
                            SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE,
                            getColumnSQLType(columnIndex));
                }

                // length is +ve. at this point, all checks for negative
                // length has already been done
                usableLength = (int) length;
                int truncationLength = 0;

                // Currently long varchar does not allow for truncation of
                // trailing blanks.  For char and varchar types, current
                // mechanism of materializing when using streams seems fine
                // given their max limits. This change is fix for DERBY-352:
                // Insert of clobs using streams should not materialize the
                // entire stream into memory
                // In case of clobs, the truncation of trailing blanks is
                // factored in when reading from the stream without
                // materializing the entire stream, and so the special casing
                // for clob below.
                if (getColumnType(columnIndex) == Types.CLOB) {
                    // Need column width to figure out if truncation is
                    // needed
                    int colWidth = getMaxColumnWidth(columnIndex);

                    // It is possible that the length of the stream passed in
                    // is greater than the column width, in which case the data
                    // from the stream needs to be truncated.
                    // usableLength is the length of the data from stream
                    // that can be used which is min(colWidth,length) provided
                    // length - colWidth has trailing blanks only
                    if (usableLength > colWidth) {
                        truncationLength = usableLength - colWidth;
                        usableLength = colWidth;
                    }
                }

                utfIn = new ReaderToUTF8Stream(reader, usableLength,
                        truncationLength, getColumnSQLType(columnIndex),
                        dvd.getStreamHeaderGenerator());
            } else {
                int colWidth = getMaxColumnWidth(columnIndex);
                utfIn = new ReaderToUTF8Stream(reader, colWidth,
                                               getColumnSQLType(columnIndex),
                                               dvd.getStreamHeaderGenerator());
            }

            dvd.setValue(utfIn, usableLength);
        } catch (StandardException t) {
            throw noStateChangeException(t);
        }
  }
View Full Code Here

      boolean pushStack = false;
            EmbedConnection ec = getEmbedConnection();
      try {

        StringDataValue dvd = (StringDataValue)getColumn(columnIndex);
                LanguageConnectionContext lcc = ec.getLanguageConnection();

                if (wasNull = dvd.isNull()) {
                    InterruptStatus.restoreIntrFlagIfSeen();
          return null;
                }

                // Set up a context stack if we have CLOB whose value is a long
                // column in the database.
                if (dvd.hasStream()) {
                    pushStack = true;
                    setupContextStack();
                }

                EmbedClob result =  new EmbedClob(ec, dvd);
View Full Code Here

    ValueNode evaluateConstantExpressions() throws StandardException {
        if (leftOperand instanceof CharConstantNode &&
                rightOperand instanceof CharConstantNode) {
            CharConstantNode leftOp = (CharConstantNode) leftOperand;
            CharConstantNode rightOp = (CharConstantNode) rightOperand;
            StringDataValue leftValue = (StringDataValue) leftOp.getValue();
            StringDataValue rightValue = (StringDataValue) rightOp.getValue();

            StringDataValue resultValue =
                    (StringDataValue) getTypeServices().getNull();
            resultValue.concatenate(leftValue, rightValue, resultValue);

            return (ValueNode) getNodeFactory().getNode(
                    C_NodeTypes.CHAR_CONSTANT_NODE,
                    resultValue.getString(),
                    getContextManager());
        }

        return this;
    }
View Full Code Here

               throw newSQLException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE,
                                     getParameterSQLType(parameterIndex));

        try {
            ReaderToUTF8Stream utfIn;
            final StringDataValue dvd = (StringDataValue)
                    getParms().getParameter(parameterIndex -1);
            dvd.setStreamHeaderFormat(usePreTenFiveHdrFormat());
            // Need column width to figure out if truncation is needed
            DataTypeDescriptor dtd[] = preparedStatement
                    .getParameterTypes();
            int colWidth = dtd[parameterIndex - 1].getMaximumWidth();
            // Holds either UNKNOWN_LOGICAL_LENGTH or the exact logical length.
            int usableLength = DataValueDescriptor.UNKNOWN_LOGICAL_LENGTH;

            if (!lengthLess) {
                // We cast the length from long to int. This wouldn't be
                // appropriate if the limit of 2G-1 is decided to be increased
                // at a later stage.
                usableLength = (int)length;
                int truncationLength = 0;

                // Currently long varchar does not allow for truncation of
                // trailing blanks.
                // For char and varchar types, current mechanism of
                // materializing when using streams seems fine given their max
                // limits.
                // This change is fix for DERBY-352: Insert of clobs using
                // streams should not materialize the entire stream into memory
                // In case of clobs, the truncation of trailing blanks is
                // factored in when reading from the stream without
                // materializing the entire stream, and so the special casing
                // for clob below.
                if (jdbcTypeId == Types.CLOB)
                {

                    // It is possible that the length of the stream passed in
                    // is greater than the column width, in which case the data
                    // from the stream needs to be truncated.
                    // usableLength is the length of the data from stream that
                    // can be inserted which is min(colWidth,length) provided
                    // length - colWidth has trailing blanks only
                    if (usableLength > colWidth) {
                        truncationLength = usableLength - colWidth;
                        usableLength = colWidth;
                    }
                }
                // Create a stream with truncation.
                utfIn = new ReaderToUTF8Stream(reader, usableLength,
                        truncationLength, getParameterSQLType(parameterIndex),
                        dvd.getStreamHeaderGenerator());
            } else {
                // Create a stream without exactness checks,
                // but with a maximum limit.
                utfIn = new ReaderToUTF8Stream(reader, colWidth,
                        getParameterSQLType(parameterIndex),
                        dvd.getStreamHeaderGenerator());
            }

            // JDBC is one-based, DBMS is zero-based.
            // Note that for lengthless stream, usableLength will be
            // the maximum length for the column.
View Full Code Here

    boolean pushStack = false;
    try {

            useStreamOrLOB(columnIndex);

            StringDataValue dvd = (StringDataValue)getColumn(columnIndex);

      if (wasNull = dvd.isNull()) { return null; }

      pushStack = true;
      setupContextStack();

            java.io.Reader ret; // The reader we will return to the user
            if (dvd.hasStream()) {
                CharacterStreamDescriptor csd = dvd.getStreamWithDescriptor();
                // See if we have to enforce a max field size.
                if (lmfs > 0) {
                    csd = new CharacterStreamDescriptor.Builder().copyState(csd).
                            maxCharLength(lmfs).build();
                }
                ret = new UTF8Reader(csd, this, syncLock);
            } else {
        String val = dvd.getString();
        if (lmfs > 0) {
          if (val.length() > lmfs)
            val = val.substring(0, lmfs);
        }
                ret = new java.io.StringReader(val);
View Full Code Here

            {
                updateNull(columnIndex);
                return;
            }
           
            final StringDataValue dvd = (StringDataValue)
                    getDVDforColumnToBeUpdated(columnIndex, updateMethodName);
            // In the case of updatable result sets, we cannot guarantee that a
            // context is pushed when the header needs to be generated. To fix
            // this, tell the DVD/generator which header format to use.
            dvd.setStreamHeaderFormat(Boolean.valueOf(
                    !getEmbedConnection().getDatabase().getDataDictionary().
                    checkVersion(DataDictionary.DD_VERSION_DERBY_10_5, null)));
            ReaderToUTF8Stream utfIn;
            int usableLength = DataValueDescriptor.UNKNOWN_LOGICAL_LENGTH;
            if (!lengthLess) {
                // check for -ve length here
                if (length < 0)
                    throw newSQLException(SQLState.NEGATIVE_STREAM_LENGTH);

                // max number of characters that can be set to be inserted
                // in Derby is 2Gb-1 (ie Integer.MAX_VALUE).
                // (e.g into a CLOB column).
                if (length > Integer.MAX_VALUE ) {
                    throw newSQLException(
                            SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE,
                            getColumnSQLType(columnIndex));
                }

                // length is +ve. at this point, all checks for negative
                // length has already been done
                usableLength = (int) length;
                int truncationLength = 0;

                // Currently long varchar does not allow for truncation of
                // trailing blanks.  For char and varchar types, current
                // mechanism of materializing when using streams seems fine
                // given their max limits. This change is fix for DERBY-352:
                // Insert of clobs using streams should not materialize the
                // entire stream into memory
                // In case of clobs, the truncation of trailing blanks is
                // factored in when reading from the stream without
                // materializing the entire stream, and so the special casing
                // for clob below.
                if (getColumnType(columnIndex) == Types.CLOB) {
                    // Need column width to figure out if truncation is
                    // needed
                    int colWidth = getMaxColumnWidth(columnIndex);

                    // It is possible that the length of the stream passed in
                    // is greater than the column width, in which case the data
                    // from the stream needs to be truncated.
                    // usableLength is the length of the data from stream
                    // that can be used which is min(colWidth,length) provided
                    // length - colWidth has trailing blanks only
                    if (usableLength > colWidth) {
                        truncationLength = usableLength - colWidth;
                        usableLength = colWidth;
                    }
                }

                utfIn = new ReaderToUTF8Stream(reader, usableLength,
                        truncationLength, getColumnSQLType(columnIndex),
                        dvd.getStreamHeaderGenerator());
            } else {
                int colWidth = getMaxColumnWidth(columnIndex);
                utfIn = new ReaderToUTF8Stream(reader, colWidth,
                                               getColumnSQLType(columnIndex),
                                               dvd.getStreamHeaderGenerator());
            }

            dvd.setValue(utfIn, usableLength);
        } catch (StandardException t) {
            throw noStateChangeException(t);
        }
  }
View Full Code Here

        throw dataTypeConversion("java.sql.Clob", columnIndex);

      boolean pushStack = false;
      try {

        StringDataValue dvd = (StringDataValue)getColumn(columnIndex);

        if (wasNull = dvd.isNull())
          return null;

                // Set up a context stack if we have CLOB whose value is a long
                // column in the database.
                if (dvd.hasStream()) {
                    pushStack = true;
                    setupContextStack();
                }

                return new EmbedClob(getEmbedConnection(), dvd);
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.types.StringDataValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.