コード例 #1
0
ファイル: BookReserver.java プロジェクト: mbokhari/biblioteca
 public void reserveBook(String title) {
   for (Book book : library.returnAllBooksInLibrary()) {
     if (book.getTitle().equals(title)) {
       book.reserveBook();
     }
   }
 }
コード例 #2
0
ファイル: BookSet.java プロジェクト: allentcm/jsword
 /**
  * Gets the sorted set of all keys which can be used for groupings. These are all the property
  * keys across the BookMetaDatas in this list.
  *
  * @return the set of all keys which can be used for grouping.
  */
 public Set<String> getGroups() {
   Set<String> results = new TreeSet<String>();
   for (Book book : this) {
     results.addAll(book.getPropertyKeys());
   }
   return results;
 }
コード例 #3
0
ファイル: Library.java プロジェクト: emilyleones/biblioteca
 public void listBooks() {
   for (Book book : books) {
     if (book.isAvailable()) {
       book.printDetails();
     }
   }
 }
コード例 #4
0
ファイル: BookStoreSpring.java プロジェクト: Evolveum/cxf
 @GET
 @Path("/books/redirectComplete")
 public Book getBookRedirectComplete(@Context HttpServletRequest request) {
   Book book = (Book) request.getAttribute(Book.class.getSimpleName().toLowerCase());
   book.setName("Redirect complete: " + request.getRequestURI());
   return book;
 }
コード例 #5
0
 @Override
 public void processAfterCopy(
     MaintenanceDocument document, Map<String, String[]> requestParameters) {
   Book book = ((Book) document.getNewMaintainableObject().getDataObject());
   book.setIsbn(null);
   super.processAfterCopy(document, requestParameters);
 }
コード例 #6
0
ファイル: XMLWriter.java プロジェクト: hmxbanz/Android
	public static String XMLContent(List<Book> books, Writer writer)
	{
		XmlSerializer serializer = Xml.newSerializer();
		try {
			serializer.setOutput(writer);
			serializer.startDocument("UTF-8", true);
			serializer.startTag("", "books");
			for (Book book : books) {
				serializer.startTag("", "book");
				serializer.attribute("", "id", String.valueOf(book.getId()));
				serializer.startTag("", "name");
				serializer.text(book.getName());
				serializer.endTag("", "name");
				serializer.startTag("", "price");
				serializer.text(String.valueOf(book.getPrice()));
				serializer.endTag("", "price");
				serializer.endTag("", "book");
			}
			serializer.endTag("", "books");
			serializer.endDocument();
			return writer.toString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
コード例 #7
0
 public long addBook(Book book) {
   System.out.println("Adding book " + book.getTitle());
   long id = books.size() + 1;
   book.setId(id);
   books.put(id, book);
   return id;
 }
コード例 #8
0
ファイル: BookTest.java プロジェクト: kolyjjj/biblioteca
 @Test
 public void testBookAShouldEqualsBookBIfTheirNameAndISBNAreEqual() {
   Book a = new Book("TDD", 1234);
   Book b = new Book("TDD", 1234);
   assertTrue(a.equals(b));
   assertTrue(b.equals(a));
 }
コード例 #9
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // Check if an existing view is being reused, otherwise inflate the view
    View listItemView = convertView;
    if (listItemView == null) {
      listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false);
    }

    // Get the {@link Book} object located at this position in the list
    Book currentBook = getItem(position);

    // Find the TextView in the list_item.xml layout with the ID author.
    TextView authorTextView = (TextView) listItemView.findViewById(R.id.author);
    // Then set the author name to that field
    authorTextView.setText(currentBook.getAuthor());

    // Find the TextView in the list_item.xml layout with the ID title.
    TextView titleTextView = (TextView) listItemView.findViewById(R.id.title);
    // Then set the title to that field
    titleTextView.setText(currentBook.getTitle());

    // Return the whole list item layout (containing 2 TextViews) so that it can be shown in
    // the ListView.
    return listItemView;
  }
コード例 #10
0
ファイル: BookController.java プロジェクト: ShermanMG/Library
 public void remove() {
   System.out.println("elo");
   bookList.remove(1);
   for (Book book : bookList) {
     System.out.println(book.getId() + " " + book.getTitle() + " " + book.getPrice());
   }
 }
コード例 #11
0
ファイル: SelectTests.java プロジェクト: nile/beankeeper
 public void testInOperatorWithList() throws Exception {
   // Create test setup
   removeAll(Book.class);
   removeAll(Author.class);
   // Create
   Author author1 = new Author("Geordi", "LaForge");
   Author author2 = new Author("Data", "");
   Author author3 = new Author("Scott", "Montgomery");
   Book book = new Book("Starship internals", "1-3-5-7");
   book.setMainAuthor(author1);
   // Save
   getStore().save(book);
   getStore().save(author1);
   getStore().save(author2);
   getStore().save(author3);
   // Create list
   ArrayList authorList = new ArrayList();
   authorList.add(author1);
   authorList.add(author2);
   authorList.add(author3);
   // Select
   List result =
       getStore().find("find book where book.mainauthor in ?", new Object[] {authorList});
   logger.debug("result is: " + result);
   Assert.assertEquals(result.size(), 1);
 }
コード例 #12
0
 @Override
 public int visit(Book book) {
   int prix = 0;
   prix = book.getPrice();
   System.out.println("Le livre " + book.getTitre() + " coûte " + prix);
   return prix;
 }
コード例 #13
0
ファイル: MyLibrary.java プロジェクト: roughael/TotalBeginner
  public static void main(String[] args) {
    // create a new MyLibrary
    MyLibrary testLibrary = new MyLibrary("Test Drive Library");
    Book b1 = new Book("War And Peace");
    Book b2 = new Book("Great Expectations");
    b1.setAuthor("Tolstoy");
    b2.setAuthor("Dickens");
    Person jim = new Person();
    Person sue = new Person();
    jim.setName("Jim");
    sue.setName("Sue");

    testLibrary.addBook(b1);
    testLibrary.addBook(b2);
    testLibrary.addPerson(jim);
    testLibrary.addPerson(sue);

    System.out.println("Just created new library");
    testLibrary.printStatus();

    System.out.println("Check out War And Peace to Sue");
    testLibrary.checkOut(b1, sue);
    testLibrary.printStatus();

    System.out.println("Do some more stuff");
    testLibrary.checkIn(b1);
    testLibrary.checkOut(b2, jim);
    testLibrary.printStatus();
  }
コード例 #14
0
  @Test
  public void testZSS595_Column() {
    Book book = Util.loadBook(this, "book/blank.xlsx");
    Sheet sheet = book.getSheet("Sheet1");

    String[] columns = {"A", "B", "C", "D", "E"};
    Ranges.range(sheet).setFreezePanel(0, 5);

    // === Insert
    for (int i = 1; i < 6; i++) {
      try {
        Ranges.range(sheet, columns[i - 1] + ":G")
            .toColumnRange()
            .insert(InsertShift.DEFAULT, InsertCopyOrigin.FORMAT_LEFT_ABOVE);
      } catch (InvalidModelOpException e) {
        continue;
      }
      fail(); // if doesn't continue, it fail!
    }

    // == Delete
    for (int i = 1; i < 6; i++) {
      try {
        Ranges.range(sheet, columns[i - 1] + ":G").toColumnRange().delete(DeleteShift.DEFAULT);
      } catch (InvalidModelOpException e) {
        continue;
      }
      fail(); // if doesn't continue, it fail!
    }
  }
コード例 #15
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   Book book = listBook.get(position);
   Intent i = new Intent(this, InformationLivre.class);
   i.putExtra("idLivre", book.getId_notice());
   startActivity(i);
 }
コード例 #16
0
  public void processCommand(String cmd, User user) {

    java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(cmd);

    try {
      String book, command = null;
      book = tokenizer.nextToken(" ");
      if (tokenizer.hasMoreTokens()) command = tokenizer.nextToken(" ");
      output.write(cmd + "\n");
      output.flush();

      Book b = (Book) bookMap.get(book);
      if (b == null) {
        output.write("invalid com.library.bo.book : " + book + "\n");
        output.flush();
        return;
      } else if (command != null) b.execute(command, user);
      else output.write(b.getTitle() + "\n");
      output.write("System> OK\n");
      output.flush();

    } catch (IOException e) {
      e.printStackTrace();
    } catch (InvalidActionException e) {
      try {
        output.write("System> " + e.getMessage() + "\n");
        output.flush();
      } catch (IOException ex) {
        ex.printStackTrace();
      }
    }
  }
コード例 #17
0
  @Test
  public void testZSS595_Row() {
    Book book = Util.loadBook(this, "book/blank.xlsx");
    Sheet sheet = book.getSheet("Sheet1");
    Ranges.range(sheet).setFreezePanel(5, 0);

    // === Insert
    for (int i = 1; i < 6; i++) {
      try {
        Ranges.range(sheet, i + ":6")
            .toRowRange()
            .insert(InsertShift.DEFAULT, InsertCopyOrigin.FORMAT_LEFT_ABOVE);
      } catch (InvalidModelOpException e) {
        continue;
      }
      fail(); // if doesn't continue, it fail!
    }

    // == Delete
    for (int i = 1; i < 6; i++) {
      try {
        Ranges.range(sheet, i + ":6").toRowRange().delete(DeleteShift.DEFAULT);
      } catch (InvalidModelOpException e) {
        continue;
      }
      fail(); // if doesn't continue, it fail!
    }
  }
  public void checkoutBook(String memberID, String bookCopyId) {

    // Get Library member's FULL object from file System
    LibraryMember lm = libraryMemberService.readLibraryMember(memberID);

    //
    CheckoutRecord checkoutRecord = lm.getRecord();

    // Get BookCopy which we are trying to checkout
    BookCopy bookCopy = BookCopy.getBookCopy(bookCopyId);

    // Get the Book Object
    Book book = Book.get(bookCopy.getISBN());

    // Current/ today's date
    LocalDate checkoutDate = LocalDate.now();

    // Duedate = current date PLUS no of days to lend
    LocalDate dueDate = checkoutDate.plusDays(book.getDaysOfLend());

    // Create a new checkout entry
    CheckoutEntry checkoutEntry = new CheckoutEntry(bookCopy, checkoutDate, dueDate, false);

    checkoutRecord.addEntry(checkoutEntry);
    lm.setRecord(checkoutRecord);

    lm.writeLibraryMember(lm);
  }
コード例 #19
0
ファイル: BookDAO.java プロジェクト: raygomez/pealib
  public static int editBook(Book book) throws Exception {
    int intStat = 0;

    String sql =
        "UPDATE Books SET ISBN10 = ?, ISBN13 = ?, "
            + "Title = ?, Author = ?, Edition = ?, Publisher = ?, "
            + "Description = ?, YearPublish = ?, Copies = ? "
            + "WHERE ID = ?";

    PreparedStatement ps = Connector.getConnection().prepareStatement(sql);

    ps.setString(1, book.getIsbn10());
    ps.setString(2, book.getIsbn13());
    ps.setString(3, book.getTitle());
    ps.setString(4, book.getAuthor());
    ps.setString(5, book.getEdition());
    ps.setString(6, book.getPublisher());
    ps.setString(7, book.getDescription());
    ps.setInt(8, book.getYearPublish());
    ps.setInt(9, book.getCopies());
    ps.setInt(10, book.getBookId());

    intStat = ps.executeUpdate();

    Connector.close();

    return intStat;
  }
コード例 #20
0
ファイル: TestBook.java プロジェクト: scaria/biblioteca
 @Test
 public void testSetorGetName() {
   String name = "Book";
   Book test = new Book(null);
   test.setName(name);
   assertEquals(name, test.getName());
 }
コード例 #21
0
ファイル: JPAPagingTest.java プロジェクト: rapidoid/rapidoid
  @Test
  public void testPaging() {
    JPA.bootstrap(path());

    int total = 15;

    JPA.transaction(
        () -> {
          for (int i = 0; i < total; i++) {
            Book book = JPA.insert(new Book("b" + i));
            notNull(book.getId());
          }
        });

    JPA.transaction(
        () -> {
          eq(JPA.getAllEntities().size(), total);
          eq(JPA.count(Book.class), total);

          eq(JPA.of(Book.class).all().size(), total);

          List<Book> first3 = JPA.of(Book.class).page(0, 3);
          eq(first3.size(), 3);
          eq(Do.map(first3).to(Book::getTitle), U.list("b0", "b1", "b2"));

          List<Book> next5 = JPA.of(Book.class).page(3, 5);
          eq(Do.map(next5).to(Book::getTitle), U.list("b3", "b4", "b5", "b6", "b7"));

          List<Book> last2 = JPA.of(Book.class).page(13, 2);
          eq(Do.map(last2).to(Book::getTitle), U.list("b13", "b14"));
        });
  }
コード例 #22
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_save) {

      if (title.getText().toString().isEmpty()) title.setError("This field can't be empty.");
      else if (!price.getText().toString().matches("^\\d+$"))
        price.setError("It must be an integer.");
      else {
        currentBook.setTitle(title.getText().toString());
        currentBook.setAuthor(author.getText().toString());
        currentBook.setCourse(course.getText().toString());
        currentBook.setPrice(Integer.valueOf(price.getText().toString()));
        currentBook.setIsbn(isbn.getText().toString());
        SimpleBookManager.getInstance().saveChanges(this);
        setResult(RESULT_OK);
        finish();
        return true;
      }
    } else if (id == android.R.id.home) {
      onBackPressed();
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
コード例 #23
0
ファイル: BookOpenHelper.java プロジェクト: ngunhi088/tyle05
  public Book readBook() {
    // 読み込み用のSQLiteDatabaseを取得
    SQLiteDatabase db = this.getReadableDatabase();

    // 取得する情報を指定
    String[] projection = {
      Book._ID,
      Book.COLUMN_NAME_BOOK_TITLE,
      Book.COLUMN_NAME_BOOK_PUBLISHER,
      Book.COLUMN_NAME_BOOK_PRICE
    };

    // 条件を指定
    String selection = Book.COLUMN_NAME_BOOK_PRICE + " = ?";
    String[] selectionArgs = {"PRICE1"};

    Cursor cursor =
        db.query(Book.BOOK_TABLE_NAME, projection, selection, selectionArgs, null, null, null);
    Book book;
    boolean moveToFirst = cursor.moveToFirst();
    if (moveToFirst) {
      book = new Book();
      //            book.setPrice(Integer.parseInt(cursor.getString(3)));
      book.setPublisher(cursor.getString(2));
      book.setTitle(cursor.getString(1));
      return book;
    }
    long itemId = cursor.getLong(cursor.getColumnIndexOrThrow(Book._ID));
    return null;
  }
コード例 #24
0
 public String viewBooks() {
   String allBooks = "";
   for (Book book : books) {
     allBooks = allBooks + book.showDetails() + "\n";
   }
   return allBooks;
 }
コード例 #25
0
 @Override
 public boolean checkoutBook(String memberId, String isbn) throws LibrarySystemException {
   Book currentBook = searchBook(isbn);
   BookCopy[] book = currentBook.getCopies();
   for (BookCopy bc : book) {
     if (computeStatus(bc)) {
       DataAccessFacade dc = new DataAccessFacade();
       LocalDate currentDate = LocalDate.now();
       LocalDate dueDate = currentDate.plusDays(bc.getBook().getMaxCheckoutLength());
       CheckoutRecordEntry newCheckoutRecordEntry =
           new CheckoutRecordEntry(currentDate, dueDate, bc);
       LibraryMember member = search(memberId);
       CheckoutRecord rc = member.getCheckoutRecord();
       if (rc.getCheckoutRecordEntries() == null) {
         List<CheckoutRecordEntry> entries = new ArrayList<>();
         entries.add(newCheckoutRecordEntry);
         member.getCheckoutRecord().setCheckoutRecordEntries(entries);
       } else {
         member.getCheckoutRecord().getCheckoutRecordEntries().add(newCheckoutRecordEntry);
       }
       bc.changeAvailability();
       dc.updateMember(member);
       dc.saveNewBook(currentBook);
       return true;
     }
   }
   return false;
 }
 @Override
 public void returnAllBooksByBorrower(String string) {
   List<Book> borrowBooks = bookRepository.findAllBorrowBooksByBorrower(string);
   for (Book book : borrowBooks) {
     book.returnBook();
   }
 }
コード例 #27
0
 private void testZSS547_DeleteSheet(Book book) {
   Ranges.range(book.getSheetAt(0), "A1").getCellValue(); // eval. Sheet1 A1
   Ranges.range(book.getSheetAt(0)).deleteSheet(); // delete Sheet1
   Ranges.range(book.getSheetAt(2)).deleteSheet(); // delete Sheet4
   // eval Sheet3 F1
   Assert.assertEquals(new Double(3.0), Ranges.range(book.getSheetAt(1), "F1").getCellValue());
   // NOTE, there should not be any exception
 }
コード例 #28
0
ファイル: ImmutableBook.java プロジェクト: McC0dy/acs
 public boolean equals(Object obj) {
   if (!(obj instanceof Book)) return false;
   Book book = (Book) obj;
   return (this.ISBN == book.getISBN()
       && this.getTitle().equals(book.getTitle())
       && this.getAuthor().equals(book.getAuthor())
       && this.getPrice() == book.getPrice());
 }
コード例 #29
0
ファイル: BooksTest.java プロジェクト: crosswire/jsword
 @Test
 public void testGetBookMetaData() {
   for (int i = 0; i < bibles.length; i++) {
     Book bible = bibles[i];
     BookMetaData bmd = bible.getBookMetaData();
     Assert.assertEquals(bmds[i], bmd);
   }
 }
コード例 #30
0
 @Override
 public String toString() {
   String bookNames = String.format("%-25s %-25s %-25s \n", "Bookname", "Author Name", "Year");
   for (Book names : bookList) {
     bookNames += names.toString() + "\n";
   }
   return bookNames;
 }