Package org.apache.commons.beanutils

Examples of org.apache.commons.beanutils.BeanMap$Entry


   * @param mode
   * @return
   */
  public static List<Criterion> getLikeCriterions(Object entity, String[] properties, MatchMode mode) {
    List<Criterion> criterions = CollectUtils.newArrayList();
    BeanMap map = new BeanMap(entity);
    for (int i = 0; i < properties.length; i++) {
      Object value = map.get(properties[i]);
      if ((value instanceof String) && (StringUtils.isNotEmpty((String) value))) {
        criterions.add(Restrictions.like(properties[i], (String) value, mode));
      }
    }
    return criterions;
View Full Code Here


    if (value instanceof String) {
      if (StringUtils.isNotEmpty((String) value)) {
        criterions.add(likeCriterion(nestedName + path, (String) value, mode));
      }
    } else if (value instanceof Entity) {
      BeanMap foreignerMap = new BeanMap(value);
      Object foreignKey = foreignerMap.get("id");
      // 该值不能为空,而且要么不是String类型,要么是不空String类型变量.
      if (ValidEntityKeyPredicate.getInstance().evaluate(foreignKey)) {
        // 在查询中添加该键值.
        criterions.add(eqCriterion(nestedName + path + ".id", foreignKey));
      }
View Full Code Here

      component = (Component) PropertyUtils.getProperty(entity, property);
    } catch (Exception e) {
      return Collections.emptyList();
    }
    if (null == component) { return Collections.emptyList(); }
    BeanMap map = new BeanMap(component);
    Set<String> properties = map.keySet();
    Set<String> excludeSet = null;
    if (null == excludePropertes) {
      excludeSet = Collections.emptySet();
    } else {
      excludeSet = CollectUtils.newHashSet();
      excludeSet.addAll(Arrays.asList(excludePropertes));
    }
    for (Iterator<String> iter = properties.iterator(); iter.hasNext();) {
      String propertyName = iter.next();
      String cascadeName = property + "." + propertyName;
      if (excludeSet.contains(cascadeName) || "class".equals(propertyName)) {
        continue;
      }
      if (!PropertyUtils.isWriteable(component, propertyName)) {
        continue;
      }
      Object value = map.get(propertyName);

      addCriterion(nestedName, entity, excludePropertes, cascadeName, value, criterions, mode,
          ignoreZero);
    }
    return criterions;
View Full Code Here

  protected void displayResults(Object result) {
    if (null == result)
      return;

    BeanMap beanMap = new BeanMap(result);

    for (Iterator<?> itProperty = beanMap.keyIterator(); itProperty
        .hasNext();) {
      String propertyName = "" + itProperty.next();
      Object propertyValue = beanMap.get(propertyName);

      if ("class".equals(propertyName))
        continue;

      if (null == propertyValue)
        continue;

      Class<?> propertyClass = null;

      try {
        propertyClass = beanMap.getType(propertyName);
      } catch (Exception e) {
        getLog().warn("Failure on property " + propertyName, e);
      }

      if (null == propertyClass) {
View Full Code Here

  @SuppressWarnings("rawtypes")
  public static List<Criterion> getEntityCriterions(String nestedName, Object entity,
      String[] excludePropertes, MatchMode mode, boolean ignoreZero) {
    if (null == entity) { return Collections.emptyList(); }
    List<Criterion> criterions = CollectUtils.newArrayList();
    BeanMap map = new BeanMap(entity);
    Set keySet = map.keySet();
    Collection properties = null;
    if (null == excludePropertes) {
      List proList = CollectUtils.newArrayList();
      proList.addAll(keySet);
      properties = proList;
    } else {
      properties = CollectionUtils.subtract(keySet, Arrays.asList(excludePropertes));
    }
    properties.remove("class");

    for (Iterator iter = properties.iterator(); iter.hasNext();) {
      String propertyName = (String) iter.next();
      if (!PropertyUtils.isWriteable(entity, propertyName)) {
        continue;
      }
      Object value = map.get(propertyName);
      addCriterion(nestedName, entity, excludePropertes, propertyName, value, criterions,
          mode, ignoreZero);
    }
    return criterions;
  }
View Full Code Here

    return criterions;
  }

  public static List<Criterion> getEqCriterions(Object entity, String[] properties) {
    List<Criterion> criterions = CollectUtils.newArrayList();
    BeanMap map = new BeanMap(entity);
    for (int i = 0; i < properties.length; i++) {
      criterions.add(Restrictions.eq(properties[i], map.get(properties[i])));
    }
    return criterions;
  }
View Full Code Here

    }
    return criterions;
  }

  public static List<Criterion> getForeignerCriterions(Object entity) {
    BeanMap map = new BeanMap(entity);
    return getForeignerCriterions(entity, map.keySet());
  }
View Full Code Here

  }

  public static List<Criterion> getForeignerCriterions(Object entity,
      Collection<String> properties) {
    List<Criterion> criterions = CollectUtils.newArrayList();
    BeanMap map = new BeanMap(entity);
    for (Iterator<String> iter = properties.iterator(); iter.hasNext();) {
      String propertyName = iter.next();
      Object foreigner = map.get(propertyName);
      if (foreigner instanceof Entity) {
        BeanMap foreignerMap = new BeanMap(foreigner);
        Object foreignKey = foreignerMap.get("id");
        // 该值不能为空,而且要么不是String类型,要么是不空String类型变量.
        if (ValidEntityKeyPredicate.getInstance().evaluate(foreignKey)) {
          // 在查询中添加该键值.
          criterions.add(Restrictions.eq(propertyName + ".id", foreignKey));
        }
View Full Code Here

   * @return
   */
  public static List<Criterion> getLikeCriterions(Object entity, String[] properties,
      MatchMode mode) {
    List<Criterion> criterions = CollectUtils.newArrayList();
    BeanMap map = new BeanMap(entity);
    for (int i = 0; i < properties.length; i++) {
      Object value = map.get(properties[i]);
      if ((value instanceof String) && (StringUtils.isNotEmpty((String) value))) {
        criterions.add(Restrictions.like(properties[i], (String) value, mode));
      }
    }
    return criterions;
View Full Code Here

    if (value instanceof String) {
      if (StringUtils.isNotEmpty((String) value)) {
        criterions.add(likeCriterion(nestedName + path, (String) value, mode));
      }
    } else if (value instanceof Entity) {
      BeanMap foreignerMap = new BeanMap(value);
      Object foreignKey = foreignerMap.get("id");
      // 该值不能为空,而且要么不是String类型,要么是不空String类型变量.
      if (ValidEntityKeyPredicate.getInstance().evaluate(foreignKey)) {
        // 在查询中添加该键值.
        criterions.add(eqCriterion(nestedName + path + ".id", foreignKey));
      }
View Full Code Here

TOP

Related Classes of org.apache.commons.beanutils.BeanMap$Entry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.