Exemple #1
0
  private static boolean emit(
      final BaseComponentType pattern, final Class compCl, final Class... cl) {
    if (pattern == null) {
      return true;
    }

    if (!compCl.getName().equals(pattern.getClass().getName())) {
      return false;
    }

    if ((cl == null) | (cl.length == 0)) {
      // Any property
      return true;
    }

    String className = cl[0].getName();

    if (BasePropertyType.class.isAssignableFrom(cl[0])) {
      if (pattern.getProperties() == null) {
        return false;
      }

      List<JAXBElement<? extends BasePropertyType>> patternProps =
          pattern.getProperties().getBasePropertyOrTzid();

      for (JAXBElement<? extends BasePropertyType> jp : patternProps) {
        if (jp.getValue().getClass().getName().equals(className)) {
          return true;
        }
      }

      return false;
    }

    List<JAXBElement<? extends BaseComponentType>> patternComps = XcalUtil.getComponents(pattern);

    if (patternComps == null) {
      return false;
    }

    // Check for component

    for (JAXBElement<? extends BaseComponentType> jp : patternComps) {
      if (jp.getValue().getClass().getName().equals(className)) {
        return emit(pattern, cl[0], Arrays.copyOfRange(cl, 1, cl.length - 1));
      }
    }

    return false;
  }
Exemple #2
0
  /**
   * @param icprops
   * @param comp
   * @param pattern
   * @throws Throwable
   */
  public static void processProperties(
      final PropertyList icprops,
      final BaseComponentType comp,
      final BaseComponentType pattern,
      final boolean wrapXprops)
      throws Throwable {
    if ((icprops == null) || icprops.isEmpty()) {
      return;
    }

    comp.setProperties(new ArrayOfProperties());
    final List<JAXBElement<? extends BasePropertyType>> pl =
        comp.getProperties().getBasePropertyOrTzid();

    for (final Object icprop : icprops) {
      final Property prop = (Property) icprop;

      final PropertyInfoIndex pii = PropertyInfoIndex.fromName(prop.getName());

      if ((pii != null) && !emit(pattern, comp.getClass(), pii.getXmlClass())) {
        continue;
      }

      final JAXBElement<? extends BasePropertyType> xmlprop = doProperty(prop, pii, wrapXprops);

      if (xmlprop != null) {
        processParameters(prop.getParameters(), xmlprop.getValue());
        pl.add(xmlprop);
      }
    }
  }