Package com.foundationdb.server.error

Examples of com.foundationdb.server.error.UnsupportedCharsetException


    public void validate(AkibanInformationSchema ais, AISValidationOutput output) {
        for (Table table : ais.getTables().values()) {
            final String tableCharset = table.getDefaultedCharsetName();
            if (tableCharset != null && !Charset.isSupported(tableCharset)) {
                output.reportFailure(new AISValidationFailure (
                        new UnsupportedCharsetException (tableCharset)));
            }
           
            for (Column column : table.getColumnsIncludingInternal()) {
                final String columnCharset = column.getCharsetName();
                if (columnCharset != null && !Charset.isSupported(columnCharset)) {
                    output.reportFailure(new AISValidationFailure (
                            new UnsupportedCharsetException (columnCharset)));
                }
            }
        }
    }
View Full Code Here


        else if (!binary) {
            try {
                source = new Value(MString.varchar(), new String(encoded, encoding));
            }
            catch (UnsupportedEncodingException ex) {
                throw new UnsupportedCharsetException(encoding);
            }
        }
        else {
            try {
                switch (type.getBinaryEncoding()) {
                case BINARY_OCTAL_TEXT:
                    source = new Value(MBinary.VARBINARY.instance(false), encoded);
                    break;
                case INT_8:
                case INT_16:
                case INT_32:
                case INT_64: // Types.BIGINT
                    // Go by the length sent rather than the implied type.
                    source = decodeIntegerType(encoded);
                    break;
                case FLOAT_32:

                    source = new Value(MApproximateNumber.FLOAT.instance(false), getDataStream(encoded).readFloat());
                    break;
                case FLOAT_64:
                    source = new Value(MApproximateNumber.DOUBLE.instance(false), getDataStream(encoded).readDouble());
                    break;
                case BOOLEAN_C:
                    source = new Value(AkBool.INSTANCE.instance(false), encoded[0] != 0);
                    break;
                case TIMESTAMP_INT64_MICROS_2000_NOTZ: // Types.TIMESTAMP
                    source = decodeTimestampInt64Micros2000NoTZ(encoded);
                    break;
                case UUID:
                    Value value = new Value(AkGUID.INSTANCE.instance(false));
                    value.putObject(AkGUID.bytesToUUID(encoded, 0));
                    source = value;
                    break;
                // Note: these types had previous implementations, but I couldn't exercise them in tests to verify
                // either with jdbc or pg8000. If you run into them, try looking at the log for this file, it most
                // likely has a correct starting point
                case STRING_BYTES:
                case TIMESTAMP_FLOAT64_SECS_2000_NOTZ: // Types.TIMESTAMP
                case DAYS_2000: // DATE
                case TIME_FLOAT64_SECS_NOTZ: // TIME
                case TIME_INT64_MICROS_NOTZ: // TIME
                case DECIMAL_PG_NUMERIC_VAR:
                default:
                    throw new UnknownDataTypeException(type.toString());
                }
            }
            catch (UnsupportedEncodingException ex) {
                throw new UnsupportedCharsetException(encoding);
            }
            catch (IOException ex) {
                throw new AkibanInternalException("IO error reading from byte array", ex);
            }
        }
View Full Code Here

        this.options = options;
        try {
            printWriter = new PrintWriter(new OutputStreamWriter(byteStream, encoding));
        }
        catch (UnsupportedEncodingException ex) {
            throw new UnsupportedCharsetException(encoding);
        }
        // If the target encoding is UTF-8, we can support
        // canAppendBytes() for properly encoded source strings.
        if ("UTF-8".equals(encoding))
            appender = AkibanAppender.of(byteStream, printWriter, "UTF-8");
View Full Code Here

            try {
                return value.toString().getBytes(charsetName).length + prefixWidth;
            }
            catch (UnsupportedEncodingException ex) {
                TableName table = fieldDef.column().getTable().getName();
                throw new UnsupportedCharsetException(charsetName);
            }
        }
    }
View Full Code Here

            String charsetName = StringAttribute.charsetName(type);
            String asString;
            try {
                asString = new String(bs.byteArray(), bs.byteArrayOffset(), bs.byteArrayLength(), charsetName);
            } catch (UnsupportedEncodingException e) {
                throw new UnsupportedCharsetException(charsetName);
            }
            return asString;
        }
View Full Code Here

        }
        try {
            b = string.getBytes(charsetName);
        } catch (UnsupportedEncodingException e) {
            TableName table = fieldDef.column().getTable().getName();
            throw new UnsupportedCharsetException(charsetName);
        }
        return putByteArray(b, 0, b.length, bytes, offset, fieldDef);
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.server.error.UnsupportedCharsetException

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.