Package org.apache.derby.iapi.types

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


    RowLocation        rl = null;
    RowLocation        scanRL = null;
    ScanController      scan = null;
    int[]          baseColumnPositions;
    int            baseColumns = 0;
    DataValueFactory    dvf;
    long          indexRows;
    ConglomerateController  baseCC = null;
    ConglomerateController  indexCC = null;
    SchemaDescriptor    sd;
    ConstraintDescriptor  constraintDesc;
View Full Code Here


    bootValidation(create, startParams);
   
    // boot the type factory before store to ensure any dynamically
    // registered types (DECIMAL) are there before logical undo recovery
        // might need them.
    DataValueFactory dvf = (DataValueFactory)
            Monitor.bootServiceModule(
                create,
                this,
        org.apache.derby.iapi.reference.ClassName.DataValueFactory,
                startParams);
View Full Code Here

        DataValueDescriptor[] ret_row =
            new DataValueDescriptor[num_cols_to_allocate];
        int         num_cols =
            (column_list == null ? format_ids.length : column_list.size());

        DataValueFactory dvf = rawtran.getDataValueFactory();

        for (int i = 0; i < num_cols; i++)
        {
            // does caller want this column?
            if ((column_list != null) && (!column_list.get(i)))
            {
                // no - column should be skipped.
            }
            else
            {
                // yes - create the column

                // get empty instance of object identified by the format id.
                ret_row[i] = dvf.getNull(format_ids[i], collation_ids[i]);

                if (SanityManager.DEBUG)
                {
                    DataValueDescriptor o = ret_row[i];
View Full Code Here

    bootValidation(create, startParams);
   
    // boot the type factory before store to ensure any dynamically
    // registered types (DECIMAL) are there before logical undo recovery
        // might need them.
    DataValueFactory dvf = (DataValueFactory)
            Monitor.bootServiceModule(
                create,
                this,
        org.apache.derby.iapi.reference.ClassName.DataValueFactory,
                startParams);
View Full Code Here

    RowLocation        rl = null;
    RowLocation        scanRL = null;
    ScanController      scan = null;
    int[]          baseColumnPositions;
    int            baseColumns = 0;
    DataValueFactory    dvf;
    long          indexRows;
    ConglomerateController  baseCC = null;
    ConglomerateController  indexCC = null;
    ExecutionContext    ec;
    SchemaDescriptor    sd;
View Full Code Here

   */
  private DataValueDescriptor convertConstant(TypeId toTypeId, int maxWidth, DataValueDescriptor constantValue)
    throws StandardException
  {
    int formatId = toTypeId.getTypeFormatId();
    DataValueFactory dvf = getDataValueFactory();
    switch (formatId)
    {
      default:
      case StoredFormatIds.CHAR_TYPE_ID:
        return constantValue;

      case StoredFormatIds.VARCHAR_TYPE_ID:
      case StoredFormatIds.NATIONAL_CHAR_TYPE_ID:
      case StoredFormatIds.NATIONAL_VARCHAR_TYPE_ID:
        String sourceValue = constantValue.getString();
        int sourceWidth = sourceValue.length();
        int posn;

        /*
        ** If the input is already the right length, no normalization is
        ** necessary - just return the source.
        **
        */

        if (sourceWidth <= maxWidth)
        {
          switch (formatId)
          {
            // For NCHAR we must pad the result, saves on normilization later if all
            // constants are of the correct size
            case StoredFormatIds.NATIONAL_CHAR_TYPE_ID:

              if (sourceWidth < maxWidth)
              {
                StringBuffer stringBuffer = new StringBuffer(sourceValue);

                int needed = maxWidth - sourceWidth;
                char blankArray[] = new char[needed];
                for (int i = 0; i < needed; i++)
                  blankArray[i] = ' ';
                stringBuffer.append(blankArray, 0,
                        maxWidth - sourceWidth);
                sourceValue = stringBuffer.toString();
              }
              return dvf.getNationalCharDataValue(sourceValue);

            case StoredFormatIds.NATIONAL_VARCHAR_TYPE_ID:
              return dvf.getNationalVarcharDataValue(sourceValue);

            case StoredFormatIds.VARCHAR_TYPE_ID:
              return dvf.getVarcharDataValue(sourceValue);
          }
        }

        /*
        ** Check whether any non-blank characters will be truncated.
        */
        for (posn = maxWidth; posn < sourceWidth; posn++)
        {
          if (sourceValue.charAt(posn) != ' ')
          {
            String typeName = null;
            switch (formatId)
            {
              case StoredFormatIds.NATIONAL_CHAR_TYPE_ID:
                typeName = TypeId.NATIONAL_CHAR_NAME;
                break;

              case StoredFormatIds.NATIONAL_VARCHAR_TYPE_ID:
                typeName = TypeId.NATIONAL_VARCHAR_NAME;
                break;

              case StoredFormatIds.VARCHAR_TYPE_ID:
                typeName = TypeId.VARCHAR_NAME;
                break;
            }
            throw StandardException.newException(SQLState.LANG_STRING_TRUNCATION,
                           typeName,
                           StringUtil.formatForPrint(sourceValue),
                           String.valueOf(maxWidth));
          }
        }

        switch (formatId)
        {
          case StoredFormatIds.NATIONAL_CHAR_TYPE_ID:
            return dvf.getNationalCharDataValue(sourceValue.substring(0, maxWidth));

          case StoredFormatIds.NATIONAL_VARCHAR_TYPE_ID:
            return dvf.getNationalVarcharDataValue(sourceValue.substring(0, maxWidth));

          case StoredFormatIds.VARCHAR_TYPE_ID:
            return dvf.getVarcharDataValue(sourceValue.substring(0, maxWidth));
        }

      case StoredFormatIds.LONGVARCHAR_TYPE_ID:
        //No need to check widths here (unlike varchar), since no max width
        return dvf.getLongvarcharDataValue(constantValue.getString());

      case StoredFormatIds.NATIONAL_LONGVARCHAR_TYPE_ID:
        //No need to check widths here (unlike varchar), since no max width
        return dvf.getNationalLongvarcharDataValue(constantValue.getString());

    }
  }
View Full Code Here

      throws StandardException
  {
        if( value instanceof DataValueDescriptor)
            return ((DataValueDescriptor) value).getClone();
       
    DataValueFactory      dvf = getDataValueFactory();
    TypeId      typeID = getTypeId();
    String            typeName = typeID.getSQLTypeName();

    if ( typeName.equals( TypeId.DATE_NAME ) )
    {
      return  new SQLDate((Date) value);
    }
    else if ( typeName.equals( TypeId.TIME_NAME ) )
    {
      return  new SQLTime( (Time) value);
    }
    else if ( typeName.equals( TypeId.TIMESTAMP_NAME ) )
    {
      return  new SQLTimestamp( (Timestamp) value);
    }
    else
    {
      return  dvf.getDataValue( value, (UserDataValue) null );
    }
  }
View Full Code Here

    bootValidation(create, startParams);
   
    // boot the type factory before store to ensure any dynamically
    // registered types (DECIMAL) are there before logical undo recovery
        // might need them.
    DataValueFactory dvf = (DataValueFactory)
            Monitor.bootServiceModule(
                create,
                this,
        org.apache.derby.iapi.reference.ClassName.DataValueFactory,
                startParams);

    //After booting the DVF, set the Locale information into it. This
    //Locale will be either the Locale obtained from the territory
    //attribute supplied by the user on the JDBC url at database create
    //time or if user didn't provide the territory attribute at database
    //create time, then it will be set to the default JVM locale. If user
    //has requested territory based collation then a Collator object will
    //be constructed from this Locale object.
    dvf.setLocale(databaseLocale);

    bootStore(create, startParams);

    // create a database ID if one doesn't already exist
    myUUID = makeDatabaseID(create, startParams);
View Full Code Here

        {
          constant.getTypeServices().setCollationDerivation(
              resultColumnType.getCollationDerivation());
          constant.getTypeServices().setCollationType(
              resultColumnType.getCollationType());
          DataValueFactory dvf = getDataValueFactory();
          newValue = ((StringDataValue)newValue).getValue(dvf.getCharacterCollator(
              constant.getTypeServices().getCollationType()));
          constant.setValue(newValue);
        }
      }
      if ( ! resultColumnType.getTypeId().equals(
View Full Code Here

  private DataValueDescriptor convertConstant(TypeId toTypeId, int maxWidth,
      DataValueDescriptor constantValue)
    throws StandardException
  {
    int formatId = toTypeId.getTypeFormatId();
    DataValueFactory dvf = getDataValueFactory();
    switch (formatId)
    {
      default:
      case StoredFormatIds.CHAR_TYPE_ID:
        return constantValue;

      case StoredFormatIds.VARCHAR_TYPE_ID:
        String sourceValue = constantValue.getString();
        int sourceWidth = sourceValue.length();
        int posn;

        /*
        ** If the input is already the right length, no normalization is
        ** necessary - just return the source.
        **
        */

        if (sourceWidth <= maxWidth)
        {
          if(formatId == StoredFormatIds.VARCHAR_TYPE_ID)
            return dvf.getVarcharDataValue(sourceValue);
        }

        /*
        ** Check whether any non-blank characters will be truncated.
        */
        for (posn = maxWidth; posn < sourceWidth; posn++)
        {
          if (sourceValue.charAt(posn) != ' ')
          {
            String typeName = null;
            if (formatId == StoredFormatIds.VARCHAR_TYPE_ID)
                typeName = TypeId.VARCHAR_NAME;
            throw StandardException.newException(SQLState.LANG_STRING_TRUNCATION,
                           typeName,
                           StringUtil.formatForPrint(sourceValue),
                           String.valueOf(maxWidth));
          }
        }

        if (formatId == StoredFormatIds.VARCHAR_TYPE_ID)
          return dvf.getVarcharDataValue(sourceValue.substring(0, maxWidth));

      case StoredFormatIds.LONGVARCHAR_TYPE_ID:
        //No need to check widths here (unlike varchar), since no max width
        return dvf.getLongvarcharDataValue(constantValue.getString());

    }
  }
View Full Code Here

TOP

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

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.