Decodes entities in a string if it isn't null.<p>

@param value the string for which to decode entities

@return the string with the decoded entities
500181
protected static String decodeEntities(String value) {

        if (value != null) {
            value = Translate.decode(value);
        }
        return value;
    }
851822
private static function toPlainValue($value)
    {
        if (is_string($value)) {
            $value = strip_tags($value);
            $value = html_entity_decode($value, ENT_QUOTES | ENT_XML1, 'UTF-8');
            $value = trim($value);

            return ($value === '') ? null : $value;
        }

        return $value;
    }
469654
public static boolean containsEntity(String value)
    {
        assert (value != null) : "Parameter 'value' must not be null";

        int pos = value.indexOf('&');
        if (pos == -1)
            return false;

        int end = value.indexOf(';');
        if (end != -1 && pos < end) {
            // extract the entity and then verify it is
            // a valid unicode identifier.
            String entity = value.substring(pos + 1, end);
            if (entity.length() == 0)
                return false;
            char[] chars = entity.toCharArray();

            // verify the start is an indentifier start
            // and the rest is a part.
            if (!Character.isUnicodeIdentifierStart(chars[0])) {
                if (chars[0] == '#' && chars.length > 1) {
                    for (int i = 1; i < chars.length; i++) {
                        if (!Character.isDigit(chars[i]))
                            return false;
                    }
                    return true;
                }
                return false;
            }
            for (int i = 1; i < chars.length; i++) {
                if (!Character.isUnicodeIdentifierPart(chars[i]))
                    return false;
            }
            // good indentifier
            return true;
        }
        return false;
    }
103890
public static String getPrefixFromValue(String value) {
    if (value == null) {
      return null;
    } else if (value.contains(DELIMITER)) {
      String[] list = value.split(DELIMITER);
      if (list != null && list.length > 0) {
        return list[0].replaceAll("\u0000", "");
      } else {
        return null;
      }
    } else {
      return value.replaceAll("\u0000", "");
    }
  }
795729
public static String urlDecode(final String value) {
        if (value == null) {
            return null;
        }

        try {
            return URLDecoder.decode(value, DEFAULT_ENCODING);

        } catch (UnsupportedEncodingException ex) {
            throw new RuntimeException(ex);
        }
    }
1244501
public static function decode( $value )
    {
        if ( is_string($value) ){
//log_debug( "debug", "decode before:" . print_r($value,true) );
            $res = htmlspecialchars_decode($value, ENT_QUOTES);
//log_debug( "debug", "decode after:" . print_r($res,true) );
            return $res;
        }
        elseif ( is_array($value) ){
            return array_map('Charcoal_System::decode', $value);
        }
        elseif ( is_object($value) ){
            $object = $value;
            $vars = get_object_vars($object);
            foreach( $vars as $key => $value ){
                $object->$key = self::decode( $value );
            }
            return $object;
        }
        return $value;
    }
1337129
public static String encode(String value) {
		if(value==null) return null;

		StringBuilder encoded=null;
		int len=value.length();
		for(int c=0;c<len;c++) {
			char ch=value.charAt(c);
			if(
				(ch<' ' && ch!='\n' && ch!='\r')
				|| ch=='\\'
			) {
				if(encoded==null) {
					encoded=new StringBuilder();
					if(c>0) encoded.append(value, 0, c);
				}
				if(ch=='\\') encoded.append("\\\\");
				else if(ch=='\b') encoded.append("\\b");
				else if(ch=='\f') encoded.append("\\f");
				else if(ch=='\t') encoded.append("\\t");
				else {
					int ich=ch;
					encoded
						.append("\\u")
						.append(hexChars[(ich>>>12)&15])
						.append(hexChars[(ich>>>8)&15])
						.append(hexChars[(ich>>>4)&15])
						.append(hexChars[ich&15])
					;
				}
			} else {
				if(encoded!=null) encoded.append(ch);
			}
		}
		return encoded==null ? value : encoded.toString();
	}
1045133
private List decodeFilter(String value) {
        String[] nameAndFilters = value.split(DELIM_GRID_NAME);

        assert nameAndFilters.length == 2;

        String namespace = nameAndFilters[0];
        String[] filters = nameAndFilters[1].split(DELIM_FILTER_TERM);

        ArrayList/*<Filter>*/ gridFilters = new ArrayList/*<Filter>*/();
        for(int i = 0; i < filters.length; i++) {
            String[] terms = filters[i].split(DELIM_FILTER);
            Filter filter = null;

            if(terms.length == 2 && terms[1].equals("*"))
                continue;
            else if(terms.length == 3) {
                FilterOperation fOp = SQLSupport.mapFilterAbbreviationToOperation(terms[1]);
                filter = _config.createFilter();
                filter.setFilterExpression(terms[0]);
                filter.setOperation(fOp);
                filter.setValue(terms[2]);
            }
            else {
                LOGGER.error(Bundle.getErrorString("DataGridStateCodec_IllegalFilter", new Object[]{filter}));
                continue;
            }

            assert filter != null;
            gridFilters.add(filter);
        }
        return gridFilters;
    }
59932
public static String decodeToStr(String value, String charsetName) {
        byte[] decodedValue = delegate.decode(value);
        return new String(decodedValue, Charset.forName(charsetName));
    }
787795
public T convert(Object value)
    {
        T result = null;
        if (value != null)
        {
            if (getValueClass().isInstance(value))
                result = getValueClass().cast(value);
            else
                result = convertFromString(value.toString());
        }
        return result;
    }
618337
public static String decodeString(final String string) {
		String decodedString = null;

		try {
			byte[] decodedBytes = decode(string);
			decodedString = new String(decodedBytes, "UTF-8");
		} catch (UnsupportedEncodingException uue) {
			// Should never happen, java has to support "UTF-8".
		}

		return decodedString;
	}
172689
public static String[] decodeString(String[] values) {
    if (values == null) {
      return null;
    }
    String[] decodedValues = new String[values.length];
    for (int i = 0; i < values.length; i++) {
      decodedValues[i] = decodeString(values[i]);
    }
    return decodedValues;
  }
1292539
public static String decode(String str) {
    if (str != null) {
      try {
        return URLDecoder.decode(str, UTF_8.name());
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("JVM must support UTF-8", e);
      }
    }
    return null;
  }
1195996
public static String enumToString(final Enum<?> value) {

    if (value == null) {
      return null;
    }

    final String underscored = value.name();

    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < underscored.length(); i++) {
      final char c = underscored.charAt(i);
      if (c == '_') {
        sb.append(Character.toUpperCase(underscored.charAt(++i)));
      } else {
        sb.append(Character.toLowerCase(c));
      }
    }
    return sb.toString();
  }
818302
private String decodeIfEncoded(String value) {
    if (StringUtils.contains(value, "%")) {
      try {
        return URLDecoder.decode(value, CharEncoding.UTF_8);
      }
      catch (UnsupportedEncodingException ex) {
        throw new RuntimeException(ex);
      }
    }
    return value;
  }
1108091
public static Date decodeDate(String value) throws ParseException {
        String javaValue = value.substring(0, value.length() - 3) + value.substring(value.length() - 2);
        SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
        return dateFormatter.parse(javaValue);
    }
1166075
private Set<String> parseValueList(String value) {

        if (value.charAt(0) == '(') {
            value = value.substring(1);
        }
        int len = value.length() - 1;
        if (value.charAt(len) == ')') {
            value = value.substring(0, len);
        }
        if (value.charAt(len - 1) == ',') {
            value = value.substring(0, len - 1);
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXCACHEKEY_PARSE_VALUES_1, value));
        }
        List<String> tokens = CmsStringUtil.splitAsList(value, ',', true);
        Set<String> result = new HashSet<String>();
        result.addAll(tokens);
        return result;
    }