Package org.crank.core

Examples of org.crank.core.CrankException


                    if (addToParentMethod == null) {
                        if (childCollection instanceof Collection) {
                            Collection col = (Collection) childCollection;
                            col.add( child );
                        } else {
                            throw new CrankException(methodNotFoundException, "Unable to add child %s to parent %s because %s",
                                    child, parent, methodNotFoundException.getMessage());
                        }
                    }
                    return;
                }
            }

            /*
             * Invoke the addMethod on parent passing the child as an argument.
             */               
            addToParentMethod.invoke(parent, new Object[]{child});                   
           
        } catch (Exception ex) {
            /* If there are any problems throw a nested exception. */
            throw new CrankException(ex, "Unable to add child to parent");
        }
    }
View Full Code Here


                            col.remove( child );
                            logger.debug(String.format("After child removed from collection = %s",col));
   
                        } else {
                            logger.debug("The object retrieved was not a Collection so we will throw the original exception's stack");
                            throw new CrankException(methodNotFoundException, "Unable to remove child %s from parent %s because %s",
                                    child, parent, methodNotFoundException.getMessage());
                        }
                        return;
                    }
                }
            }
            /*
             * Invoke the removeMethod on parent passing the child as an argument.
             */
            removeFromParentMethod.invoke(parent, new Object[]{child});           
        } catch (Exception ex) {
            /* If there are any problems throw a nested exception. */
            throw new CrankException(ex, "Unable to remove child");
        }
    }
View Full Code Here

   @param list A list of objects that will be base objects in the tree.
   *  @return A new Table Model
   * */
  public T createTreeModelFromList(List<?> list) {
    if (list == null) {
      throw new CrankException("the list argument cannot be null");     
    }
   
    /* As we build the tree let's walk through an example of parsing a build string like this:
      "Departments->this.name->employees.name;groups.name"
    */
    String [] levels = getDirections();
    if (levels == null || levels.length == 0) {
      throw new CrankException("the tree build directions could not be interpreted");
    }

    N root = null;
    /* Create the root Node. */
    int level = 0; //index=0
View Full Code Here

    return createTreeModel(root);
  }
  private String getFirstLevelLabel(String[] levels) {
    if (levels.length < 2) {
      throw new CrankException("expected at least two levels in getFirstLevelLabel");
    }
    String currentBuildDirections = levels[1]; //currentBuildDirections like "this.name"
    String[] level2 = currentBuildDirections.split("[.]"); //Splits into something like "this", "name"
    return level2[1]; //grabs the label, i.e., "name".
  }
View Full Code Here

    public static boolean isRequired(Class<?> clazz, String propertyName) {
        if (clazz == null) {
            return false;
        }   
      if (clazz == null || propertyName == null) {
        throw new CrankException("CrankUtils.isRequired: Null arguments are not allowed " +
            " clazz = %s, propertyName = %s ", clazz, propertyName);
      }
        try {
          PropertyDescriptor descriptor = getPropertyDescriptor( clazz, propertyName);
          if (descriptor==null) {
            throw new CrankException("CrankUtils.isRequired: Unable to find property descriptor");
          }
          if (descriptor.getPropertyType().isPrimitive()) {
              return true;
          }
         
          Map<String, AnnotationData> map = getAnnotationDataAsMap( clazz, propertyName );


            boolean found = map.get( "required" ) != null;

            /* If you found an annotation called required, return true. */
          if (found) {
              return true;
          } else {
              /*Otherwise check to see if a column annotation data can be found. */

            return (isRequiredColumnNullable(map, "column") || isRequiredColumnNullable(map, "joinColumn")
                || isRequiredColumnOptional(map, "manyToOne"));
          }
        } catch (Exception ex) {
        throw new CrankException(ex, "CrankUtils.isRequired: Problem %s" +
            " clazz = %s, propertyName = %s ", ex.getMessage(), clazz, propertyName);
         
        }
    }
View Full Code Here

        }
    }
   
    public static String getToolTip(Class<?> clazz, String propertyName) {
      if (clazz == null || propertyName == null) {
        throw new CrankException("CrankUtils.getToolTip: Null arguments are not allowed " +
            " clazz = %s, propertyName = %s ", clazz, propertyName);
      }
        try {
          PropertyDescriptor descriptor =
            getPropertyDescriptor( clazz, propertyName);
          if (descriptor==null) {
            throw new CrankException("CrankUtils.getToolTip: Unable to find property descriptor");
          }
         
          Map<String, AnnotationData> map = getAnnotationDataAsMap( clazz, propertyName );
          if (map.containsKey( "toolTip" ) ) {
              return (String) ((AnnotationData) map.get( "toolTip" )).getValues().get("value");
          }
          return null;
        } catch (Exception ex) {
        throw new CrankException(ex, "CrankUtils.getToolTip: Problem %s" +
            " clazz = %s, propertyName = %s ", ex.getMessage(), clazz, propertyName);
         
        }
    }
View Full Code Here

        }
    }
   
    public static boolean isNameSpaceToolTip(Class<?> clazz, String propertyName) {
      if (clazz == null || propertyName == null) {
        throw new CrankException("CrankUtils.isNameSpaceToolTip: Null arguments are not allowed " +
            " clazz = %s, propertyName = %s ", clazz, propertyName);
      }
        try {
          PropertyDescriptor descriptor =
            getPropertyDescriptor( clazz, propertyName);
          if (descriptor==null) {
            throw new CrankException("CrankUtils.isNameSpaceToolTip: Unable to find property descriptor");
          }
         
          Map<String, AnnotationData> map = getAnnotationDataAsMap( clazz, propertyName );
          if (map.containsKey( "toolTipFromNameSpace" ) ) {
              return true;
          }
          return false;
        } catch (Exception ex) {
        throw new CrankException(ex, "CrankUtils.getToolTip: Problem %s" +
            " clazz = %s, propertyName = %s ", ex.getMessage(), clazz, propertyName);
         
        }
    }
View Full Code Here

        }
    }
   
    public static String getLabelToolTip(Class<?> clazz, String propertyName) {
      if (clazz == null || propertyName == null) {
        throw new CrankException("CrankUtils.getLabelToolTip: Null arguments are not allowed " +
            " clazz = %s, propertyName = %s ", clazz, propertyName);
      }
        try {
          PropertyDescriptor descriptor =
            getPropertyDescriptor( clazz, propertyName);
          if (descriptor==null) {
            throw new CrankException("CrankUtils.getLabelToolTip: Unable to find property descriptor");
          }
         
          Map<String, AnnotationData> map = getAnnotationDataAsMap( clazz, propertyName );
          if (map.containsKey( "toolTip" ) ) {
              return (String) ((AnnotationData) map.get( "toolTip" )).getValues().get("labelValue");
          }
          return null;
        } catch (Exception ex) {
        throw new CrankException(ex, "CrankUtils.getToolTip: Problem %s" +
            " clazz = %s, propertyName = %s ", ex.getMessage(), clazz, propertyName);
         
        }
    }
View Full Code Here

                return false;
            }
            }
            return false;
        } catch (Exception ex) {
            throw new CrankException(ex, "Unable to get property %s from class %s", propertyName, clazz);
        }
       
    }
View Full Code Here

    public T getPrototype() {
      if(prototype==null) {
        try {
        prototype = type.newInstance();
      } catch (Exception e) {
        throw new CrankException(e, "Unable to instantiate class=%s", type);
      }
      }
    return prototype;
  }
View Full Code Here

TOP

Related Classes of org.crank.core.CrankException

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.