Example usage for org.apache.commons.beanutils BeanMap BeanMap

List of usage examples for org.apache.commons.beanutils BeanMap BeanMap

Introduction

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

Prototype

public BeanMap(Object bean) 

Source Link

Document

构造一个新的BeanMap�作指定的bean, 如果给定的bean是null, 那么 这个map将会是empty。

Usage

From source file:com.autobizlogic.abl.util.BeanUtil.java

/**
 * Get a string showing the given bean's full value (primary key and all attributes)
 *///ww w. j a  v a 2  s .com
@SuppressWarnings("rawtypes")
public static String getBeanLongDescription(MetaEntity metaEntity, Object bean) {

    StringBuffer result = new StringBuffer();

    result.append(getBeanDescription(metaEntity, bean));

    Map map = null;
    if (bean instanceof Map)
        map = (Map) bean;
    else
        map = new BeanMap(bean);

    result.append(" = [");
    Set<MetaAttribute> metaAttributes = metaEntity.getMetaAttributes();
    for (MetaAttribute metaAttribute : metaAttributes) {
        Object value = map.get(metaAttribute.getName());
        result.append(metaAttribute.getName());
        result.append("=");
        result.append(value);
        result.append(", ");
    }
    result.append("]");

    return result.toString();
}

From source file:io.lightlink.oracle.OracleStructType.java

@Override
public Object convertToJdbc(Connection connection, RunnerContext runnerContext, String name, Object value)
        throws IOException, SQLException {
    OracleConnection con = unwrap(connection);

    if (!(value instanceof Map)) { // create a Map from bean
        Map map = new CaseInsensitiveMap(new BeanMap(value));
        map.remove("class");
        value = map;/*w  w w.  j a v  a2  s  .com*/
    }

    return createStruct(con, (Map) value, getCustomSQLTypeName());

}

From source file:com.funambol.lanciadelta.LanciaDeltaBeanMap.java

public LanciaDeltaBeanMap(Object o) {
    putAll(new BeanMap(o));
}

From source file:com.funambol.lanciadelta.LanciaDeltaBeanMap.java

public LanciaDeltaBeanMap(final String prefix, final Object o) {
    BeanMap bm = new BeanMap(o);

    String key = null;//from   ww  w  .j  av  a2 s  .c om
    Iterator i = bm.keyIterator();
    while (i.hasNext()) {
        key = (String) i.next();

        put(prefix + "." + key, bm.get(key));
    }
}

From source file:io.lightlink.spring.StreamingMapper.java

@Override
public Object mapRow(ResultSet resultSet, int i) throws SQLException {

    if (nestedRowMapper != null) {
        Object row;/*from  w w w  .  j  ava2  s  .c  o m*/
        row = nestedRowMapper.mapRow(resultSet, i);
        responseStream.writeFullObjectToArray(new BeanMap(row));
    } else {
        if (colCount == 0)
            readMetadata(resultSet);
        responseStream.writeObjectStart();
        for (int j = 0; j < colCount; j++) {
            Object value = resultSet.getObject(j + 1);
            Object converted = SQLHandler.genericConvertFromJdbc(null, value);
            responseStream.writeProperty(colNames[j], converted);
        }
        responseStream.writeObjectEnd();
    }
    return null;
}

From source file:com.creditcloud.ump.model.ump.utils.MessageUtils.java

public static Map<String, String> getFieldValuesMap(BaseResponse response) {
    Map<String, String> result = new HashMap<>();
    for (Object entryObj : new BeanMap(response).entrySet()) {
        Map.Entry entry = (Map.Entry) entryObj;
        String key = entry.getKey().toString();
        String value = entry.getValue() == null ? null : entry.getValue().toString();
        if (!key.equalsIgnoreCase("class") && !key.equals("rspType") && value != null) {
            result.put(key, value);//from w  w w .  j  av  a  2s . c  o  m
        }
    }
    return result;
}

From source file:io.lightlink.oracle.OracleStructArrayType.java

@Override
public Object convertToJdbc(Connection connection, RunnerContext runnerContext, String name, Object value)
        throws IOException, SQLException {
    OracleConnection con = unwrap(connection);

    ArrayDescriptor arrayStructDesc = safeCreateArrayDescriptor(getCustomSQLTypeName(), con);

    if (value == null) {
        return null;
    } else if (value instanceof List || value.getClass().isArray()) {
        if (value.getClass().isArray()) {
            value = Arrays.asList((Object[]) value);
        }//  w  w w.j  av  a  2  s  . c  o  m

        List records = (List) value;

        STRUCT[] structArray = new STRUCT[records.size()];

        for (int i = 0; i < structArray.length; i++) {
            Object record = records.get(i);

            if (!(record instanceof Map)) { // create a Map from bean
                Map map = new CaseInsensitiveMap(new BeanMap(record));
                map.remove("class");
                record = map;
            }

            structArray[i] = createStruct(con, (Map) record, arrayStructDesc.getBaseName());
        }

        return new ARRAY(arrayStructDesc, con, structArray);

    } else {

        throw new IllegalArgumentException("Type " + getCustomSQLTypeName() + " of converter="
                + this.getClass().getName() + " accepts array/list of objects.");
    }
}

From source file:com.github.ibole.infrastructure.persistence.db.mybatis.pagination.PagingParametersFinder.java

/**
 * Find whether contains <code>PaginationCriteria</code> objects in the object.
 *
 * @param object parameter object.//from  w ww  . j a v a  2  s.c o  m
 * @return PaginationCriteria
 */
@SuppressWarnings("rawtypes")
private PagingCriteria findCriteriaFromObject(Object object) {

    // ???NULL
    if (searchMap.containsKey(object)) {
        return null;
    }
    // object class
    Class<?> objClass = object.getClass();
    PagingCriteria pc;
    // primitive
    if (isPrimitiveType(objClass)) {
        pc = null;
    } else if (object instanceof PagingCriteria) {
        pc = (PagingCriteria) object;
    } else if (object instanceof Map) {
        pc = findCriteriaFromMap((Map) object);
    } else if (object instanceof Collection) {
        pc = findCriteriaFromCollection((Collection) object);
    } else if (objClass.isArray()) {
        pc = findCriteriaFromArray(object);
    } else {
        BeanMap map = new BeanMap(object);
        return findCriteriaFromMap(map);
    }

    searchMap.put(object, SqlHelper.EMPTY);
    return pc;
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.common.vbb.impl.util.AbstractVBB.java

/** {@inheritDoc}. */
public void setVisualVariables(EObject visualVariables) {
    if (this.visualVariables != null && this.visualVariables.isInstance(visualVariables)) {
        for (EReference ref2Child : this.visualVariables.getEAllReferences()) {
            if (this.children.containsKey(ref2Child.getName())) {
                this.children.get(ref2Child.getName())
                        .setVisualVariables((EObject) visualVariables.eGet(ref2Child));
            }//  w  w w . j  a v a  2 s  . c  o m
        }
        BeanMap bm = new BeanMap(this);
        for (EAttribute att : this.visualVariables.getEAllAttributes()) {
            VisualVariableHelper.setVisualVariableValue(bm, visualVariables, att);
        }
    }
}

From source file:com.bstek.dorado.view.loader.PackagesConfigPackageParser.java

@Override
@SuppressWarnings("unchecked")
protected Object doParse(Node node, ParseContext context) throws Exception {
    Element element = (Element) node;
    String name = element.getAttribute("name");
    Assert.notEmpty(name);//from w w  w. ja v  a  2  s  .c  o  m

    Package pkg;
    PackagesConfig packagesConfig = ((PackagesConfigParseContext) context).getPackagesConfig();
    Map<String, Package> packages = packagesConfig.getPackages();
    pkg = packages.get(name);
    if (pkg == null) {
        pkg = new Package(name);
        packages.put(name, pkg);
    }

    Map<String, Object> properties = parseProperties(element, context);
    if (!properties.containsKey("fileNames")) {
        Object value = parseProperty("fileNames", element, context);
        if (value != null && value != ConfigUtils.IGNORE_VALUE) {
            properties.put("fileNames", value);
        }
    }

    String fileNamesText = StringUtils.trim((String) properties.remove("fileNames"));
    fileNamesText = StringUtils.defaultIfEmpty(fileNamesText, NONE_FILE);
    String[] oldFileNames = pkg.getFileNames();
    String[] newFileNames = fileNamesText.split(",");
    if (oldFileNames != null && oldFileNames.length > 0) {
        newFileNames = (String[]) ArrayUtils.addAll(oldFileNames, newFileNames);
    }
    pkg.setFileNames(newFileNames);

    String dependsText = (String) properties.remove("depends");
    if (StringUtils.isNotEmpty(dependsText)) {
        String[] dependsArray = dependsText.split(",");
        for (String depends : dependsArray) {
            pkg.getDepends().add(depends);
        }
    }

    String dependedByText = (String) properties.remove("dependedBy");
    if (StringUtils.isNotEmpty(dependedByText)) {
        String[] dependedByArray = dependedByText.split(",");
        for (String dependedBy : dependedByArray) {
            pkg.getDependedBy().add(dependedBy);
        }
    }

    String clientTypeText = (String) properties.remove("clientType");
    if (StringUtils.isNotEmpty(clientTypeText)) {
        pkg.setClientType(ClientType.parseClientTypes(clientTypeText));
    }

    ((Map<String, Object>) new BeanMap(pkg)).putAll(properties);
    return pkg;
}