Example usage for org.apache.commons.beanutils PropertyUtils getPropertyType

List of usage examples for org.apache.commons.beanutils PropertyUtils getPropertyType

Introduction

In this page you can find the example usage for org.apache.commons.beanutils PropertyUtils getPropertyType.

Prototype

public static Class getPropertyType(Object bean, String name)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException 

Source Link

Document

Return the Java Class representing the property type of the specified property, or null if there is no such property for the specified bean.

For more details see PropertyUtilsBean.

Usage

From source file:nz.co.senanque.messaging.OrderReplyEndpoint.java

public void issueResponseFor(Message<org.w3c.dom.Document> orderResponse) {
    log.debug("processed orderResponse: correlationId {}",
            orderResponse.getHeaders().get(IntegrationMessageHeaderAccessor.CORRELATION_ID, Long.class));
    org.w3c.dom.Document doc = orderResponse.getPayload();
    Document document = new DOMBuilder().build(doc);
    Element root = document.getRootElement();

    Order context = new Order();
    @SuppressWarnings("unchecked")
    Iterator<Text> itr = (Iterator<Text>) root
            .getDescendants(new ContentFilter(ContentFilter.TEXT | ContentFilter.CDATA));
    while (itr.hasNext()) {
        Text text = itr.next();/* www.  j  a v a  2  s  .c o m*/
        log.debug("name {} value {}", text.getParentElement().getName(), text.getValue());

        String name = getName(text);
        try {
            Class<?> targetType = PropertyUtils.getPropertyType(context, name);
            Object value = ConvertUtils.convert(text.getValue(), targetType);
            PropertyUtils.setProperty(context, name, value);
        } catch (IllegalAccessException e) {
            // Ignore these and move on
            log.debug("{} {}", name, e.getMessage());
        } catch (InvocationTargetException e) {
            // Ignore these and move on
            log.debug("{} {}", name, e.getMessage());
        } catch (NoSuchMethodException e) {
            // Ignore these and move on
            log.debug("{} {}", name, e.getMessage());
        }
    }
}

From source file:org.androidtransfuse.processor.Merger.java

private <T extends Mergeable> Object mergeProperties(Merge mergeAnnotation, String propertyName, T target,
        T source) throws MergerException {

    try {// w ww .  j  av a2  s . c o  m

        String tag = null;
        if (mergeAnnotation != null) {
            tag = mergeAnnotation.value();
        }

        Object targetProperty = PropertyUtils.getProperty(target, propertyName);
        Object sourceProperty = PropertyUtils.getProperty(source, propertyName);
        Class propertyType = PropertyUtils.getPropertyType(target, propertyName);

        Object merged;
        if (tag != null && target.isGenerated() && target.containsTag(tag)) {
            merged = sourceProperty;
        } else {
            merged = merge(propertyType, targetProperty, sourceProperty);
        }

        updateTag(target, tag, merged == null);
        return merged;

    } catch (NoSuchMethodException e) {
        throw new MergerException("NoSuchMethodException while trying to merge", e);
    } catch (IllegalAccessException e) {
        throw new MergerException("IllegalAccessException while trying to merge", e);
    } catch (InvocationTargetException e) {
        throw new MergerException("InvocationTargetException while trying to merge", e);
    }
}

From source file:org.androidtransfuse.processor.Merger.java

private <T extends Mergeable> List mergeList(MergeCollection mergeCollectionAnnotation, String propertyName,
        T target, T source) throws MergerException {

    try {//  w  w  w  .  j  av a  2s .co m

        List targetCollection = (List) PropertyUtils.getProperty(target, propertyName);
        List sourceCollection = (List) PropertyUtils.getProperty(source, propertyName);

        if (mergeCollectionAnnotation == null) {
            return (List) merge(PropertyUtils.getPropertyType(target, propertyName), targetCollection,
                    sourceCollection);
        }

        //update collection from source
        Collection<Mergeable> merged = updateFromSource(targetCollection, sourceCollection,
                mergeCollectionAnnotation.type());

        List targetResult = makeCollection(targetCollection, mergeCollectionAnnotation.collectionType(), target,
                propertyName);

        targetResult.clear();
        targetResult.addAll(merged);

        return targetResult;

    } catch (NoSuchMethodException e) {
        throw new MergerException("NoSuchMethodException while trying to merge", e);
    } catch (IllegalAccessException e) {
        throw new MergerException("IllegalAccessException while trying to merge", e);
    } catch (InvocationTargetException e) {
        throw new MergerException("InvocationTargetException while trying to merge", e);
    }
}

From source file:org.androidtransfuse.processor.Merger.java

private <T extends Mergeable> List makeCollection(List targetList, Class<? extends List> listType, T target,
        String propertyName) throws MergerException {

    try {/*from w w  w.j a v  a  2 s. co  m*/
        //merger only supports Lists
        if (targetList == null) {
            //first look for specific impl in annotation
            if (listType != List.class) {
                return listType.newInstance();
            } else {
                //try to instantiate field type
                return (List) PropertyUtils.getPropertyType(target, propertyName).newInstance();
            }
        }

        return targetList;
    } catch (NoSuchMethodException e) {
        throw new MergerException("NoSuchMethodException while trying to merge", e);
    } catch (IllegalAccessException e) {
        throw new MergerException("IllegalAccessException while trying to merge", e);
    } catch (InstantiationException e) {
        throw new MergerException("InstantiationException while trying to merge", e);
    } catch (InvocationTargetException e) {
        throw new MergerException("InvocationTargetException while trying to merge", e);
    }
}

From source file:org.apache.struts.util.RequestUtils.java

/**
 * <p>If the given form bean can accept multiple FormFile objects but the user only uploaded a single, then
 * the property will not match the form bean type.  This method performs some simple checks to try to accommodate
 * that situation.</p>//w  w  w . j a v a2 s  . c  o  m
 *
 * @param bean
 * @param name
 * @param parameterValue
 * @return
 * @throws ServletException if the introspection has any errors.
 */
private static Object rationalizeMultipleFileProperty(Object bean, String name, Object parameterValue)
        throws ServletException {
    if (!(parameterValue instanceof FormFile)) {
        return parameterValue;
    }

    FormFile formFileValue = (FormFile) parameterValue;
    try {
        Class propertyType = PropertyUtils.getPropertyType(bean, name);

        if (propertyType == null) {
            return parameterValue;
        }

        if (List.class.isAssignableFrom(propertyType)) {
            ArrayList list = new ArrayList(1);
            list.add(formFileValue);
            return list;
        }

        if (propertyType.isArray() && propertyType.getComponentType().equals(FormFile.class)) {
            return new FormFile[] { formFileValue };
        }

    } catch (IllegalAccessException e) {
        throw new ServletException(e);
    } catch (InvocationTargetException e) {
        throw new ServletException(e);
    } catch (NoSuchMethodException e) {
        throw new ServletException(e);
    }

    // no changes
    return parameterValue;

}

From source file:org.apache.torque.dsfactory.AbstractDataSourceFactory.java

/**
 * Encapsulates setting configuration properties on
 * <code>DataSource</code> objects.
 *
 * @param property the property to read from the configuration
 * @param c the configuration to read the property from
 * @param ds the <code>DataSource</code> instance to write the property to
 * @throws Exception if anything goes wrong
 *///from   w  ww. j  a  v a2s  .co  m
protected void setProperty(String property, Configuration c, Object ds) throws Exception {
    if (c == null || c.isEmpty()) {
        return;
    }

    String key = property;
    Class<?> dsClass = ds.getClass();
    int dot = property.indexOf('.');
    try {
        if (dot > 0) {
            property = property.substring(0, dot);

            MappedPropertyDescriptor mappedPD = new MappedPropertyDescriptor(property, dsClass);
            Class<?> propertyType = mappedPD.getMappedPropertyType();
            Configuration subProps = c.subset(property);
            // use reflection to set properties
            Iterator<?> j = subProps.getKeys();
            while (j.hasNext()) {
                String subProp = (String) j.next();
                String propVal = subProps.getString(subProp);
                Object value = ConvertUtils.convert(propVal, propertyType);
                PropertyUtils.setMappedProperty(ds, property, subProp, value);

                if (log.isDebugEnabled()) {
                    log.debug(
                            "setMappedProperty(" + ds + ", " + property + ", " + subProp + ", " + value + ")");
                }
            }
        } else {
            if ("password".equals(key)) {
                // do not log value of password
                // for this, ConvertUtils.convert cannot be used
                // as it also logs the value of the converted property
                // so it is assumed here that the password is a String
                String value = c.getString(property);
                PropertyUtils.setSimpleProperty(ds, property, value);
                if (log.isDebugEnabled()) {
                    log.debug("setSimpleProperty(" + ds + ", " + property + ", " + " (value not logged)" + ")");
                }
            } else {
                Class<?> propertyType = PropertyUtils.getPropertyType(ds, property);
                Object value = ConvertUtils.convert(c.getString(property), propertyType);
                PropertyUtils.setSimpleProperty(ds, property, value);

                if (log.isDebugEnabled()) {
                    log.debug("setSimpleProperty(" + ds + ", " + property + ", " + value + ")");
                }
            }
        }
    } catch (RuntimeException e) {
        throw new TorqueRuntimeException("Runtime error setting property " + property, e);
    } catch (Exception e) {
        log.error("Property: " + property + " value: " + c.getString(key) + " is not supported by DataSource: "
                + ds.getClass().getName());
    }
}

From source file:org.apache.torque.JndiConfigurationTest.java

/**
 * Creates a Data Source from the Torque configuration without using Torque.
 * @return a SharedPoolDataSource source.
 * @throws Exception if we cannot create a Data source.
 *///from w ww.  j av a 2 s  .  c om
protected BasicDataSource getDataSource() throws Exception {
    Configuration torqueConfiguration = getTorqueConfiguraton();
    String defaultDatabase = getDefaultDatabase(torqueConfiguration);
    Configuration dsfactoryConfiguration = torqueConfiguration
            .subset(Torque.TORQUE_KEY + "." + DataSourceFactory.DSFACTORY_KEY + "." + defaultDatabase + "."
                    + AbstractDataSourceFactory.CONNECTION_KEY);

    BasicDataSource dataSource = new BasicDataSource();
    for (Iterator i = dsfactoryConfiguration.getKeys(); i.hasNext();) {
        String key = (String) i.next();
        String stringValue = dsfactoryConfiguration.getString(key);

        if ("user".equals(key)) {
            // setUser() in SharedPoolDataSouce corresponds to
            // setUsername() in BasicDataSourceFactory
            key = "username";
        } else if ("driver".equals(key)) {
            // setDriver() in SharedPoolDataSouce corresponds to
            // setDriverClassName() in BasicDataSourceFactory
            key = "driverClassName";
        }

        Class propertyType = PropertyUtils.getPropertyType(dataSource, key);
        Object value = ConvertUtils.convert(stringValue, propertyType);
        PropertyUtils.setSimpleProperty(dataSource, key, value);
    }

    return dataSource;
}

From source file:org.bbreak.excella.core.tag.excel2java.ObjectsParser.java

/**
 * ?//  w  w w.j a v  a  2 s  .co m
 * 
 * @param sheet 
 * @param tagCell ???
 * @param data BookController?parseBook(), parseSheet()?<BR>
 *              SheetParser?parseSheet?????<BR>
 *              TagParser??????<BR>
 * @return ?
 * @throws ParseException 
 */
@Override
public List<Object> parse(Sheet sheet, Cell tagCell, Object data) throws ParseException {

    List<Object> resultList = new ArrayList<Object>();
    Class<?> clazz = null;

    // 
    int tagRowIdx = tagCell.getRowIndex();
    // 
    int propertyRowIdx;
    // 
    int valueRowFromIdx;
    // 
    int valueRowToIdx = sheet.getLastRowNum();

    try {
        Map<String, String> paramDef = TagUtil.getParams(tagCell.getStringCellValue());

        clazz = Class.forName(paramDef.get(PARAM_CLASS));

        // ?
        propertyRowIdx = TagUtil.adjustValue(tagRowIdx, paramDef, PARAM_PROPERTY_ROW,
                DEFAULT_PROPERTY_ROW_ADJUST);
        if (propertyRowIdx < 0 || propertyRowIdx > sheet.getLastRowNum()) {
            throw new ParseException(tagCell, "?" + PARAM_PROPERTY_ROW);
        }

        // ?
        valueRowFromIdx = TagUtil.adjustValue(tagRowIdx, paramDef, PARAM_DATA_ROW_FROM,
                DEFAULT_VALUE_ROW_FROM_ADJUST);
        if (valueRowFromIdx < 0 || valueRowFromIdx > sheet.getLastRowNum()) {
            throw new ParseException(tagCell, "?" + PARAM_DATA_ROW_FROM);
        }

        // ?
        valueRowToIdx = TagUtil.adjustValue(tagRowIdx, paramDef, PARAM_DATA_ROW_TO, valueRowToIdx - tagRowIdx);
        if (valueRowToIdx > sheet.getLastRowNum() || valueRowToIdx < 0) {
            throw new ParseException(tagCell, "?" + PARAM_DATA_ROW_TO);
        }

        // ???
        if (valueRowFromIdx > valueRowToIdx) {
            throw new ParseException(tagCell,
                    "?" + PARAM_DATA_ROW_FROM + "," + PARAM_DATA_ROW_TO);
        }

    } catch (Exception e) {
        if (e instanceof ParseException) {
            throw (ParseException) e;
        } else {
            throw new ParseException(tagCell, e);
        }
    }

    // ???
    Map<Integer, Class<?>> propertyClassMap = new HashMap<Integer, Class<?>>();
    // ????
    Map<Integer, String> propertyNameMap = new HashMap<Integer, String>();
    // ??
    Map<String, List<ObjectsPropertyParser>> customPropertyParserMap = new HashMap<String, List<ObjectsPropertyParser>>();

    // ??
    List<Integer> targetColNums = new ArrayList<Integer>();
    Row propertyRow = sheet.getRow(propertyRowIdx);
    if (propertyRow == null) {
        // ?null??
        return resultList;
    }
    int firstCellNum = propertyRow.getFirstCellNum();
    int lastCellNum = propertyRow.getLastCellNum();
    for (int cellCnt = firstCellNum; cellCnt < lastCellNum; cellCnt++) {
        Cell cell = propertyRow.getCell(cellCnt);
        if (cell == null) {
            continue;
        }
        try {
            String propertyName = cell.getStringCellValue();
            if (propertyName.startsWith(BookController.COMMENT_PREFIX)) {
                continue;
            }

            Object obj = clazz.newInstance();
            Class<?> propertyClass = PropertyUtils.getPropertyType(obj, propertyName);
            if (propertyClass != null) {
                propertyClassMap.put(cellCnt, propertyClass);
                propertyNameMap.put(cellCnt, propertyName);
                targetColNums.add(cellCnt);
            } else {
                // ????
                for (ObjectsPropertyParser parser : customPropertyParsers) {
                    if (parser.isParse(sheet, cell)) {
                        List<ObjectsPropertyParser> propertyParsers = customPropertyParserMap.get(propertyName);
                        if (propertyParsers == null) {
                            propertyParsers = new ArrayList<ObjectsPropertyParser>();
                        }
                        // ???????
                        if (!propertyParsers.contains(parser)) {
                            propertyParsers.add(parser);
                        }
                        customPropertyParserMap.put(propertyName, propertyParsers);

                        if (!targetColNums.contains(cellCnt)) {
                            propertyNameMap.put(cellCnt, propertyName);
                            targetColNums.add(cellCnt);
                        }
                    }
                }
            }

        } catch (Exception e) {
            throw new ParseException(cell, e);
        }
    }

    if (targetColNums.size() > 0) {
        // ????

        // ??
        for (int rowCnt = valueRowFromIdx; rowCnt <= valueRowToIdx; rowCnt++) {
            Row dataRow = sheet.getRow(rowCnt);
            if (dataRow == null) {
                continue;
            }
            Object obj;
            try {
                obj = clazz.newInstance();
                for (Integer colCnt : targetColNums) {
                    Cell cell = dataRow.getCell(colCnt);

                    try {
                        Class<?> propertyClass = propertyClassMap.get(colCnt);
                        String propertyName = propertyNameMap.get(colCnt);
                        // ?
                        if (customPropertyParserMap.containsKey(propertyName)) {
                            List<ObjectsPropertyParser> propertyParsers = customPropertyParserMap
                                    .get(propertyName);
                            Map<String, String> params = TagUtil.getParams(propertyName);
                            Object cellValue = PoiUtil.getCellValue(cell);

                            // ??
                            for (ObjectsPropertyParser propertyParser : propertyParsers) {
                                propertyParser.parse(obj, cellValue, TagUtil.getTag(propertyName), params);
                            }
                        } else {
                            Object value = null;
                            if (cell != null) {
                                value = PoiUtil.getCellValue(cell, propertyClass);
                            }
                            PropertyUtils.setProperty(obj, propertyName, value);
                        }
                    } catch (Exception e) {
                        throw new ParseException(cell, e);
                    }
                }
            } catch (Exception e) {
                if (e instanceof ParseException) {
                    throw (ParseException) e;
                } else {
                    throw new ParseException(tagCell, e);
                }
            }
            resultList.add(obj);
        }
    }
    return resultList;
}

From source file:org.bbreak.excella.trans.tag.sheet2java.SheetToJavaExecuter.java

/**
 * ??????<BR>//from w  ww.  j a  v a 2  s  .co m
 * ???????<BR>
 * 
 * @param targetSheet ?
 * @param targetColumnInfoList 
 * @return 
 * @throws ParseException 
 */
protected List<Object> parseTargetSheet(Sheet targetSheet, SheetToJavaParseInfo sheetInfo,
        List<SheetToJavaSettingInfo> targetColumnInfoList) throws ParseException {

    // ??
    List<Object> results = new ArrayList<Object>();

    int logicalRowNum = sheetInfo.getLogicalNameRowNum() - 1;
    int valueStartRowNum = sheetInfo.getValueRowNum() - 1;
    int valueEndRowNum = targetSheet.getLastRowNum();

    // ????index?
    Map<String, Integer> colLogicalNameMap = new HashMap<String, Integer>();

    // colLogicalNameMap?
    Row row = targetSheet.getRow(logicalRowNum);
    if (row != null) {

        // ?????
        int firstColIdx = row.getFirstCellNum();
        int lastColIdx = row.getLastCellNum();

        for (int colIdx = firstColIdx; colIdx <= lastColIdx; colIdx++) {
            Cell cell = row.getCell(colIdx);
            if (cell != null) {
                try {
                    // ???
                    String logicalCellValue = cell.getStringCellValue();
                    if (!logicalCellValue.startsWith(BookController.COMMENT_PREFIX)) {
                        colLogicalNameMap.put(logicalCellValue, colIdx);
                    }
                } catch (Exception e) {
                    throw new ParseException(cell, e);
                }
            }
        }
    }

    // ?????????????
    List<Class<?>> classList = new ArrayList<Class<?>>();

    // ?SettingInfo?
    Map<Class<?>, List<SheetToJavaSettingInfo>> settingInfoListMap = new HashMap<Class<?>, List<SheetToJavaSettingInfo>>();
    // ???????
    Map<Class<?>, List<String>> uniquePropertyListMap = new HashMap<Class<?>, List<String>>();
    for (SheetToJavaSettingInfo settingInfo : targetColumnInfoList) {

        // ??
        Class<?> clazz = settingInfo.getClazz();
        List<SheetToJavaSettingInfo> settingInfoList = settingInfoListMap.get(clazz);
        if (settingInfoList == null) {
            // ?????????
            settingInfoList = new ArrayList<SheetToJavaSettingInfo>();
        }
        List<String> uniquePropertyList = uniquePropertyListMap.get(clazz);
        if (uniquePropertyList == null) {
            // ?????????
            uniquePropertyList = new ArrayList<String>();
        }

        // ??
        settingInfoList.add(settingInfo);
        if (settingInfo.isUnique()) {
            uniquePropertyList.add(settingInfo.getPropertyName());
        }

        // ???
        if (!classList.contains(clazz)) {
            classList.add(clazz);
        }

        // ??
        settingInfoListMap.put(clazz, settingInfoList);
        uniquePropertyListMap.put(clazz, uniquePropertyList);
    }

    // ???
    for (Class<?> clazz : classList) {

        // ??
        List<Object> objList = new ArrayList<Object>();

        Object obj = null;
        try {

            // ???
            for (int valueRowIdx = valueStartRowNum; valueRowIdx <= valueEndRowNum; valueRowIdx++) {
                Row valueRow = targetSheet.getRow(valueRowIdx);
                if (valueRow == null) {
                    continue;
                }

                boolean isProcessRow = true;
                for (SheetToJavaListener propertyListener : sheetToJavaListeners) {
                    if (!propertyListener.preProcessRow(valueRow)) {
                        isProcessRow = false;
                    }
                }
                if (!isProcessRow) {
                    continue;
                }

                obj = Class.forName(clazz.getName()).newInstance();

                // ???
                List<SheetToJavaSettingInfo> settingInfoList = settingInfoListMap.get(clazz);
                for (SheetToJavaSettingInfo settingInfo : settingInfoList) {

                    // ??
                    String propertyName = settingInfo.getPropertyName();
                    // 
                    Object value = settingInfo.getValue();
                    // ?
                    Object settingValue = value;
                    Cell valueCell = null;

                    if (value instanceof String) {
                        // ??
                        String settingValueStr = (String) value;
                        if (settingValueStr.startsWith(TAG_PREFIX)) {
                            // ??
                            if (settingValueStr.startsWith(TAG_LOGICAL_NAME_PREFIX)) {
                                // ?????
                                String logicalKey = TagUtil.getParam(settingValueStr, LNAME_TAG_PARAM_PREFIX,
                                        LNAME_TAG_PARAM_SUFFIX);
                                Integer logicalKeyCol = colLogicalNameMap.get(logicalKey);
                                if (logicalKeyCol == null) {
                                    Cell errorCell = null;
                                    for (SheetToJavaSettingInfo columnInfo : targetColumnInfoList) {
                                        if (columnInfo.getValue().equals(settingValueStr)) {
                                            errorCell = columnInfo.getValueCell();
                                        }
                                    }
                                    throw new ParseException(errorCell,
                                            "????:" + logicalKey);
                                }

                                valueCell = valueRow.getCell(logicalKeyCol);
                                if (valueCell != null) {
                                    Class<?> propertyClass = PropertyUtils.getPropertyType(obj,
                                            settingInfo.getPropertyName());
                                    try {
                                        settingValue = PoiUtil.getCellValue(valueCell, propertyClass);
                                    } catch (RuntimeException e) {
                                        throw new ParseException(valueCell,
                                                "???????(" + propertyClass + ")", e);
                                    }
                                } else {
                                    // ?null??
                                    settingValue = null;
                                    valueCell = null;
                                }

                            } else {
                                // ?????
                                // ??
                                parseCustomProperty(valueCell, colLogicalNameMap, obj, valueRow,
                                        settingValueStr);
                                // ??
                                continue;
                            }
                        }
                    }

                    // 
                    try {
                        // ?????
                        for (SheetToJavaListener propertyListener : sheetToJavaListeners) {
                            propertyListener.preSetProperty(valueCell, obj, propertyName, settingValue);
                        }

                        PropertyUtils.setProperty(obj, propertyName, settingValue);

                        // ????
                        for (SheetToJavaListener propertyListener : sheetToJavaListeners) {
                            propertyListener.postSetProperty(valueCell, obj, propertyName, settingValue);
                        }
                    } catch (ParseException parseEx) {
                        throw parseEx;
                    } catch (RuntimeException e) {
                        throw new ParseException(valueCell,
                                "??????(" + propertyName + "=" + settingValue + "["
                                        + settingValue.getClass().getCanonicalName() + "]" + ")",
                                e);
                    }
                }

                for (SheetToJavaListener propertyListener : sheetToJavaListeners) {
                    if (!propertyListener.postProcessRow(valueRow, obj)) {
                        isProcessRow = false;
                    }
                }
                if (!isProcessRow) {
                    continue;
                }

                List<String> uniquePropertyList = uniquePropertyListMap.get(clazz);
                if (!isDuplicateObj(obj, objList, uniquePropertyList)) {
                    // ???????
                    objList.add(obj);
                }
            }

            // ????
            results.addAll(objList);
        } catch (ParseException parseEx) {
            throw parseEx;
        } catch (Exception e) {
            throw new ParseException(e.toString());
        }
    }

    return results;
}

From source file:org.bbreak.excella.trans.tag.sheet2java.SheetToJavaSettingParser.java

/**
 * ?/*  w w  w  .j  a v a2  s  .  c  o  m*/
 * 
 * @param sheet 
 * @param tagCell ???
 * @param data TransProcessor?processBook, processSheet?<BR> 
 *              ????TagParser.parse??????<BR>
 * @return ?
 * @throws ParseException 
 */
@Override
public List<SheetToJavaSettingInfo> parse(Sheet sheet, Cell tagCell, Object data) throws ParseException {

    // ?
    int tagRowIdx = tagCell.getRowIndex();
    int tagColIdx = tagCell.getColumnIndex();

    // 
    int valueRowFromIdx;
    int valueRowToIdx = sheet.getLastRowNum();

    try {
        Map<String, String> paramDef = TagUtil.getParams(tagCell.getStringCellValue());

        // ?
        valueRowFromIdx = TagUtil.adjustValue(tagRowIdx, paramDef, PARAM_DATA_ROW_FROM,
                DEFAULT_DATA_ROW_FROM_ADJUST);
        if (valueRowFromIdx < 0 || valueRowFromIdx > sheet.getLastRowNum()) {
            throw new ParseException(tagCell, "?" + PARAM_DATA_ROW_FROM);
        }

        // ?
        valueRowToIdx = TagUtil.adjustValue(tagRowIdx, paramDef, PARAM_DATA_ROW_TO, valueRowToIdx - tagRowIdx);
        if (valueRowToIdx > sheet.getLastRowNum() || valueRowToIdx < 0) {
            throw new ParseException(tagCell, "?" + PARAM_DATA_ROW_TO);
        }

        // ???
        if (valueRowFromIdx > valueRowToIdx) {
            throw new ParseException(tagCell,
                    "?" + PARAM_DATA_ROW_FROM + "," + PARAM_DATA_ROW_TO);
        }

    } catch (Exception e) {
        if (e instanceof ParseException) {
            throw (ParseException) e;
        } else {
            throw new ParseException(tagCell, e);
        }
    }

    List<SheetToJavaSettingInfo> sheetSettingInfoList = new ArrayList<SheetToJavaSettingInfo>();

    // ??
    int sheetNameColIdx = tagColIdx++;
    // 
    int valueColIdx = tagColIdx++;
    // 
    int classColIdx = tagColIdx++;
    // 
    int propertyNameColIdx = tagColIdx++;
    // ?
    int uniqueColIdx = tagColIdx++;

    // ?????
    Workbook workbook = sheet.getWorkbook();

    // ???
    for (int rowNum = valueRowFromIdx; rowNum <= valueRowToIdx; rowNum++) {
        Row row = sheet.getRow(rowNum);
        if (row != null) {
            // ??
            Cell sheetNameCell = row.getCell(sheetNameColIdx);
            Cell valueCell = row.getCell(valueColIdx);
            Cell classCell = row.getCell(classColIdx);
            Cell propertyNameCell = row.getCell(propertyNameColIdx);
            Cell uniqueCell = row.getCell(uniqueColIdx);

            // ?
            if ((sheetNameCell == null) && (valueCell == null) && (classCell == null)
                    && (propertyNameCell == null) && (uniqueCell == null)) {
                // ????null??
                continue;

            } else if ((sheetNameCell == null) || (sheetNameCell.getStringCellValue() == null)
                    || ("".equals(sheetNameCell.getStringCellValue()))) {
                // ?????????
                continue;

            } else {
                // ????
                Cell requiredErrorCell = null;
                if (classCell == null) {
                    // ?null??
                    requiredErrorCell = row.createCell(classColIdx);
                }

                // ??
                if (requiredErrorCell != null) {
                    throw new ParseException(requiredErrorCell, "?null??");
                }
            }

            // ??
            SheetToJavaSettingInfo settingInfo = new SheetToJavaSettingInfo();

            // ????
            String sheetName = sheetNameCell.getStringCellValue();
            if (workbook.getSheet(sheetName) == null) {
                throw new ParseException(sheetNameCell, "[" + sheetName + "]????");
            }

            // ??
            settingInfo.setSheetName(sheetName);
            settingInfo.setSheetNameCell(sheetNameCell);

            // ?
            try {
                settingInfo.setClazz(Class.forName(classCell.getStringCellValue()));
                settingInfo.setClazzCell(classCell);
            } catch (ClassNotFoundException e) {
                throw new ParseException(classCell, e);
            }

            // 
            Object value = PoiUtil.getCellValue(valueCell);
            settingInfo.setValueCell(valueCell);

            // ?????
            boolean isValueTag = false;
            // ????????
            boolean isValueLogicalNameTag = false;
            if (value instanceof String) {
                // ??
                String valueStr = (String) value;
                if ((valueStr).startsWith(SheetToJavaExecuter.TAG_PREFIX)) {
                    // ??
                    isValueTag = true;
                    if ((valueStr).startsWith(SheetToJavaExecuter.TAG_LOGICAL_NAME_PREFIX)) {
                        // ?????
                        isValueLogicalNameTag = true;
                    }
                }
            }

            if (!isValueTag || isValueLogicalNameTag) {
                // ?????????

                // ??
                Cell requiredErrorCell = null;
                if (propertyNameCell == null) {
                    requiredErrorCell = row.createCell(propertyNameColIdx);
                }
                if (requiredErrorCell != null) {
                    throw new ParseException(requiredErrorCell, "?null??");
                }

                // ?
                settingInfo.setPropertyName(propertyNameCell.getStringCellValue());
                settingInfo.setPropertyNameCell(propertyNameCell);

                // ?
                Class<?> propertyClass = null;
                try {
                    Object obj = settingInfo.getClazz().newInstance();
                    propertyClass = PropertyUtils.getPropertyType(obj, settingInfo.getPropertyName());
                } catch (Exception e) {
                    throw new ParseException(propertyNameCell, e);
                }
                if (propertyClass == null) {
                    throw new ParseException(propertyNameCell,
                            "?:" + settingInfo.getPropertyName());
                }

                // ????
                if (uniqueCell != null) {
                    if (uniqueCell.getStringCellValue() != null
                            && uniqueCell.getStringCellValue().equals(UNIQUE_PROPERTY_MARK)) {
                        settingInfo.setUnique(true);
                        settingInfo.setUniqueCell(uniqueCell);
                    }
                }
            } else {
                // ??

                // ?????
                try {
                    TagUtil.getParams((String) value);
                } catch (Exception e) {
                    throw new ParseException(valueCell, e);
                }
            }

            // ??????
            boolean checkTypeFlag = false;
            if (value instanceof String) {
                if (!isValueTag) {
                    // ??
                    checkTypeFlag = true;
                }
            } else {
                // ??
                if (value != null) {
                    // null??
                    checkTypeFlag = true;
                }
            }

            // ?
            if (checkTypeFlag) {
                // ????
                Object obj;
                try {
                    obj = settingInfo.getClazz().newInstance();
                    Class<?> propertyClass = PropertyUtils.getPropertyType(obj, settingInfo.getPropertyName());
                    value = PoiUtil.getCellValue(valueCell, propertyClass);
                } catch (Exception e) {
                    throw new ParseException(valueCell, e);
                }
            }
            settingInfo.setValue(value);

            // ????
            sheetSettingInfoList.add(settingInfo);
        }
    }
    return sheetSettingInfoList;
}