All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.beanio.config.BeanConfig Maven / Gradle / Ivy

Go to download

A Java un/marshalling library for CSV, XML, delimited and fixed length stream formats.

There is a newer version: 2.1.0
Show newest version
/*
 * Copyright 2011 Kevin Seim
 * 
 * Licensed 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.beanio.config;

import java.util.*;

/**
 * A property configuration that describes a Java bean object.  The bean class type is
 * set using the type attribute, and its properties can be configured by
 * adding child PropertyConfig instances.
 * 
 * @author Kevin Seim
 * @since 1.0
 */
public class BeanConfig extends PropertyConfig {

    private List propertyList = new ArrayList();
    
    /**
     * Constructs a new BeanConfig.
     */
    public BeanConfig() { }
    
    /**
     * Returns true to indicate this property is a bean.
     * @return true
     */
    @Override
    public boolean isBean() {
        return true;
    }
    
    /**
     * Adds a property to this bean.
     * @param fieldConfig the field configuration
     */
    public void addProperty(PropertyConfig fieldConfig) {
        propertyList.add(fieldConfig);
    }
    
    /**
     * Returns a list of this bean's properties.
     * @return the list of properties that make up this bean
     */
    public List getPropertyList() {
        return propertyList;
    }
    
    /**
     * Returns the property configuration at the given index.
     * @param index the property index
     * @return the property configuration
     * @throws IndexOutOfBoundsException if there is no property at the specified index
     */
    public PropertyConfig getProperty(int index) {
        return propertyList.get(index);
    }

    /**
     * Sets the list of properties that make up this bean.
     * @param list the list of properties
     */
    public void setPropertyList(List list) {
        if (list == null) {
            this.propertyList.clear();
        }
        else {
            this.propertyList = list;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy