Format an URI.

@param string Entity type
@param integer Entity identifier
@param string Type of the URI

@return string
320777
public function formatURI($type, $id, $uriType = self::SCHEME_TYPE)
    {
        switch ($uriType) {
            case self::SCHEME_TYPE:
                return 'entity://' . $type . '/' . $id;
            case self::STACHE_TYPE:
                return '{{' . $type . '/' . $id . '}}';
        }
        throw new \InvalidArgumentException(sprintf("%s: invalid URI type", $uriType));
    }
416393
private void addEntityID(Map<String, String> requestParameters, StringBuilder uri) {
        if (StringUtils.hasText(requestParameters.get(RequestElements.REQ_PARAM_ENTITY_ID))) {
            uri.append("/").append(requestParameters.get(RequestElements.REQ_PARAM_ENTITY_ID));
        }
    }
836766
private static String id(String organizationId, String entityId, String version) {
        return organizationId + ':' + entityId + ':' + version;
    }
590154
protected function uriToId($uriIds, $type)
    {
        $type = 'spotify:' . $type . ':';

        $uriIds = array_map(function ($id) use ($type) {
            return str_replace($type, '', $id);
        }, (array) $uriIds);

        return (count($uriIds) == 1) ? $uriIds[0] : $uriIds;
    }
385952
public function decomposeURI($uri, &$type = null)
    {
        $elements = [];

        if (!self::URIIsCandidate($uri)) {
            return $elements;
        }

        foreach ($this->getURIPatterns() as $name => $pattern) {
            if (preg_match($pattern, $uri, $matches)) {
                $type = $name;
                $elements = [
                    'type'  => $matches['type'],
                    'id'    => $matches['id'],
                ];
                break;
            }
        }

        return $elements;
    }
779286
public function getEntityPathFromURI($uri)
    {
        if ($parts = $this->decomposeURI($uri)) {
            return $this->getEntityPath($parts['type'], $parts['id']);
        }

        throw new \InvalidArgumentException(sprintf("%s: invalid entity URI scheme or malformed URI", $uri));
    }
799265
function _getEntityKey(entityType, entity) {
  switch (entityType) {
    case 'remote-application':
    case 'application':
    case 'unit':
      return entity.name;
    case 'machine':
    case 'relation':
      return entity.id;
    case 'annotation':
      return entity.tag;
    default:
      // This is an unknown entity type so ignore it as we don't know how to
      // handle it.
      return null;
  }
}
864598
function $formatter(type, d, {user,sId,ip,ref}) {
  if (!config.log || !config.log.trk[type]) return
  var ident = user != null ? `${user.name||user._id}`.gray : `${sId.substring(0,12)}`.cyan

  var jdata = type == 'view'
    ? `${(d.url||'').cyan} ${ref?ref.replace(/https\:\/\/|http\:\/\//g,'<<< ').replace('www.','').blue:''}`
    : JSON.stringify(d.data||{}).replace(/^\{/,'').replace(/\}$/,'').replace(/\"([^(\")"]+)\":/g,"$1:".dim).gray
  var label = type
  if (type == 'event') label = d.name
  if (type == 'view') label = `VIEW:${d.type}`
  $logIt(`trk.${type}`
    , label.toUpperCase()
    , `${ip.replace(':ffff','')}`.cyan+`\t${ident}`
    , jdata
  )
}
475937
@GetMapping(value = "/{entityTypeId}/{id}", produces = APPLICATION_JSON_VALUE)
  public Map<String, Object> retrieveEntity(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @RequestParam(value = "attributes", required = false) String[] attributes,
      @RequestParam(value = "expand", required = false) String[] attributeExpands) {
    Set<String> attributesSet = toAttributeSet(attributes);
    Map<String, Set<String>> attributeExpandSet = toExpandMap(attributeExpands);

    EntityType meta = dataService.getEntityType(entityTypeId);
    Object id = getTypedValue(untypedId, meta.getIdAttribute());
    Entity entity = dataService.findOneById(entityTypeId, id);
    if (entity == null) {
      throw new UnknownEntityException(meta, id);
    }

    return getEntityAsMap(entity, meta, attributesSet, attributeExpandSet);
  }
1318950
private function getDrupalEntityPath($type, $entity)
    {
        $uri = entity_uri($type, $entity);

        if (!$uri) {
            throw new \InvalidArgumentException(sprintf("%s: entity type is not supported yet"));
        }

        return $uri['path'];
    }
1197695
private function formatFile(Entity $entity, $file = [], $path = false) {
        // get extension & path
        $ext = (new File($file['name']))->ext();
        $path = trim(str_replace(['/', '\\'], DS, $path), DS);

        // handle identifiers
        $identifiers = [
            ':model' => strtolower($entity->getSource()),
            ':uuid' => Text::uuid(),
            ':md5' => md5(rand() . uniqid() . time()),
        ];

        // output
        return strtr($path, $identifiers) . '.' . strtolower($ext);
    }
992997
function convertEntity(entity) {
    switch (entity[0]) {
        case '"': {
            if(entity.indexOf("^^") > 0) {
                var parts = entity.split("^^");
                return {literal: parts[0] + "^^<" + parts[1] + ">" };
            } else {
                return { literal: entity };
            }
        }
        case '_': return { blank: entity.replace('b', '') };
        default:  return { token: 'uri', value: entity, prefix: null, suffix: null };
    }
}
738172
static void dataUri( CssFormatter formatter, byte[] bytes, String urlStr, String type ) {
        if( type == null ) {
            switch( urlStr.substring( urlStr.lastIndexOf( '.' ) + 1 ) ) {
                case "gif": 
                    type = "image/gif;base64";
                    break;
                case "png": 
                    type = "image/png;base64";
                    break;
                case "jpg":
                case "jpeg":
                    type = "image/jpeg;base64";
                    break;
                default: 
                    type = "text/html";
            }
        } else {
            type = removeQuote( type );
        }

        if( type.endsWith( "base64" ) ) {
            formatter.append( "url(\"data:" ).append( type ).append( ',' );
            formatter.append( toBase64( bytes ) );
            formatter.append( "\")" );
        } else {
            formatter.append( "url(\"data:" ).append( type ).append( ',' );
            appendEncode( formatter, bytes );
            formatter.append( "\")" );
        }
    }
1356931
function getEntity(urls, entityId) {
  // Add xhtml11.dtd to prevent missing entity errors with XHTML files
  urls.push("resource:///res/dtd/xhtml11.dtd");

  // Build a string of external entities
  var extEntities = "";
  for (i = 0; i < urls.length; i++) {
    extEntities += '<!ENTITY % dtd' + i + ' SYSTEM "' +
                   urls[i] + '">%dtd' + i + ';';
  }

  var parser = Cc["@mozilla.org/xmlextras/domparser;1"]
                  .createInstance(Ci.nsIDOMParser);
  var header = '<?xml version="1.0"?><!DOCTYPE elem [' + extEntities + ']>';
  var elem = '<elem id="elementID">&' + entityId + ';</elem>';
  var doc = parser.parseFromString(header + elem, 'text/xml');
  var elemNode = doc.querySelector('elem[id="elementID"]');

  if (elemNode == null)
    throw new Error(arguments.callee.name + ": Unknown entity - " + entityId);

  return elemNode.textContent;
}
968185
@Override
    public String getType(String uri, String local) {
        int index = getIndex(uri, local);

        if (index < 0) {
            return null;
        }
        return getType(index);
    }
886686
public function determineEntityType($entity)
    {
        // remove braces at the beginning (only if $entity looks like <http://...>)
        if ('<' == substr($entity, 0, 1)) {
            $entity = str_replace(['>', '<'], '', $entity);
        }

        // checks if $entity is an URL
        if (true === $this->rdfHelpers->simpleCheckURI($entity)) {
            return 'uri';

        // checks if ^^< is in $entity OR if $entity is surrounded by quotation marks
        } elseif (false !== strpos($entity, '"^^<')
            || ('"' == substr($entity, 0, 1) && '"' == substr($entity, strlen($entity) - 1, 1))) {
            return 'typed-literal';

        // blank node
        } elseif (false !== strpos($entity, '_:')) {
            return 'blanknode';

        // checks if $entity is an URL, which was written with prefix, such as rdfs:label
        } elseif (false !== strpos($entity, ':')) {
            return 'uri';

        // checks if "@ is in $entity
        } elseif (false !== strpos($entity, '"@')) {
            return 'literal';

        // checks if $entity is a string; only strings can be a variable
        } elseif (true === is_string($entity)) {
            return 'var';

        // unknown type
        } else {
            return null;
        }
    }
105155
public function addFromRequest(Type $type, Request $request)
    {
        $key = parent::addFromRequest($type, $request);
        /*
         * @var ExpressKey
         */
        $key->setEntity($this->expressEntity);

        return $key;
    }