/** {@inheritDoc} */ @GET @Path("/patron") @TypeHint(Patron.class) @Override public Response getCardInformation( @QueryParam("personId") String personId, @QueryParam("byuId") String byuId, @QueryParam("ssn") String ssn, @QueryParam("netId") String netId, @QueryParam("proxId") String proxId) { Patron patron = null; try { if (personId != null && personId.length() == 9) { patron = cardManager.getPatronByPersonId(personId); } else if (byuId != null) { patron = cardManager.getPatronByByuId(byuId); } else if (ssn != null) { patron = cardManager.getPatronBySSN(ssn); } else if (netId != null) { patron = cardManager.getPatronByNetId(netId); } else if (proxId != null) { patron = cardManager.getPatronByProxId(proxId); } } catch (IllegalArgumentException iae) { return Response.status(Response.Status.NOT_FOUND).entity(iae.getMessage()).build(); } return Response.ok().entity(patron).build(); }
public void setEntity(java.lang.Object ent) { Method[] methods = ent.getClass().getDeclaredMethods(); box.removeAll(); for (Method m : methods) { if (m.getName().toLowerCase().startsWith("get")) { String attName = m.getName().substring(3); Object result; try { result = m.invoke(ent, new Object[] {}); String value = "null"; if (result != null) value = result.toString(); JPanel attPane = new JPanel(new FlowLayout(FlowLayout.LEFT)); attPane.add(new JLabel(attName + " : " + m.getReturnType().getName() + " = " + value)); box.add(attPane); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } }
/* * launch process config input: className and args */ public void launchProcessConfig(String className, String[] args) throws SecurityException, NoSuchMethodException { try { Class<?> processClass = Class.forName(className); // System.out.print("processClass is " + processClass.toString()); MigratableProcess process; process = (MigratableProcess) processClass.getConstructor(String[].class).newInstance((Object) args); // process = (MigratableProcess) processClass.newInstance(); System.out.println("MP is " + process.toString()); processList.add(process); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } // TestProcess test = new TestProcess(); catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public static String CreateZip(String[] filesToZip, String zipFileName) { byte[] buffer = new byte[18024]; try { ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName)); out.setLevel(Deflater.BEST_COMPRESSION); for (int i = 0; i < filesToZip.length; i++) { FileInputStream in = new FileInputStream(filesToZip[i]); String fileName = null; for (int X = filesToZip[i].length() - 1; X >= 0; X--) { if (filesToZip[i].charAt(X) == '\\' || filesToZip[i].charAt(X) == '/') { fileName = filesToZip[i].substring(X + 1); break; } else if (X == 0) fileName = filesToZip[i]; } out.putNextEntry(new ZipEntry(fileName)); int len; while ((len = in.read(buffer)) > 0) out.write(buffer, 0, len); out.closeEntry(); in.close(); } out.close(); } catch (IllegalArgumentException e) { return "Failed to create zip: " + e.toString(); } catch (FileNotFoundException e) { return "Failed to create zip: " + e.toString(); } catch (IOException e) { return "Failed to create zip: " + e.toString(); } return "Success"; }
public int addToTable(String line) { String[] a = line.split(splitToken); try { return addToTable(a); } catch (IllegalArgumentException e) { String msg = String.format("\"%s\" -> '%s'", e.getMessage(), line); throw new IllegalArgumentException(msg, e); } }
public OntologyDB(String filename) { try { // String modelFileName = filename; this.reloadOWLFile(filename); } catch (IllegalArgumentException e) { System.out.println("Caught Exception : " + e.getMessage()); } this.reasoning(); }
public Filter filter(String filter) { try { return FilterImpl.newInstance(filter); } catch (InvalidSyntaxException e) { IllegalArgumentException ex = new IllegalArgumentException(); ex.initCause(e); throw ex; } }
/** Gets all Genomic Data. */ private ProfileDataSummary getGenomicData( String cancerStudyId, HashMap<String, GeneticProfile> defaultGeneticProfileSet, SampleList defaultSampleSet, String geneListStr, ArrayList<SampleList> sampleList, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, DaoException { // parse geneList, written in the OncoPrintSpec language (except for changes by XSS clean) double zScore = ZScoreUtil.getZScore( new HashSet<String>(defaultGeneticProfileSet.keySet()), new ArrayList<GeneticProfile>(defaultGeneticProfileSet.values()), request); double rppaScore = ZScoreUtil.getRPPAScore(request); ParserOutput theOncoPrintSpecParserOutput = OncoPrintSpecificationDriver.callOncoPrintSpecParserDriver( geneListStr, new HashSet<String>(defaultGeneticProfileSet.keySet()), new ArrayList<GeneticProfile>(defaultGeneticProfileSet.values()), zScore, rppaScore); ArrayList<String> geneList = new ArrayList<String>(); geneList.addAll(theOncoPrintSpecParserOutput.getTheOncoPrintSpecification().listOfGenes()); ArrayList<ProfileData> profileDataList = new ArrayList<ProfileData>(); Set<String> warningUnion = new HashSet<String>(); for (GeneticProfile profile : defaultGeneticProfileSet.values()) { try { GetProfileData remoteCall = new GetProfileData( profile, geneList, StringUtils.join(defaultSampleSet.getSampleList(), " ")); ProfileData pData = remoteCall.getProfileData(); warningUnion.addAll(remoteCall.getWarnings()); profileDataList.add(pData); } catch (IllegalArgumentException e) { e.getStackTrace(); } } ProfileMerger merger = new ProfileMerger(profileDataList); ProfileData mergedProfile = merger.getMergedProfile(); ProfileDataSummary dataSummary = new ProfileDataSummary( mergedProfile, theOncoPrintSpecParserOutput.getTheOncoPrintSpecification(), zScore, rppaScore); return dataSummary; }
/** * @param path * @return byte or null */ public byte[] getFile(String path) { Log.d(TAG, "get file " + path); // NON-NLS File f = new File(getFullCachePath(path)); if (!f.exists()) { Log.w(TAG, "file: " + f.toString() + " not exists"); // NON-NLS return null; } try { ByteArrayOutputStream out = new ByteArrayOutputStream(); FileInputStream fileInputStream = new FileInputStream(f); byte[] buf = new byte[1024]; int numRead = 0; while ((numRead = fileInputStream.read(buf)) != -1) out.write(buf, 0, numRead); fileInputStream.close(); return out.toByteArray(); } catch (FileNotFoundException e) { Log.w(TAG, e.getMessage()); e.printStackTrace(); absoluteDelete(path); return null; } catch (StreamCorruptedException e) { Log.w(TAG, e.getMessage()); e.printStackTrace(); absoluteDelete(path); return null; } catch (IOException e) { Log.w(TAG, e.getMessage()); e.printStackTrace(); absoluteDelete(path); return null; } catch (IllegalArgumentException e) { Log.w(TAG, e.getMessage()); e.printStackTrace(); absoluteDelete(path); return null; } catch (RuntimeException e) { // не позволим кэшу убить нашу программу Log.w(TAG, e.getMessage()); e.printStackTrace(); absoluteDelete(path); return null; } catch (Exception e) { // не позволим кэшу убить нашу программу Log.w(TAG, e.getMessage()); e.printStackTrace(); absoluteDelete(path); return null; } }
/** * Sends a specific <tt>Request</tt> to the STUN server associated with this * <tt>StunCandidateHarvest</tt>. * * @param request the <tt>Request</tt> to send to the STUN server associated with this * <tt>StunCandidateHarvest</tt> * @param firstRequest <tt>true</tt> if the specified <tt>request</tt> should be sent as the first * request in the terms of STUN; otherwise, <tt>false</tt> * @return the <tt>TransactionID</tt> of the STUN client transaction through which the specified * <tt>Request</tt> has been sent to the STUN server associated with this * <tt>StunCandidateHarvest</tt> * @param transactionID the <tt>TransactionID</tt> of <tt>request</tt> because <tt>request</tt> * only has it as a <tt>byte</tt> array and <tt>TransactionID</tt> is required for the * <tt>applicationData</tt> property value * @throws StunException if anything goes wrong while sending the specified <tt>Request</tt> to * the STUN server associated with this <tt>StunCandidateHarvest</tt> */ protected TransactionID sendRequest( Request request, boolean firstRequest, TransactionID transactionID) throws StunException { if (!firstRequest && (longTermCredentialSession != null)) longTermCredentialSession.addAttributes(request); StunStack stunStack = harvester.getStunStack(); TransportAddress stunServer = harvester.stunServer; TransportAddress hostCandidateTransportAddress = hostCandidate.getTransportAddress(); if (transactionID == null) { byte[] transactionIDAsBytes = request.getTransactionID(); transactionID = (transactionIDAsBytes == null) ? TransactionID.createNewTransactionID() : TransactionID.createTransactionID(harvester.getStunStack(), transactionIDAsBytes); } synchronized (requests) { try { transactionID = stunStack.sendRequest( request, stunServer, hostCandidateTransportAddress, this, transactionID); } catch (IllegalArgumentException iaex) { if (logger.isLoggable(Level.INFO)) { logger.log( Level.INFO, "Failed to send " + request + " through " + hostCandidateTransportAddress + " to " + stunServer, iaex); } throw new StunException(StunException.ILLEGAL_ARGUMENT, iaex.getMessage(), iaex); } catch (IOException ioex) { if (logger.isLoggable(Level.INFO)) { logger.log( Level.INFO, "Failed to send " + request + " through " + hostCandidateTransportAddress + " to " + stunServer, ioex); } throw new StunException(StunException.NETWORK_ERROR, ioex.getMessage(), ioex); } requests.put(transactionID, request); } return transactionID; }
/** * Updates a resource on the ckan server. * * @param resource ckan resource object * @return the updated resource * @throws JackanException */ public synchronized CkanResource updateResource(CkanResource resource, Boolean checkConsistency) { if (ckanToken == null) { throw new JackanException( "Tried to update resource" + resource.getName() + ", but ckan token was not set!"); } // check consistance with original version of the to be updated resource if (checkConsistency) { CkanResource originalResource = getResource(resource.getId()); for (Field f : originalResource.getClass().getDeclaredFields()) { f.setAccessible(true); String fieldName; try { if ((f.get(originalResource) != null) && (f.get(resource) == null) && (!f.getName().equals("created"))) { fieldName = f.getName(); // if(!fieldName.equals("created")){ f.set(resource, f.get(originalResource)); System.out.println("Not a null: " + fieldName + " Value: "); // //}; // System.out.println("Not a null: "+fieldName+ " Value: "); } } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } // System.out.println("After consistance checking resource is consist of: // "+resource.toString()); ObjectMapper objectMapper = CkanClient.getObjectMapper(); String json = null; try { json = objectMapper.writeValueAsString(resource); } catch (IOException e) { throw new JackanException("Couldn't serialize the provided CkanResourceMinimized!", e); } return postHttp( ResourceResponse.class, "/api/3/action/resource_update", json, ContentType.APPLICATION_JSON) .result; }
public int luaCB_four_to_five(Lua l, LuaPlugin plugin) { try { plugin.generateLuaClass(l, new BinaryOutFile(plugin, new FourToFiveEncoder(object))); } catch (IOException e) { l.pushNil(); l.pushString("IOException: " + e.getMessage()); return 2; } catch (IllegalArgumentException e) { l.pushNil(); l.pushString("Illegal argument: " + e.getMessage()); return 2; } return 1; }
public int luaCB_deflate(Lua l, LuaPlugin plugin) { try { plugin.generateLuaClass(l, new BinaryOutFile(plugin, new DeflaterOutputStream(object))); } catch (IOException e) { l.pushNil(); l.pushString("IOException: " + e.getMessage()); return 2; } catch (IllegalArgumentException e) { l.pushNil(); l.pushString("Illegal argument: " + e.getMessage()); return 2; } return 1; }
/** * Checks weather values of a target attribute are significantly different * * @return */ public boolean targetSignDifferent() { boolean res = false; int att = -1; String att_name; String att_name2; ClusStatistic targetStat = m_StatManager.getStatistic(ClusAttrType.ATTR_USE_TARGET); if (targetStat instanceof ClassificationStat) { for (int i = 0; i < targetStat.getNbNominalAttributes(); i++) { att_name = ((ClassificationStat) targetStat).getAttribute(i).getName(); for (int j = 0; j < m_ClassStat.getNbNominalAttributes(); j++) { att_name2 = m_ClassStat.getAttribute(j).getName(); if (att_name.equals(att_name2)) { att = j; break; } } if (SignDifferentNom(att)) { res = true; break; // TODO: If one target att significant, the whole rule significant!? } } // System.out.println("Target sign. testing: " + res); return res; } else if (targetStat instanceof RegressionStat) { for (int i = 0; i < targetStat.getNbNumericAttributes(); i++) { att_name = ((RegressionStat) targetStat).getAttribute(i).getName(); for (int j = 0; j < m_RegStat.getNbNumericAttributes(); j++) { att_name2 = m_RegStat.getAttribute(j).getName(); if (att_name.equals(att_name2)) { att = j; break; } } try { if (SignDifferentNum(att)) { res = true; break; // TODO: If one target att significant, the whole rule significant!? } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (MathException e) { e.printStackTrace(); } } return res; } else { // TODO: Classification and regression return true; } }
public int luaCB_text(Lua l, LuaPlugin plugin) { try { plugin.generateLuaClass(l, new TextOutFile(plugin, object)); } catch (IOException e) { l.pushNil(); l.pushString("IOException: " + e.getMessage()); return 2; } catch (IllegalArgumentException e) { l.pushNil(); l.pushString("Illegal argument: " + e.getMessage()); return 2; } return 1; }
public OntologyDB(ArrayList<String> filenames) { // create an empty model this.model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); // this.model = ModelFactory.createDefaultModel(); try { for (String filename : filenames) { // String modelFileName = filename; this.importOntology(filename); } } catch (IllegalArgumentException e) { System.out.println("Caught Exception : " + e.getMessage()); } this.reasoning(); }
/* Method purpose: Prompt the user for the name of the agent for editing. Method parameters: House data object, and int x for the object which coordinates it corresponds to. Return: None. */ public static void editAgentName(Map<Integer, House> data, int x) { // Prompt for the name, only reprompts if an error occurs. String name = ""; boolean valid = false; do { try { name = JOptionPane.showInputDialog(null, "Please enter the agents name"); data.get(x).setAgentName(name); valid = true; } catch (IllegalArgumentException f) { JOptionPane.showMessageDialog(null, f.getMessage()); valid = false; } } while (!valid); }
public static String resolveRelativePath(String relativePath, String base) { /*System.out.println("==============="); System.out.println(relativePath); System.out.println(base);*/ // keep simple cases as they were if ((base == null) || (new File(relativePath).isAbsolute())) { // System.out.println("1"); return relativePath; } if (base.startsWith("http")) { try { // System.out.println("2a"); return new URI(base).resolve(relativePath).toString(); } catch (URISyntaxException ex) { ex.printStackTrace(); } } if (!(relativePath.startsWith(".."))) { // System.out.println("2b"); File parentFile = new File(base).getParentFile(); if (parentFile == null) { return relativePath; } URI uri2 = parentFile.toURI(); String modRelPath = relativePath.replaceAll(" ", "%20"); // String modRelPath = relativePath; try { URI absoluteURI = uri2.resolve(modRelPath); return new File(absoluteURI).getAbsolutePath(); } catch (IllegalArgumentException use) { use.printStackTrace(); return relativePath; } } // the relative Path starts with .. String UP = ".." + System.getProperty("file.separator"); String OTHER = "../"; if (relativePath.startsWith(UP) || relativePath.startsWith(OTHER)) { String newBase = new File(base).getParent(); String newRelative = relativePath.substring(3); // System.out.println("3"); return resolveRelativePath(newRelative, newBase); } // no can do // System.out.println("4"); return relativePath; }
/** {@inheritDoc} */ @POST @Path("/note") @Consumes(MediaType.APPLICATION_XML) @TypeHint(Note.class) @Override public Response addNote(Note note) { IdCardNote newNote; Note savedNote; try { newNote = cardManager.addNote(note); savedNote = Note.createNote(newNote); } catch (IllegalArgumentException e) { return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build(); } return Response.ok().entity(savedNote).build(); }
/** * Function that creates a "ARCHIVE" folder that is going to contain all the archives that will be * created by this program. * * @return folder that is going to contain all the archives that will be created by this program */ private File createArchive() { archiveDirectory = null; try { String homePath = System.getProperty("user.home"); archiveDirectory = new File(homePath + File.separatorChar + "Archive"); if (!archiveDirectory.exists()) archiveDirectory.mkdir(); } catch (SecurityException ex) { ex.printStackTrace(); } catch (NullPointerException ex) { ex.printStackTrace(); } catch (IllegalArgumentException ex) { ex.printStackTrace(); } return archiveDirectory; }
public static int luaCB_open(Lua l, LuaPlugin plugin) { l.pushNil(); String name = l.checkString(1); try { plugin.generateLuaClass(l, new BinaryOutFile(plugin, new FileOutputStream(name))); } catch (IOException e) { l.pushNil(); l.pushString("IOException: " + e.getMessage()); return 2; } catch (IllegalArgumentException e) { l.pushNil(); l.pushString("Illegal argument: " + e.getMessage()); return 2; } return 1; }
public static Integer getProcessID(Process p) { try { Field f = p.getClass().getDeclaredField("pid"); f.setAccessible(true); Integer s = (Integer) f.get(p); return s; } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return null; }
public String submitSIP(String endpoint, String user, String pass, Package pkg) throws RPCException { AbderaClient client = null; try { client = getClient(endpoint, user, pass); RequestOptions opts = new RequestOptions(); opts.setContentType("application/xml"); opts.setHeader("X-Packaging", "http://dataconservancy.org/schemas/dcp/1.0"); opts.setHeader("X-Verbose", "true"); Dcp dcp; try { dcp = PackageUtil.constructDcp(pkg); } catch (IllegalArgumentException e) { // e.printStackTrace(); throw new RPCException("Malformed SIP: " + e.getMessage()); } ByteArray buf = new ByteArray(8 * 1024); dcpbuilder.buildSip(dcp, buf.asOutputStream()); ClientResponse resp = client.post(endpoint, buf.asInputStream(), opts); int status = resp.getStatus(); StringWriter result = new StringWriter(); resp.getDocument().writeTo(result); if (status == 200 || status == 201 || status == 202) { return result.toString(); } else { throw new RPCException("Package deposit failed: " + result); } } catch (IOException e) { throw new RPCException(e.getMessage()); } catch (URISyntaxException e) { throw new RPCException(e.getMessage()); } finally { if (client != null) { client.teardown(); } } }
/** {@inheritDoc} */ @GET @Path("/newCard") @Override @TypeHint(IdCard.class) public Response getNewCard( @QueryParam("personId") String personId, @QueryParam("byuId") String byuId, @QueryParam("ssn") String ssn, @QueryParam("netId") String netId, @QueryParam("proxId") String proxId) { IdCard newCard; try { newCard = cardManager.getNewCard(personId, byuId, ssn, netId); } catch (IllegalArgumentException iae) { return Response.status(Response.Status.BAD_REQUEST).entity(iae.getMessage()).build(); } return Response.ok().entity(newCard).build(); }
/*Method purpose: To find the file that is to be read into the program. Method parameters: House[] data object Return: String path, path of the file for re-writing purposes. */ public static String chooseFile(Map<Integer, House> data, String path) throws FileNotFoundException { // Initialize all the variables int xCord = -1; int yCord = -1; String name = " "; double money = 0.0; int status = -1; int type = -1; Scanner in = null; int i = 0; String comma; try { in = new Scanner(new FileInputStream(path)); while (in.hasNextLine()) { xCord = Integer.parseInt(in.next()); comma = in.next(); yCord = Integer.parseInt(in.next()); comma = in.next(); name = in.next(); comma = in.next(); money = Double.parseDouble(in.next()); comma = in.next(); status = Integer.parseInt(in.next()); comma = in.next(); type = Integer.parseInt(in.next()); // make sure I cannot get higher than 24 data.put(i, new House(xCord, yCord, name, money, status, type)); i++; } in.close(); } catch (IllegalArgumentException f) { JOptionPane.showMessageDialog(null, f.getMessage()); } catch (FileNotFoundException g) { JOptionPane.showMessageDialog(null, "Sorry, the file was not found"); } catch (NoSuchElementException h) { } return path; }
@Override public DbData readData(InputStream in) throws XMLStreamException { XMLStreamReader sr = _staxInFactory.createXMLStreamReader(in); DbData result = new DbData(); sr.nextTag(); expectTag(FIELD_TABLE, sr); try { while (sr.nextTag() == XMLStreamReader.START_ELEMENT) { result.addRow(readRow(sr)); } } catch (IllegalArgumentException iae) { throw new XMLStreamException("Data problem: " + iae.getMessage(), sr.getLocation()); } sr.close(); return result; }
/* Method purpose: Presents the user with a simple menu for property type Method parameters: House data object, and int x for the object which coordinates it corresponds to. Return: None. */ public static void editPropertyType(Map<Integer, House> data, int x) { Object[] property = {"Single family home", "Townhouse", "Condo", "Apartment"}; int propertyType = 0; try { propertyType = JOptionPane.showOptionDialog( null, "Which type of property is this home?", "Property edit", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, property, property[0]); } catch (IllegalArgumentException e) { JOptionPane.showMessageDialog(null, e.getMessage()); } data.get(x).setType(propertyType); }
public void play() { try { mp.setDataSource( Environment.getExternalStorageDirectory() + "/pathofthefile/" + FirstSettings_two.file_video); mp.prepare(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } mp.start(); }
public static void main(String[] args) throws Exception { System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); /** * This test does not establish any connection to the specified URL, hence a dummy URL is used. */ URL foobar = new URL("https://example.com/"); HttpsURLConnection urlc = (HttpsURLConnection) foobar.openConnection(); try { urlc.getCipherSuite(); } catch (IllegalStateException e) { System.out.print("Caught proper exception: "); System.out.println(e.getMessage()); } try { urlc.getServerCertificateChain(); } catch (IllegalStateException e) { System.out.print("Caught proper exception: "); System.out.println(e.getMessage()); } try { urlc.setDefaultHostnameVerifier(null); } catch (IllegalArgumentException e) { System.out.print("Caught proper exception: "); System.out.println(e.getMessage()); } try { urlc.setHostnameVerifier(null); } catch (IllegalArgumentException e) { System.out.print("Caught proper exception: "); System.out.println(e.getMessage()); } try { urlc.setDefaultSSLSocketFactory(null); } catch (IllegalArgumentException e) { System.out.print("Caught proper exception: "); System.out.println(e.getMessage()); } try { urlc.setSSLSocketFactory(null); } catch (IllegalArgumentException e) { System.out.print("Caught proper exception"); System.out.println(e.getMessage()); } System.out.println("TESTS PASSED"); }
/* Method purpose: Prompt the user for the status of the house. Method parameters: House data object, and int x for the object which coordinates it corresponds to. Return: None. */ public static void editStatus(Map<Integer, House> data, int x) { // present the user with a buttom prompt. Then simply pass the choice into the house object. Object[] status = {"For sale", "Sold", "N/A"}; int propertyStatus = 0; try { propertyStatus = JOptionPane.showOptionDialog( null, "What is the status of this home??", "Property edit", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, status, status[0]); } catch (IllegalArgumentException e) { JOptionPane.showMessageDialog(null, e.getMessage()); } data.get(x).setHouseStatus(propertyStatus); }