public static function getContextValue($ctx, $key, $type) {
    $rval = null;

    // return null for invalid key
    if($key === null) {
      return $rval;
    }

    // get default language
    if($type === '@language' && property_exists($ctx, $type)) {
      $rval = $ctx->{$type};
    }

    // get specific entry information
    if(property_exists($ctx->mappings, $key)) {
      $entry = $ctx->mappings->{$key};
      if($entry === null) {
        return null;
      }

      if($type === null) {
        // return whole entry
        $rval = $entry;
      } else if(property_exists($entry, $type)) {
        // return entry value for type
        $rval = $entry->{$type};
      }
    }

    return $rval;
  }