コード例 #1
0
ファイル: XpathConstraint.java プロジェクト: UniqueOne/drools
 public Class<?> getReturnedClass() {
   if (returnedType != null) {
     return returnedType.getClassType();
   }
   try {
     Method accessor = classObjectType.getClassType().getMethod(field);
     return iterate ? getItemClass(accessor) : accessor.getReturnType();
   } catch (NoSuchMethodException e) {
     throw new RuntimeException(e);
   }
 }
コード例 #2
0
ファイル: AbductiveQuery.java プロジェクト: OnePaaS/drools
  protected void findConstructor(Declaration[] declarations) throws NoSuchMethodException {
    int N = this.abducibleArgs.length;

    cachedConstructor = null;
    List<Class> availableArgs = N > 0 ? new ArrayList<Class>(N) : Collections.<Class>emptyList();
    for (int j = 0; j < N; j++) {
      // during the initial build (KieBuilder), the declarations are provided on the fly and use for
      // type checking
      // when building the KieBase, the internal declarations are set and can be used
      Declaration decl =
          declarations != null ? declarations[mapArgToParam(j)] : getDeclaration(abducibleArgs[j]);
      if (decl != null) {
        availableArgs.add(decl.getExtractor().getExtractToClass());
      }
    }
    Class klass = returnType.getClassType();
    while (cachedConstructor == null) {
      try {
        cachedConstructor =
            klass.getConstructor(availableArgs.toArray(new Class[availableArgs.size()]));
      } catch (NoSuchMethodException nsme) {
        if (klass == Object.class) {
          throw nsme;
        } else {
          klass = klass.getSuperclass();
        }
      }
    }
  }
コード例 #3
0
ファイル: XpathConstraint.java プロジェクト: UniqueOne/drools
 private Method getAccessor() {
   if (accessor == null) {
     try {
       accessor = classObjectType.getClassType().getMethod(field);
     } catch (NoSuchMethodException e) {
       throw new RuntimeException(e);
     }
   }
   return accessor;
 }
コード例 #4
0
ファイル: AbductiveQuery.java プロジェクト: OnePaaS/drools
 private Constructor getConstructor() {
   if (cachedConstructor == null
       || cachedConstructor.getDeclaringClass() != returnType.getClassType()) {
     try {
       findConstructor(null);
     } catch (NoSuchMethodException e) {
       e.printStackTrace();
       cachedConstructor = null;
       returnType = null;
     }
   }
   return cachedConstructor;
 }
コード例 #5
0
ファイル: XpathConstraint.java プロジェクト: UniqueOne/drools
 @Override
 public String toString() {
   StringBuilder sb =
       new StringBuilder((lazy ? "?" : "") + classObjectType.getClassType().getSimpleName());
   if (iterate) {
     sb.append("/");
   } else {
     sb.append(".");
   }
   sb.append(field);
   if (index >= 0) {
     sb.append("[").append(index).append("]");
   }
   if (constraints != null && !constraints.isEmpty()) {
     sb.append("{");
     sb.append(constraints.get(0));
     for (int i = 1; i < constraints.size(); i++) {
       sb.append(", ").append(constraints.get(i));
     }
     sb.append("}");
   }
   return sb.toString();
 }
コード例 #6
0
 public void setClassObjectType(ClassObjectType objectType) {
   this.objectType = objectType;
   setIndex(-1);
   setFieldType(((ClassObjectType) objectType).getClassType());
   setValueType(objectType.getValueType());
 }