Convert.

@param _value the value
@return the string
@throws EFapsException
160456
public static String convert(final Object _value) throws EFapsException {
        String ret = null;
        if (_value instanceof String) {
            ret = (String) _value;
        } else if (_value instanceof Instance) {
            ret = ((Instance) _value).getOid();
        } else if (_value instanceof Number) {
            ret = ((Number) _value).toString();
        } else if (_value instanceof LocalDate) {
            ret = ((LocalDate) _value).toString();
        } else {
            LOG.warn("No specific converter defined for: {}", _value);
            ret = String.valueOf(_value);
        }
        return ret;
    }
691279
public function convertToPHPValue($value, AbstractPlatform $platform)
    {

        switch ($platform->getName()) {
            case 'postgresql':
                $value = (is_resource($value)) ? stream_get_contents($value) : $value;
                $convertedValue = parent::convertToPHPValue(hex2bin($value), $platform);
                break;
            default:
                $convertedValue = parent::convertToPHPValue($value, $platform);
        }

        return $convertedValue;
    }
918810
public function reverseTransform($value): ?MoneyValue
    {
        if (null === $value || '' === $value) {
            return null;
        }

        if (!\is_string($value)) {
            throw new TransformationFailedException('Expected a string or null.');
        }

        if ('NaN' === $value) {
            throw new TransformationFailedException('"NaN" is not a valid number');
        }

        if (false !== mb_strpos($value, '∞')) {
            throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like.');
        }

        // Convert normal spaces to fixed spaces.
        $value = str_replace(' ', "\xc2\xa0", $value);

        $formatter = $this->getNumberFormatter();

        $groupSep = $formatter->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
        $decSep = $formatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
        $withCurrency = (bool) preg_match('#\p{Sc}#u', $value);

        // Some locales use the space as group separation.
        // The ICU data confirms this, but since v58.1 this can no longer be parsed
        // in the currency format. Unless you use DECIMAL which doesn't work
        // for currency. So... simple remove the spaces between numbers.
        $value = preg_replace("/(\\p{N})\xc2\xa0(\\p{N})/u", '$1$2', $value);

        if ('.' !== $decSep && (!$this->grouping || '.' !== $groupSep)) {
            $value = str_replace('.', $decSep, $value);
        }

        if (',' !== $decSep && (!$this->grouping || ',' !== $groupSep)) {
            $value = str_replace(',', $decSep, $value);
        }

        if (!$withCurrency) {
            $value = $this->addCurrencySymbol($value);
        }

        try {
            $money = (new IntlMoneyParser($formatter, new ISOCurrencies()))->parse($value);

            return new MoneyValue($money, $withCurrency);
        } catch (ParserException $e) {
            throw new TransformationFailedException($e->getMessage(), 0, $e);
        } catch (\Exception $e) {
            throw new TransformationFailedException($e->getMessage(), 0, $e);
        }
    }
302870
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if (null === $value) {
            return null;
        }

        if (ctype_alpha($value[0])) {
            return $this->getSpatialPlatform($platform)->convertStringToPHPValue($this, $value);
        }

        return $this->getSpatialPlatform($platform)->convertBinaryToPHPValue($this, $value);
    }
128307
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return null;
        }

        if (static::$basePath !== '' && \strpos($value->getPathname(), static::$basePath) !== 0) {
            throw new \LogicException(\sprintf('Invalid path or "basePath" ("%s") configuration', static::$basePath));
        }

        return \substr($value->getPathname(), \strlen(static::$basePath));
    }
787039
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return;
        }

        $val = \DateTime::createFromFormat(
            $platform->getDateTimeFormatString(),
            $value,
            new \DateTimeZone('UTC')
        );
        if (!$val) {
            throw ConversionException::conversionFailed($value, $this->getName());
        }

        return $val;
    }
445577
public String getStringValueFromModel(FacesContext context)
        throws ConverterException {
        ValueExpression ve = getValueExpression("value");
        if (ve == null) {
            return null;
        }

        Object currentValue = ve.getValue(context.getELContext());

        // If there is a converter attribute, use it to to ask application
        // instance for a converter with this identifer.
        Converter c = getConverter();

        if (c == null) {
            // if value is null and no converter attribute is specified, then
            // return null (null has meaning for a view parameters; it means remove it).
            if (currentValue == null) {
                return null;
            }
            // Do not look for "by-type" converters for Strings
            if (currentValue instanceof String) {
                return (String) currentValue;
            }

            // if converter attribute set, try to acquire a converter
            // using its class type.

            Class converterType = currentValue.getClass();
            c = context.getApplication().createConverter(converterType);

            // if there is no default converter available for this identifier,
            // assume the model type to be String.
            if (c == null) {
                return currentValue.toString();
            }
        }

        return c.getAsString(context, this, currentValue);
    }
970197
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (empty($value)) {
            return null;
        }

        if ($value instanceof Uuid || Uuid::isValid($value)) {
            return (string) $value;
        }

        throw ConversionException::conversionFailed($value, self::NAME);
    }
1259441
protected <T> T convertIfNecessary(String value, T originalValue) {
        if (originalValue == null) {
            return (T) value;
        }

        return TypeConversionUtils.convertIfNecessary(value, (Class<T>) originalValue.getClass());
    }
1282552
public static String decodeToStr(String value) {
        byte[] decodedValue = delegate.decode(value);
        return new String(decodedValue, UTF_8);
    }
1105397
@Override
    public String convertTo(final Object value) {
        if (value == null) return "null";
        return convertTo(value.getClass(), value);
    }
456976
public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if (empty($value)) {
            return null;
        }

        if ($value instanceof UuidInterface) {
            return $value->getBytes();
        }

        try {
            if (is_string($value) || method_exists($value, '__toString')) {
                return Uuid::fromString((string) $value)->getBytes();
            }
        } catch (InvalidArgumentException $e) {
            // Ignore the exception and pass through.
        }

        throw ConversionException::conversionFailed($value, static::NAME);
    }
359867
protected function convertValueForColumn($value, ColumnMap $colMap)
    {
        if ($colMap->getType() == 'OBJECT' && is_object($value)) {
            if (is_array($value)) {
                $value = array_map('serialize', $value);
            } else {
                $value = serialize($value);
            }
        } elseif ('ARRAY' === $colMap->getType() && is_array($value)) {
            $value = '| ' . implode(' | ', $value) . ' |';
        } elseif (PropelTypes::ENUM === $colMap->getType() && !is_null($value)) {
            if (is_array($value)) {
                $value = array_map([$colMap, 'getValueSetKey'], $value);
            } else {
                $value = $colMap->getValueSetKey($value);
            }
        } elseif ($colMap->isSetType() && !is_null($value)) {
            try {
                $value = SetColumnConverter::convertToInt($value, $colMap->getValueSet());
            } catch (SetColumnConverterException $e) {
                throw new PropelException(sprintf('Value "%s" is not accepted in this set column', $e->getValue()), $e->getCode(), $e);
            }
        }

        return $value;
    }
150911
private void getValues4Instances(final String _oid)
        throws EFapsException
    {
        // group the instance by type
        // check if the current instance is the list (happens if this
        // value select is e.g. part of a linkto
        final Map<Type, List<Instance>> type2instance = new HashMap<>();
        final Instance currentInst = Instance.get(_oid);
        final List<Instance> instances = new ArrayList<>();
        if (getOneSelect().getQuery().getInstanceList().contains(currentInst)) {
            instances.addAll(getOneSelect().getQuery().getInstanceList());
        } else {
            for (final Object object : getOneSelect().getObjectList()) {
                final String oid =  (String) super.getValue(object);
                instances.add(Instance.get(oid));
            }
        }

        for (final Instance instance : instances) {
            final List<Instance> tmpList;
            if (type2instance.containsKey(instance.getType())) {
                tmpList = type2instance.get(instance.getType());
            } else {
                tmpList = new ArrayList<>();
                type2instance.put(instance.getType(), tmpList);
            }
            tmpList.add(instance);
        }

        // make one union part for every type
        for (final Entry<Type, List<Instance>> entry : type2instance.entrySet()) {

            boolean union = false;
            final Set<Classification> classTypes = new HashSet<>();
            Type curr = entry.getKey();
            while (curr.getParentType() != null) {
                classTypes.addAll(curr.getClassifiedByTypes());
                curr = curr.getParentType();
            }
            classTypes.addAll(curr.getClassifiedByTypes());
            final SQLSelect unionSelect = new SQLSelect();
            for (final Classification clazz : classTypes) {

                final Attribute typeAttr = clazz.getClassifyRelationType()
                                .getAttribute(clazz.getRelTypeAttributeName());
                final Attribute linkAttr = clazz.getClassifyRelationType()
                                .getAttribute(clazz.getRelLinkAttributeName());
                final SQLSelect select;
                if (union) {
                    unionSelect.addPart(SQLPart.UNION).addPart(SQLPart.ALL);
                    select = new SQLSelect();
                } else {
                    select = unionSelect;
                    union = true;
                }
                select.column(0, "ID")
                    .column(0, linkAttr.getSqlColNames().get(0))
                    .column(0, typeAttr.getSqlColNames().get(0))
                    .from(clazz.getClassifyRelationType().getMainTable().getSqlTable(), 0)
                    .addPart(SQLPart.WHERE)
                    .addColumnPart(0, linkAttr.getSqlColNames().get(0))
                    .addPart(SQLPart.IN).addPart(SQLPart.PARENTHESIS_OPEN);

                boolean first = true;
                for (final Instance instance : entry.getValue()) {
                    if (first) {
                        first = false;
                    } else {
                        select.addPart(SQLPart.COMMA);
                    }
                    select.addValuePart(instance.getId());
                }
                select.addPart(SQLPart.PARENTHESIS_CLOSE);
                if (clazz.getClassifyRelationType().getMainTable().getSqlColType() != null) {
                    select.addPart(SQLPart.AND)
                        .addColumnPart(0, clazz.getClassifyRelationType().getMainTable().getSqlColType())
                        .addPart(SQLPart.EQUAL).addValuePart(clazz.getClassifyRelationType().getId());
                }
                if (union && !select.equals(unionSelect)) {
                    unionSelect.addNestedSelectPart(select.getSQL());
                }
            }
            if (classTypes.size() > 0) {
                executeOneCompleteStmt(unionSelect.getSQL(), entry.getValue());
            }
        }
    }
484892
public void setVal(final String _value)
        throws EFapsException
    {
        Connection con = null;
        try {
            con = Context.getConnection();
            Context.getDbType().setSequence(con, getDBName(), Long.parseLong(_value));
            con.commit();
        } catch (final SQLException e) {
            throw new EFapsException(NumberGenerator.class, "setVal()", e);
        } finally {
            try {
                if (con != null && !con.isClosed()) {
                    con.close();
                }
            } catch (final SQLException e) {
                throw new CacheReloadException("could not read child type ids", e);
            }
        }
    }
940391
public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if (is_string($value)) {
            return parent::convertToPHPValue($value, $platform);
        }

        return $value;
    }
339181
public static Object convertClob(Connection conn, String value) throws SQLException {
        return convertClob(conn, value.getBytes());
    }