Java Reference
In-Depth Information
public List<DVD> getDVDs() throws IOException {
DvdCommand cmdObj = new DvdCommand(SocketCommand.GET_DVDS);
return getResultFor(cmdObj).getList();
}
/**
* A properly formatted <code>String</code> expressions returns all matching
* DVD items. The <code>String</code> must be formatted as a regular
* expression.
*
* @param query A regular expression search string.
* @return A <code>Collection</code> of <code>DVD</code> objects that match
* the search criteria.
* @throws IOException Thrown if an <code>IOException</code> is
* encountered in the <code>db</code> class.
*/
public Collection<DVD> findDVD(String query)
throws IOException, PatternSyntaxException {
DvdCommand cmdObj = new DvdCommand(SocketCommand.FIND);
cmdObj.setRegex(query);
DvdResult serialReturn = getResultFor(cmdObj);
if (serialReturn.isException()
&& serialReturn.getException() instanceof PatternSyntaxException) {
throw (PatternSyntaxException) serialReturn.getException();
} else {
return serialReturn.getCollection();
}
}
/**
* Removes a <code>DVD</code> from the system using a UPC.
*
* @param upc The UPC of the DVD you want to remove from the database.
* @return true if the item was removed, false if it was not removed.
* @throws IOException Indicates there is a problem accessing the data.
*/
public boolean removeDVD(String upc) throws IOException {
DVD dvd = new DVD();
dvd.setUPC(upc);
DvdCommand cmdObj = new DvdCommand(SocketCommand.REMOVE, dvd);
return getResultFor(cmdObj).getBoolean();
}
Search WWH ::




Custom Search