Ejemplo n.º 1
0
 /**
  * Constructor for MultiPropertyComparator.
  *
  * @param propertyStr a {@link java.lang.String} object.
  */
 public MultiPropertyComparator(final String propertyStr) {
   super();
   final String[] properties = Strings.split(propertyStr, ',');
   for (int i = 0; i < properties.length; i++) {
     addComparator(new PropertyComparator(properties[i].trim()));
   }
 }
Ejemplo n.º 2
0
  @Override
  protected void evaluateParams() {
    String[] nameArray = Strings.split(name, ',');
    dates = new Date[nameArray.length];
    String format2 = Date.ResvervedFormats.get(format);
    if (null != format2) format = format2;
    String[] requiredArray = Strings.split(required, ',');
    String[] commentArray = Strings.split(comment, ',');
    String[] labelArray = Strings.split(label, ',');
    for (int i = 0; i < nameArray.length; i++) {
      if (i >= 2) break;
      dates[i] = new Date(stack);
      String name = nameArray[i];
      dates[i].setName(name);
      dates[i].setFormat(format);
      if (requiredArray != null) {
        dates[i].setRequired(requiredArray.length == 1 ? required : requiredArray[i]);
      }
      if (commentArray != null) {
        dates[i].setComment(commentArray.length == 1 ? comment : commentArray[i]);
      }
      if (labelArray != null) {
        dates[i].setLabel(labelArray.length == 1 ? label : labelArray[i]);
      }
      dates[i].setTitle(dates[i].getLabel());
      if (i == 0) dates[0].setValue(start);
      else dates[1].setValue(end);

      dates[i].evaluateParams();
    }
    if (dates.length == 2) {
      dates[0].setMaxDate("#F{$dp.$D(\\'" + dates[1].id + "\\')}");
      dates[1].setMinDate("#F{$dp.$D(\\'" + dates[0].id + "\\')}");

      if (labelArray.length == 1) {
        boolean containTime = format.contains("HH:mm");
        dates[0].setTitle(
            dates[0].getTitle() + getText(containTime ? "common.beginAt" : "common.beginOn"));
        dates[1].setTitle(
            dates[1].getTitle() + getText(containTime ? "common.endAt" : "common.endOn"));
      }
    }
  }
Ejemplo n.º 3
0
  /**
   * {@inheritDoc} 初始化对象指定路径的属性。<br>
   * 例如给定属性a.b.c,方法会依次检查a a.b a.b.c是否已经初始化
   */
  public ObjectAndType initProperty(final Object target, String entityName, final String attr) {
    Object propObj = target;
    Object property = null;

    int index = 0;
    String[] attrs = Strings.split(attr, ".");
    Type type = Model.getType(entityName);
    while (index < attrs.length) {
      try {
        property = PropertyUtils.getProperty(propObj, attrs[index]);
        Type propertyType = type.getPropertyType(attrs[index]);
        // 初始化
        if (null == propertyType) {
          logger.error("Cannot find property type [{}] of {}", attrs[index], propObj.getClass());
          throw new RuntimeException(
              "Cannot find property type " + attrs[index] + " of " + propObj.getClass().getName());
        }
        if (null == property) {
          property = propertyType.newInstance();
          try {
            PropertyUtils.setProperty(propObj, attrs[index], property);
          } catch (NoSuchMethodException e) {
            // Try fix jdk error for couldn't find correct setter when object's Set required type is
            // diffent with Get's return type declared in interface.
            Method setter = Reflections.getSetter(propObj.getClass(), attrs[index]);
            if (null != setter) setter.invoke(propObj, property);
            else throw e;
          }
        }
        index++;
        propObj = property;
        type = propertyType;
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return new ObjectAndType(property, type);
  }