Generates code that loads a Storage instance on the stack, throwing a
FetchException if Storage request fails.

@param type type of Storage to request
496984
private void loadStorageForFetch(CodeBuilder b, TypeDesc type) {
        b.loadThis();
        b.loadField(SUPPORT_FIELD_NAME, mSupportType);
        TypeDesc storageType = TypeDesc.forClass(Storage.class);

        TypeDesc repositoryType = TypeDesc.forClass(Repository.class);
        b.invokeInterface
            (mSupportType, "getRootRepository", repositoryType, null);
        b.loadConstant(type);

        // This may throw a RepositoryException.
        Label tryStart = b.createLabel().setLocation();
        b.invokeInterface(repositoryType, STORAGE_FOR_METHOD_NAME, storageType,
                          new TypeDesc[]{TypeDesc.forClass(Class.class)});
        Label tryEnd = b.createLabel().setLocation();
        Label noException = b.createLabel();
        b.branch(noException);

        b.exceptionHandler(tryStart, tryEnd,
                           RepositoryException.class.getName());
        b.invokeVirtual
            (RepositoryException.class.getName(), "toFetchException",
             TypeDesc.forClass(FetchException.class), null);
        b.throwObject();

        noException.setLocation();
    }
1210488
protected List<FileMeta> handleGetEntityMetaFiles(Class<? extends FileEntity> type, Integer entityId) {
        Map<String, String> uriVariables = restUriVariablesFactory.getUriVariablesForGetEntityMetaFiles(
                BullhornEntityInfo.getTypesRestEntityName(type), entityId);
        String url = restUrlFactory.assembleGetEntityMetaFilesUrl();
        String jsonString = this.performGetRequest(url, String.class, uriVariables);
        EntityMetaFiles<? extends FileMeta> entityMetaFiles = restJsonConverter.jsonToEntityDoNotUnwrapRoot(jsonString,
                StandardEntityMetaFiles.class);
        if (entityMetaFiles == null || entityMetaFiles.getFileMetas() == null) {
            return Collections.emptyList();
        }
        return (List<FileMeta>) entityMetaFiles.getFileMetas();
    }
639355
def load( typecode )
      offset = 0
      typecode.typecodes.collect do |t|
        value = GCCValue.new @function,
          "*(#{GCCType.new( t ).identifier} *)( #{self} + #{offset} )"
        offset += t.storage_size
        value
      end
    end
327167
@Override
    public IDataType onTypeFault(String typeName) throws AtlasException {

        // Type is not cached - check the type store.
        // Any super and attribute types needed by the requested type
        // which are not cached will also be loaded from the store.
        Context context = new Context();
        TypesDef typesDef = getTypeFromStore(typeName, context);
        if (typesDef.isEmpty()) {
            // Type not found in the type store.
            return null;
        }

        // Add all types that were loaded from the store to the cache.
        TransientTypeSystem transientTypeSystem = typeSystem.createTransientTypeSystem(context.getTypesDef(), false);
        Map<String, IDataType> typesAdded = transientTypeSystem.getTypesAdded();
        putAll(typesAdded.values());
        return typesAdded.get(typeName);
    }
60467
public Object lookup(String type, String url)
        throws IOException
    {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();

        try {
            Class api = Class.forName(type, false, loader);

            return factory.create(api, url);
        } catch (Exception e) {
            throw new IOException(String.valueOf(e));
        }
    }
1165522
public <T> T loadResources(Class<T> type, String... resources) {
    return loadResources(type, Arrays.asList(resources));
  }
1279891
public Layout layoutFor(Class<? extends Storable> type, int generation)
        throws FetchException, FetchNoneException
    {
        StoredLayout storedLayout =
            mLayoutStorage.query("storableTypeName = ? & generation = ?")
            .with(type.getName()).with(generation)
            .loadOne();
        return new Layout(this, storedLayout);
    }
879433
protected void initializeData(ULocale desiredLocale, String type)
    {
        String key = desiredLocale.getBaseName() + '+' + type;
        String ns = desiredLocale.getKeywordValue("numbers");
        if (ns != null && ns.length() > 0) {
            key += '+' + ns;
        }
        DateFormatSymbols dfs = DFSCACHE.getInstance(key, desiredLocale);
        initializeData(dfs);
    }
694573
private Map<String, Object> getEntity(String type, String id) throws StorageException {
        try {
            JestResult response = esClient.execute(new Get.Builder(getIndexName(), id).type(type).build());
            if (!response.isSucceeded()) {
                return null;
            }
            return response.getSourceAsObject(Map.class);
        } catch (Exception e) {
            throw new StorageException(e);
        }
    }
520423
public void instanceOfType(Local<?> target, Local<?> source, TypeId<?> type) {
        addInstruction(new ThrowingCstInsn(Rops.INSTANCE_OF, sourcePosition,
                RegisterSpecList.make(source.spec()), catches, type.constant));
        moveResult(target, true);
    }
294444
public Response changeType(String bucket, String key, StorageType type)
            throws QiniuException {
        String resource = encodedEntry(bucket, key);
        String path = String.format("/chtype/%s/type/%d", resource, type.ordinal());
        return rsPost(bucket, path, null);
    }
940179
public void addType(final Type... _type)
        throws EFapsException
    {
        final List<Type> allType = new ArrayList<>();
        if (this.types.isEmpty()) {
            final Type type = Type.get(this.typeUUID);
            if (type.isAbstract()) {
                final List<Type> childTypes = type.getChildTypes()
                                .stream()
                                .filter(t -> !t.isAbstract())
                                .collect(Collectors.toList());
                allType.addAll(childTypes);
            } else {
                allType.add(type);
            }
        }
        for (final UUID type : this.types) {
            allType.add(Type.get(type));
        }
        for (final Type type : _type) {
            if (type.isAbstract()) {
                final List<Type> childTypes = type.getChildTypes()
                                .stream()
                                .filter(t -> !t.isAbstract())
                                .collect(Collectors.toList());
                allType.addAll(childTypes);
            } else {
                allType.add(type);
            }
        }

        //make for every type a list of types up to the parent
        final List<List<Type>> typeLists = new ArrayList<>();
        for (final Type type : allType) {
            final List<Type> typesTmp = new ArrayList<>();
            typeLists.add(typesTmp);
            Type tmpType = type;
            while (tmpType != null) {
                typesTmp.add(tmpType);
                tmpType = tmpType.getParentType();
            }
        }

        final Set<Type> common = new LinkedHashSet<>();
        if (!typeLists.isEmpty()) {
            final Iterator<List<Type>> iterator = typeLists.iterator();
            common.addAll(iterator.next());
            while (iterator.hasNext()) {
                common.retainAll(iterator.next());
            }
        }
        if (common.isEmpty()) {
            throw new EFapsException(QueryBuilder.class, "noCommon", allType);
        } else {
            // first common type
            this.typeUUID = common.iterator().next().getUUID();
            for (final Type type : allType) {
                this.types.add(type.getUUID());
            }
        }
        // special case handling
        if (this.types.size() == 1 && this.types.iterator().next().equals(this.typeUUID)) {
            this.types.clear();
        }
    }
811063
@Override
    @SuppressWarnings("unchecked")
    public <T> T get(final Object key, final Class<T> type) {
        if (!cache.isEnabled()) {
            LOGGER.warn("Cache {} is disabled. Cannot get {} from cache", cache.getName(), key);
            return null;
        }

        Object value = getValue(key);
        if (value == null) {
            LOGGER.info("Cache miss. Get by key {} and type {} from cache {}", new Object[] { key, type, cache.getName() });
            return null;
        }

        if (value instanceof PertinentNegativeNull) {
            return null;
        }

        if (type != null && !type.isInstance(value)) {
            // in such case default Spring back end for EhCache throws IllegalStateException which interrupts
            // intercepted method invocation
            String msg = "Cached value is not of required type [" + type.getName() + "]: " + value;
            LOGGER.error(msg, new IllegalStateException(msg));
            return null;
        }

        LOGGER.info("Cache hit. Get by key {} and type {}  from cache {} value '{}'", new Object[] { key, type, cache.getName(), value });
        return (T) value;
    }
955063
public static <T> T get(Class<T> type) {
        FactoryBuilder factoryBuilder = REPOSITORY.get(type);
        return (T) factoryBuilder.get();
    }
294048
public static StoreException create(final Type type, final Throwable cause) {
        Preconditions.checkNotNull(cause, "cause");
        return create(type, cause, null);
    }
1361678
private Mapper createMapper(Type type) {
    lock.lock();
    try {
      Mapper mapper = cache.get(type);
      if (mapper != null) {
        return mapper;
      }
      if (type instanceof Class) {
        mapper = createMapper((Class<?>) type);
      } else if (type instanceof ParameterizedType) {
        mapper = createMapper((ParameterizedType) type);
      } else {
        throw new IllegalArgumentException(
            String.format("Type %s is neither a Class nor ParameterizedType", type));
      }
      cache.put(type, mapper);
      return mapper;
    } finally {
      lock.unlock();
    }
  }
4993
public <V> V executeAndFetchFirst(Class<V> returnType) {
        Object o = executeScalar();
        if (null == o) {
            return null;
        }
        return convert(o, returnType);
    }