Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package org.apache.aries.blueprint.di;

Version:
$Rev: 820271 $ $Date: 2009-09-30 09:58:29 -0400 (Wed, 30 Sep 2009) $
public class ArrayRecipe extends AbstractRecipe {
    private final List<Recipelist;
    private final Object type;
    public ArrayRecipe(String nameObject type) {
        super(name);
        this. = type;
        this. = new ArrayList<Recipe>();
    }
    public List<RecipegetDependencies() {
        List<RecipenestedRecipes = new ArrayList<Recipe>(.size());
        for (Recipe recipe : ) {
            if (recipe != null) {
                nestedRecipes.add(recipe);
            }
        }
        return nestedRecipes;
    }
    protected Object internalCreate() throws ComponentDefinitionException {
        ReifiedType type;
        if (this. instanceof Class) {
            type = new ReifiedType((Classthis.);
        } else if (this. instanceof String) {
            type = loadType((Stringthis.);
        } else {
            type = new ReifiedType(Object.class);
        }
        // create array instance
        Object array;
        try {
            array = Array.newInstance(type.getRawClass(), .size());
        } catch (Exception e) {
            throw new ComponentDefinitionException("Error while creating array instance: " + type);
        }
        int index = 0;
        for (Recipe recipe : ) {
            Object value;
            if (recipe != null) {
                try {
                    value = convert(recipe.create(), type);
                } catch (Exception e) {
                    throw new ComponentDefinitionException("Unable to convert value " + recipe + " to type " + typee);
                }
            } else {
                value = null;
            }
            
            Array.set(arrayindexvalue);
            index++;
        }
        
        return array;
    }
    public void add(Recipe value) {
        .add(value);
    }
New to GrepCode? Check out our FAQ X