Exemplo n.º 1
0
 /**
  * Check if the given element is an array.
  *
  * <p>Multidimensional arrays are not supported.
  *
  * <p>Non-empty 1-dimensional arrays of CompositeData and TabularData are not handled as arrays
  * but as tabular data.
  */
 public static boolean isSupportedArray(Object elem) {
   if (elem == null || !elem.getClass().isArray()) {
     return false;
   }
   Class<?> ct = elem.getClass().getComponentType();
   if (ct.isArray()) {
     return false;
   }
   if (Array.getLength(elem) > 0
       && (CompositeData.class.isAssignableFrom(ct) || TabularData.class.isAssignableFrom(ct))) {
     return false;
   }
   return true;
 }
Exemplo n.º 2
0
 protected FailureDetailView createFailureDetailView() {
   String className = BaseTestRunner.getPreference(FAILUREDETAILVIEW_KEY);
   if (className != null) {
     Class viewClass = null;
     try {
       viewClass = Class.forName(className);
       return (FailureDetailView) viewClass.newInstance();
     } catch (Exception e) {
       JOptionPane.showMessageDialog(
           mainPane, "Could not create Failure DetailView - using default view");
     }
   }
   return new DefaultFailureDetailView();
 }
Exemplo n.º 3
0
 /**
  * Creates a View instance of the class designated to this ViewFactory.
  *
  * <p>If it fails for some reason (i.e. - no View class specified or the given view class doesn't
  * except a single Element parameter for its constructor), a GenericView is returned.
  */
 public View create(Element elem) {
   try {
     return viewClass
         .getDeclaredConstructor(new Class[] {Element.class})
         .newInstance(new Object[] {elem});
   } catch (Exception ex) {
     return new GenericView(elem);
   }
 }
Exemplo n.º 4
0
 /**
  * This method provides a readable classname if it's an array, i.e. either the classname of the
  * component type for arrays of java reference types or the name of the primitive type for arrays
  * of java primitive types. Otherwise, it returns null.
  */
 public static String getArrayClassName(String name) {
   String className = null;
   if (name.startsWith("[")) {
     int index = name.lastIndexOf("[");
     className = name.substring(index, name.length());
     if (className.startsWith("[L")) {
       className = className.substring(2, className.length() - 1);
     } else {
       try {
         Class<?> c = Class.forName(className);
         className = c.getComponentType().getName();
       } catch (ClassNotFoundException e) {
         // Should not happen
         throw new IllegalArgumentException("Bad class name " + name, e);
       }
     }
   }
   return className;
 }
Exemplo n.º 5
0
 /** Check if the given collection is a uniform collection of the given type. */
 public static boolean isUniformCollection(Collection<?> c, Class<?> e) {
   if (e == null) {
     throw new IllegalArgumentException("Null reference type");
   }
   if (c == null) {
     throw new IllegalArgumentException("Null collection");
   }
   if (c.isEmpty()) {
     return false;
   }
   for (Object o : c) {
     if (o == null || !e.isAssignableFrom(o.getClass())) {
       return false;
     }
   }
   return true;
 }
Exemplo n.º 6
0
 static {
   // compute primitives/primitiveMap/primitiveToWrapper
   for (Class<?> c : primitiveWrappers) {
     try {
       Field f = c.getField("TYPE");
       Class<?> p = (Class<?>) f.get(null);
       primitives.add(p);
       primitiveMap.put(p.getName(), p);
       primitiveToWrapper.put(p.getName(), c);
     } catch (Exception e) {
       throw new AssertionError(e);
     }
   }
   // compute editableTypes
   for (Class<?> c : primitives) {
     editableTypes.add(c.getName());
   }
   for (Class<?> c : primitiveWrappers) {
     editableTypes.add(c.getName());
   }
   for (Class<?> c : extraEditableClasses) {
     editableTypes.add(c.getName());
   }
   // compute numericalTypes
   for (Class<?> c : primitives) {
     String name = c.getName();
     if (!name.equals(Boolean.TYPE.getName())) {
       numericalTypes.add(name);
     }
   }
   for (Class<?> c : primitiveWrappers) {
     String name = c.getName();
     if (!name.equals(Boolean.class.getName())) {
       numericalTypes.add(name);
     }
   }
 }
Exemplo n.º 7
0
 /**
  * This method returns the class matching the name className. It's used to cater for the primitive
  * types.
  */
 public static Class<?> getClass(String className) throws ClassNotFoundException {
   Class<?> c;
   if ((c = primitiveMap.get(className)) != null) return c;
   return Class.forName(className);
 }
Exemplo n.º 8
0
  public void actionPerformed(ActionEvent a) {

    int code = 0;
    String roomtypeCompare_arr = null;
    String roomtypeCompare_dep = null;
    if ("book".equals(a.getActionCommand())) {
      try {
        Class.forName("com.mysql.jdbc.Driver");

        // Database connection information. Please note that when porting the code, you must have
        // the jdbc Driver installed where the code is running.
        Connection con =
            DriverManager.getConnection(
                "jdbc:mysql://67.20.111.85:3306/jeehtove_caliking?relaxAutoCommit=true",
                "jeehtove_ck",
                "Z_^PBBZT+kcy");

        // The SELECT query
        String query_arr =
            "SELECT * from reservations WHERE checkin BETWEEN '"
                + checkindateField.getText()
                + "' AND '"
                + checkoutdateField.getText()
                + "'";
        String query_dep =
            "SELECT * from reservations WHERE checkout BETWEEN '"
                + checkindateField.getText()
                + "' AND '"
                + checkoutdateField.getText()
                + "'";

        Statement stmt_arr = con.createStatement();
        Statement stmt_dep = con.createStatement();
        Statement stmt_insert = con.createStatement();
        ResultSet result_arr = stmt_arr.executeQuery(query_arr);
        ResultSet result_dep = stmt_dep.executeQuery(query_dep);

        // Get room type from radio buttons
        String room_type;
        if (standardRoom.isSelected()) {
          room_type = "Standard";
          code = 1;
        } else if (familyRoom.isSelected()) {
          room_type = "Family";
          code = 2;
        } else {
          room_type = "Suite";
          code = 3;
        }

        bookRoom();
        // ResultSet rs=stmt.executeQuery("select * from emp");
        /*if (!result_arr.next() && !result_dep.next()){

        	bookRoom();

        	//Query Prep for checking for open rooms
        	/*String query_checkrooms = "SELECT * FROM makereservation_rooms WHERE type = '" + code + "' AND booked = '0';";
        	Statement stmt_checkrooms = con.createStatement();
        	ResultSet checkrooms = stmt_checkrooms.executeQuery(query_checkrooms);

        	if (checkrooms.next()){
        	String getroomnumber = checkrooms.getString("room");
        	String insert = "INSERT INTO `reservations` VALUES ('" + getroomnumber + "', '" +  checkindateField.getText() + "', '" +  checkoutdateField.getText() + "',  '" + room_type + "',  '" + nameField.getText() + "');";
        	String bookroom = "UPDATE `makereservation_rooms` SET booked = '1' WHERE room = '" + getroomnumber + "';";
        	//System.out.println(insert);
        	int rs=stmt_insert.executeUpdate(insert);
        	int cr=stmt_checkrooms.executeUpdate(bookroom);
        	con.commit();
        	System.out.println("Room Booked!");
        }

        	else System.out.println("All " + room_type + " rooms are booked for the time requested.");
        }

        else {
        	if (result_arr.next()){
        		roomtypeCompare_arr = result_arr.getString("type");
        		System.out.println("(arrival) Does " + roomtypeCompare_arr + " equal " + room_type + "?");
        		if (roomtypeCompare_arr.equals(room_type)){
        			String  checkindateDB_arr = result_arr.getString("checkin");
        			String  checkoutdateDB_arr = result_arr.getString("checkout");
        			System.out.println("There is a room booked on " +  checkindateDB_arr + " that checks out on " +  checkoutdateDB_arr + ". Please select another date.");
        		}

        		else {

        			System.out.println("Room Booked!");
        		}
        	}
        }
        	//System.out.println(query_dep);
        	if (result_dep.next()){
        		roomtypeCompare_dep = result_dep.getString("type");
        		System.out.println("(departure) Does " + roomtypeCompare_dep + " equal " + room_type + "?");
        		if (roomtypeCompare_dep.equals(room_type)){
        			String  checkindateDB_dep = result_dep.getString("checkin");
        			String  checkoutdateDB_dep = result_dep.getString("checkout");
        			System.out.println("There is a room booked on " +  checkindateDB_dep + " that checks out on " +  checkoutdateDB_dep + ". Please select another date.");
        		}

        		else {
        			System.out.println("Room Booked!");
        		}
        	}*/
        con.close();

      } catch (Exception e) {
        System.out.println(e);
      }
    }
  }