/* * * ========== * ========== * ========== * ========== * ========== * ========== * ========== * ========== * * * Validatable methods: * * ========== * ========== * ========== * ========== * ========== * ========== * ========== * ========== * */ @Override public boolean isValid() { for (QuestionAnsweringRVInfo questionAnsweringRVInfo : questionAnsweringRVInfoList) { try { if (questionAnsweringRVInfo.getAnswer().getAnswerArray().length == 0) { try { invalidText = context .getResources() .getString( R.string.output_invalidField_questionAnsweringRV_unansweredQuestions); } catch (NullPointerException e) { e.printStackTrace(); } return false; } } catch (NullPointerException e) { try { invalidText = context .getResources() .getString(R.string.output_invalidField_questionAnsweringRV_unansweredQuestions); } catch (NullPointerException e2) { e2.printStackTrace(); } return false; } } return true; }
private static String convertLocalURLTag(final String name, final String arg) { if (name.equals("sprite")) { try { Pony tmp = PonyCreator.create(arg); return "" + tmp.getFrontSprite(); } catch (ReflectiveOperationException e) { printDebug("[Meta.toLocalURL] Error creating pony " + arg + ": " + e); e.printStackTrace(); } } else if (name.equals("type")) { try { return "" + pokepon.enums.Type.forName(arg).getToken(); } catch (NullPointerException e) { printDebug("[Meta.toLocalURL] Error creating type " + arg); e.printStackTrace(); } } else if (name.equals("movetype")) { try { return "" + Move.MoveType.forName(arg).getToken(); } catch (NullPointerException e) { printDebug("[Meta.toLocalURL] Error creating movetype " + arg); e.printStackTrace(); } } return ""; }
public static <T extends Number> ArrayList<ArrayList<T>> solve( ArrayList<ArrayList<T>> a, ArrayList<ArrayList<T>> bVector, double eps, Class<T> type) { try { if (verifySingularity(a, eps)) { int size = a.size(); ArrayList<ArrayList<T>> solution = new ArrayList<ArrayList<T>>(); for (int i = 0; i < size; i++) { solution.add(new ArrayList<T>()); } for (int i = size - 1; i >= 0; i--) { T sum = bVector.get(i).get(0); for (int j = i + 1; j < size; j++) { T value = a.get(i).get(j); T x = solution.get(j).get(0); sum = subsElements(sum, mulElements(value, x, type), type); } solution.get(i).add(divElements(sum, a.get(i).get(i), type, eps)); } // this.checkSolution(); return solution; } else { return null; } } catch (NullPointerException e) { Logger.getGlobal().log(Level.SEVERE, "something went wrong solving the sys!"); e.printStackTrace(); return null; } catch (IndexOutOfBoundsException e) { Logger.getGlobal().log(Level.SEVERE, "check your indexes!"); e.printStackTrace(); return null; } }
/** * Uses {@link uk.ac.aber.cs211.wordladder.Generator} to produce a random word ladder. args[1] is * the initial word while args[2] is the depth of the word ladder to produce. * * @param args Command line arguments from invocation. */ public static void generate(String[] args) { String startWord = null; int depth = 0; try { startWord = args[1]; depth = Integer.parseInt(args[2]); } catch (NullPointerException e) { if (args.length < 3) { System.err.println("Insufficient arguments."); printHelp(); System.exit(-1); } e.printStackTrace(); System.exit(-1); } Generator generator = null; try { generator = new Generator().setStart(startWord).setDepth(depth); } catch (IOException e) { System.err.println("Could not load dictionaries. Check current working directory."); System.exit(-1); } List<String> solution = generator.run(); if (solution == null) { System.err.println("A ladder of that depth is not possible."); System.exit(-1); } System.out.println(solution); System.exit(0); }
@Override public boolean onTouchEvent(MotionEvent event) { try { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: Drawable drawable = getDrawable(); if (drawable != null) { drawable.mutate().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY); } break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: Drawable drawableUp = getDrawable(); if (drawableUp != null) { drawableUp.mutate().clearColorFilter(); } break; } } catch (NullPointerException e) { e.printStackTrace(); } return super.onTouchEvent(event); }
/* * This method will open a file that the user chooses, * then store the data from the file into a StringBuffer. */ public static StringBuffer openFile() { StringBuffer fileContents = new StringBuffer(); // Declares the String buffer to hold text in the text file. JFileChooser chooser = new JFileChooser(); // Declares the JFileChooser object to let the user choose their file. FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXT FILES", "txt", "text"); chooser.setFileFilter(filter); // Adds the fileNameExtensionFilter into the JFileChooser chooser.showOpenDialog(null); // Displays an open dialog window. File targetFile = chooser.getSelectedFile(); // Assigns the chosen file to the variable targetFile. try { Scanner myScanner = new Scanner( targetFile); // Declares and instantiates our Scanner object for reading the file. while (myScanner.hasNextLine()) { // Our loop will check to ensure there is a line there. // This line of code takes the nextLine of text from the file and appends it to our // StringBuffer. fileContents.append(myScanner.nextLine() + "\r\n"); } myScanner.close(); // Closes our scanner object so that we're not wasting resources. } catch (NullPointerException event) { System.out.println("We've encountered a NullPointerException"); event.printStackTrace(); } catch (FileNotFoundException event) { System.out.println("We've encountered a FileNotFoundException"); event.printStackTrace(); } return new StringBuffer( fileContents); // Returns a new StringBuffer item which will contain the text from the file. }
/** * This function takes an OMGraphicList and loads each one with the array representing the records * in the dbf file. Each graphics stores the graphic in its object slot. */ public void loadDbfModelIntoGraphics(OMGraphicList list) { if (list != null && dbfModel.getRowCount() > 0) { int numgraphics = list.size(); for (int i = 0; i < numgraphics; i++) { try { OMGraphic omg = list.getOMGraphicAt(i); Integer recnum = (Integer) (omg.getAttribute(ShapeConstants.SHAPE_INDEX_ATTRIBUTE)); // OFF BY ONE!!! The shape record numbers // assigned to the records start with 0, while // everything else we do starts with 0. The DbfTableModel // follows java convention and starts at 0. The integer // stored in the OMG should know it too. Object inforec = dbfModel.getRecord(recnum.intValue()); omg.putAttribute(ShapeConstants.SHAPE_DBF_INFO_ATTRIBUTE, inforec); } catch (ClassCastException cce) { if (Debug.debugging("shape")) { cce.printStackTrace(); } } catch (NullPointerException npe) { npe.printStackTrace(); } } } }
public void commit() throws ResourceException { if (DEBUG) { try { throw new NullPointerException("Asif:JCALocalTransaction:commit"); } catch (NullPointerException npe) { npe.printStackTrace(); } } LogWriter logger = cache.getLogger(); if (logger.fineEnabled()) { logger.fine("JCALocalTransaction:invoked commit"); } TXStateProxy tsp = this.gfTxMgr.getTXState(); if (tsp != null && this.tid != tsp.getTransactionId()) { throw new IllegalStateException( "Local Transaction associated with Tid = " + this.tid + " attempting to commit a different transaction"); } try { this.gfTxMgr.commit(); this.tid = null; } catch (Exception e) { throw new LocalTransactionException(e.toString()); } // Iterator<ConnectionEventListener> itr = this.listeners.iterator(); // ConnectionEvent ce = new // ConnectionEvent(this,ConnectionEvent.LOCAL_TRANSACTION_COMMITTED); // while( itr.hasNext()) { // itr.next().localTransactionCommitted(ce); // } }
@Override public void run() { if (bot.hasMessage()) { message = bot.getMessage(); channel = bot.getChannel(); sender = bot.getSender(); } if (this.message.startsWith("~vote")) { tokenize(false, 5, this.message); try { if ((voters != null) && (((Integer) voters.get(this.sender)).intValue() == 1)) { return; } } catch (NullPointerException ex) { ex.printStackTrace(); } if (this.parameters.equalsIgnoreCase(" y")) { voteYes += 1; voters.put(this.sender, Integer.valueOf(1)); } else if (this.parameters.equalsIgnoreCase(" n")) { voteNo += 1; voters.put(this.sender, Integer.valueOf(1)); } Main.bot.sendMessage(this.channel, voteYes + " " + voteNo); } }
@Override protected String doInBackground(String... strings) { JsonParser jsonParser = new JsonParser(GamePlayStrategyActivity.this); String url = Const.GET_ACTIVE_USERS; String jsonString = jsonParser.getJSONFromUrl(url); // Log.e("jsonStringurl", url); try { JSONObject jsonObject = new JSONObject(jsonString); if (jsonObject != null) { result = jsonObject.getInt(Const.KEY_RESULT); activeUsers = jsonObject.getString(Const.KEY_ACTIVE_USER); } else { msg = jsonObject.getString(Const.KEY_MSG); } } catch (NullPointerException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return null; }
public static void witeObjectToFile(Object object, File file) { ObjectOutputStream objectOut = null; FileOutputStream fileOut = null; try { if (!file.exists()) { file.createNewFile(); } fileOut = new FileOutputStream(file, false); objectOut = new ObjectOutputStream(fileOut); objectOut.writeObject(object); fileOut.getFD().sync(); } catch (IOException e) { e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } finally { if (objectOut != null) { try { objectOut.close(); } catch (IOException e) { // do nowt } } if (fileOut != null) { try { fileOut.close(); } catch (IOException e) { // do nowt } } } }
private static boolean setCharacteristicNotification( BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic characteristic, boolean enabled) { if (bluetoothGatt == null) { Log.w(TAG, "BluetoothAdapter not initialized"); return false; } bluetoothGatt.setCharacteristicNotification(characteristic, enabled); try { BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(UUIDDes)); if (descriptor != null) { descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); return (bluetoothGatt.writeDescriptor(descriptor)); } else { Log.e(TAG, "descriptor is null"); return false; } } catch (NullPointerException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } return true; }
@Override public String execute() throws Exception { try { Map session = ActionContext.getContext().getSession(); session.put("User", null); session.clear(); myDao.getDbsession().close(); addActionMessage("Successfully Logged Out."); return "success"; } catch (HibernateException e) { addActionError("Server Error Please Try Again "); e.printStackTrace(); return "error"; } catch (NullPointerException ne) { addActionError("Server Error Please Try Again "); ne.printStackTrace(); return "error"; } catch (Exception e) { addActionError("Server Error Please Try Again "); e.printStackTrace(); return "error"; } }
/** * Sorts the array of objects of class data in an ascending order based upon the value present in * the field id * * @param v to execute this method when the corresponding button is clicked */ public static void sortObjects(View v) { try { Log.i("Unsorted List:", gson.toJson(dataObjects)); // Create a comparator which compares the objects based upon the // values of field id and sort this array of objects in an ascending // order using this comparator Collections.sort( Arrays.asList(dataObjects), new Comparator<Data>() { @Override public int compare(Data dateFirstObject, Data dateSecondObject) { // compare the two objects based upon the value of // field Id and // return values accordingly to sort objects in an // ascending // order if (dateFirstObject.getId() < dateSecondObject.getId()) { return 1; } else if (dateFirstObject.getId() > dateSecondObject.getId()) { return -1; } else { return 0; } } }); Log.i("Sorted list based upon the latest timestamp", gson.toJson(dataObjects)); } catch (NullPointerException e) { e.printStackTrace(); Log.i("Null pointer exception", "Null pointer exception in sortObjects"); } }
public static <T extends Number> ArrayList<ArrayList<T>> getInverse( ArrayList<ArrayList<T>> QT, ArrayList<ArrayList<T>> R, double eps, Class<T> type) { try { ArrayList<ArrayList<T>> inverse = new ArrayList<ArrayList<T>>(); ArrayList<ArrayList<T>> solCol; int size = QT.size(); for (int i = 0; i < size; i++) { ArrayList<T> row = new ArrayList<T>(); inverse.add(row); } for (int col = 0; col < size; col++) { ArrayList<ArrayList<T>> bAsMatrix = new ArrayList<ArrayList<T>>(); for (int row = 0; row < size; row++) { ArrayList<T> rowInB = new ArrayList<T>(); rowInB.add(QT.get(row).get(col)); bAsMatrix.add(rowInB); } solCol = solve(R, bAsMatrix, eps, type); for (int i = 0; i < size; i++) { inverse.get(i).add(solCol.get(i).get(0)); } } return inverse; } catch (NullPointerException e) { e.printStackTrace(); return null; } }
/** * @param pcat * @param array * @param coordTab * @param flagIgnore */ private static void fillXMatchArray( Pcat pcat, double[][] array, int[] coordTab, boolean[] flagIgnore) { Source o; String content; Iterator<Obj> it = pcat.iterator(); for (int i = 0; it.hasNext(); i++) { o = (Source) it.next(); // not needed // flagIgnore[i] = false; try { // ra content = o.getValue(coordTab[0]); if (isSexa(content)) content = sexa2Deg(content, true); // array[i][0] = Double.parseDouble(content); array[i][0] = Double.valueOf(content).doubleValue(); // dec content = o.getValue(coordTab[1]); if (isSexa(content)) content = sexa2Deg(content, false); // array[i][1] = Double.parseDouble(content); array[i][1] = Double.valueOf(content).doubleValue(); } catch (NumberFormatException e) { e.printStackTrace(); // ignore this source flagIgnore[i] = true; // array[i][0] = array[i][1] = 0.0; } catch (NullPointerException npe) { npe.printStackTrace(); // ignore this source flagIgnore[i] = true; } } }
public BookCatalogImpl() { try { final String filePath = path + "catalog.json"; // read the json file ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream inputStream = classLoader.getResourceAsStream(filePath); BufferedReader streamReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); bookStrBuilder = new StringBuilder(); String inputStr; while ((inputStr = streamReader.readLine()) != null) bookStrBuilder.append(inputStr); final ObjectMapper mapper = new ObjectMapper(); catalog = mapper.readValue(bookStrBuilder.toString(), new TypeReference<List<Book>>() {}); hBookDetails = new Hashtable(); for (Book book : catalog) { hBookDetails.put(book.getId(), book); } } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } catch (NullPointerException ex) { ex.printStackTrace(); } }
public static String getAccFriends(MainExcel.AccountObj accountObj) throws Exception { String accountId = accountObj.id; String accountTokken = accountObj.token; String count; String uri; JSONObject responseArray; try { uri = "https://api.vk.com/method/friends.get?user_id=" + accountId + "&count=1&v=5.24&access_token=" + accountTokken; responseArray = (MainRequest.getRequestJson(uri)); count = ((JSONObject) responseArray.get("response")).get("count").toString(); } catch (NullPointerException e) { System.out.println("getCountMyFriends.NullPointerException" + e.getMessage()); e.printStackTrace(); // count = CheckerFunc.getAccFriends(accountObj); count = "0"; } return count; }
/** * Sets up the GUI, ensuring that everything is loaded nicely. * * @param location * @param resources */ public void initialize(URL location, ResourceBundle resources) { filter = new Filter(); Set<String> books = new HashSet<>(); for (Book book : Book.values()) { books.add(book.toString()); } filter.setBooks(books); results.setItems(listItems); String index = "java_ebook_search/index"; String home = "/java_ebook_search/view/index.html"; try { search = new Search(index); commonTerms = TextFields.bindAutoCompletion(query, search.getAutocomplete()); commonTerms.setVisibleRowCount(10); sc = new SpellCheck(); webEngine = webView.getEngine(); webEngine.load(getClass().getResource(home).toString()); results .getSelectionModel() .selectedItemProperty() .addListener((observable, oldValue, newValue) -> loadResult(newValue)); } catch (NullPointerException e) { System.out.println("It's happened again, ignore it"); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
/** Running thread */ public void run() { try { in = new ObjectInputStream(clientSocket.getInputStream()); out = new ObjectOutputStream(clientSocket.getOutputStream()); this.query = (String) in.readObject(); // LOG.debug("Query: " + query); // We assume that query should either start with one of OntQueryQueue.QUERY_TYPES or // the query type will be missing - for the getBeanForId(id) queries OntQueryQueue oqq = new OntQueryQueue(query); if (oqq.getQueryType() == null || oqq.getQueryType().equals("")) { // it's a single id query this.results = new TreeSet<OntBean>(); String fbbtId = oqq.getQueries().get(0); OntBean ob = dlQueryServer.getBeanForId(fbbtId); this.results.add(ob); } else { // it's a list query this.results = dlQueryServer.askQuery(this.query); } sendObjectToClient(this.results); } catch (IOException ex) { ex.printStackTrace(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } catch (NullPointerException ex) { ex.printStackTrace(); } }
@Override public void onBindViewHolder(final ViewHolder viewHolder, int i) { // set text if (viewHolder.tvDeviceName != null) { if (mDataset.get(i).getBondState() == BluetoothDevice.BOND_BONDED) { viewHolder.tvDeviceName.setTextColor( ContextCompat.getColor(activity, R.color.forest_green)); } viewHolder.tvDeviceName.setText(mDataset.get(i).getName()); } if (mDataset.get(i) != null) { try { if (!mDataset.get(i).getName().contains(A108prefix)) { viewHolder.ivDeviceIcon.setImageResource(R.mipmap.bt); } } catch (NullPointerException e) { e.printStackTrace(); } if (viewHolder.tvDeviceMac != null) viewHolder.tvDeviceMac.setText(mDataset.get(i).getAddress()); } }
@Override public JSONRPC2Response process(Map<String, Object> params) { JSONRPC2Response resp = null; try { Integer id = HandlerUtils.<Number>fetchField(FSID, params, true, null).intValue(); String status = FVConfigurationController.instance().flowSpaceStatus(id); resp = new JSONRPC2Response(status, 0); } catch (ClassCastException e) { resp = new JSONRPC2Response( new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), cmdName() + ": " + e.getMessage()), 0); } catch (MissingRequiredField e) { resp = new JSONRPC2Response( new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), cmdName() + ": " + e.getMessage()), 0); } catch (NullPointerException e) { e.printStackTrace(); } return resp; }
/** Performs dispersal operations associated with the Occupant. */ public void disperse() { try { propagules = disperser.disperse(); } catch (NullPointerException e) { e.printStackTrace(); } }
public void setCertificate(String KeyStore, String KeyPass, String TrustStore, String TrustPass) { this.keyStore = KeyStore; this.keyPass = KeyPass; this.trustStore = TrustStore; this.trustPass = TrustPass; try { ClassLoader loader = getClass().getClassLoader(); String certificate = ""; URL kURL = loader.getResource("certificate/" + KeyStore); certificate = kURL.toString().replace("file:/", ""); System.setProperty("javax.net.ssl.keyStore", certificate); System.setProperty("javax.net.ssl.keyStorePassword", KeyPass); System.setProperty("javax.net.ssl.keyStoreType", "JKS"); URL tURL = loader.getResource("certificate/" + TrustStore); certificate = tURL.toString().replace("file:/", ""); System.setProperty("javax.net.ssl.trustStore", certificate); System.setProperty("javax.net.ssl.trustStorePassword", TrustPass); System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); } catch (NullPointerException e) { e.printStackTrace(); logger.error(e.toString()); } }
@Override public View getView(Context context) { View view = LayoutInflater.from(context).inflate(getCardLayout(), null); mCardLayout = view; try { ((FrameLayout) view.findViewById(R.id.cardContent)).addView(getCardContent(context)); } catch (NullPointerException e) { e.printStackTrace(); } // ((TextView) view.findViewById(R.id.title)).setText(this.title); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); int bottom = Utils.convertDpToPixelInt(context, 12); lp.setMargins(0, 0, 0, bottom); view.setLayoutParams(lp); return view; }
/** * @param clazz * @param constantName * @param declared * @return */ public static String getStringConstant(Class<?> clazz, String constantName, boolean declared) { Field compType = null; try { // check if there's a // public static final String COMPONENT_TYPE = "..."; compType = declared ? clazz.getDeclaredField(constantName) : clazz.getField(constantName); } catch (SecurityException e) { // if no such field, fall through } catch (NoSuchFieldException e) { // if no such field, fall through } if (null == compType) return null; int modifiers = compType.getModifiers(); if (!Modifier.isStatic(modifiers) || !Modifier.isPublic(modifiers) || !Modifier.isFinal(modifiers) || String.class != compType.getType()) { return null; } try { return (String) compType.get(null); } catch (IllegalArgumentException e1) { // shouldn't happen - the arg is of the correct type e1.printStackTrace(); } catch (IllegalAccessException e1) { // shouldn't happen - the method is public e1.printStackTrace(); } catch (NullPointerException e1) { // shouldn't happen - allowed a null arg when // the field is static e1.printStackTrace(); } return null; }
public String[] getSessionHTML(HttpSession session, HttpServletRequest request) throws ServletException, IOException { String user = null; String group = null; String userName = null; String groupname = null; String redirect = ""; try { redirect = UserRecord; if (session.getAttribute("user") == null) { session.invalidate(); request.getRequestDispatcher(redirect).include(request, response); } else { user = (String) session.getAttribute("user"); group = (String) session.getAttribute("group"); } Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals("user")) sess[0] = cookie.getValue(); if (cookie.getName().equals("JSESSIONID")) sessionID = cookie.getValue(); if (cookie.getName().equals("group")) sess[1] = cookie.getValue(); break; } } } catch (NullPointerException n) { n.printStackTrace(); } return sess; }
public List<ArrayList<Object>> getDataFromDB(String tableName) { List<ArrayList<Object>> dataDB = new ArrayList<ArrayList<Object>>(); ResultSet res; try { int i = 0; res = statement.executeQuery("SELECT * FROM " + tableName); ResultSetMetaData rsMetaData = res.getMetaData(); int numberOfColumns = rsMetaData.getColumnCount(); for (int u = 0; u < numberOfColumns; u++) { dataDB.add(new ArrayList<Object>()); } while (res.next()) { for (int j = 1; j <= numberOfColumns /* cols size */; j++) { dataDB.get(j - 1).add("" + res.getString(j)); } i++; } return dataDB; } catch (SQLException e) { e.printStackTrace(); return null; } catch (NullPointerException k) { k.printStackTrace(); } return null; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_details, container, false); toolbar = (Toolbar) rootView.findViewById(R.id.toolbar); posterText = (TextView) rootView.findViewById(R.id.posterTitle); posterBar = (ImageView) rootView.findViewById(R.id.posterImage); dateText = (TextView) rootView.findViewById(R.id.release_date); durationText = (TextView) rootView.findViewById(R.id.duration); voteText = (TextView) rootView.findViewById(R.id.average_vote); overviewText = (TextView) rootView.findViewById(R.id.overview); trailerListView = (ListView) rootView.findViewById(R.id.trailerListView); trailerListView.setOnItemClickListener(this); reviewListView = (ListView) rootView.findViewById(R.id.reviewListView); trailerLinear = (LinearLayout) rootView.findViewById(R.id.trailer_linear); reviewLinear = (LinearLayout) rootView.findViewById(R.id.review_linear); toggleBtn = (ToggleButton) rootView.findViewById(R.id.toggle); toggleBtn.setOnClickListener(this); Log.i("isNull", getArguments() == null ? "ok" : "no"); if (toolbar != null) { // onePane Mode ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); try { ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } catch (NullPointerException e) { e.printStackTrace(); } } curd = new CURD(getActivity(), movie); return rootView; }
/** * Gets the connection. * * @param databaseName the database name * @param databaseIP the database ip * @return the connection * @throws Exception the exception */ public Connection getConnection(String databaseName, String databaseIP) /* */ throws Exception /* */ { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); Properties properties = new EncryptableProperties(encryptor); try { properties.load(this.getClass().getClassLoader().getResourceAsStream("mysql.properties")); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); throw fnfe; } catch (NullPointerException fnfe) { fnfe.printStackTrace(); throw fnfe; } String username = properties.getProperty("mysql.user"); encryptor.setPassword(username); // could be got from web, env variable... String passwd = properties.getProperty("mysql.password"); String port = properties.getProperty("mysql.port"); databaseIP = properties.getProperty("mysql.databaseIP", databaseIP); databaseName = properties.getProperty("mysql.databaseName", databaseName); /* */ try { /* 49 */ Connection connection = DriverManager.getConnection( "jdbc:mysql://" + databaseIP + ":" + port + "/" + databaseName, username, passwd); /* 50 */ return connection; /* */ } /* */ catch (SQLException e) /* */ { /* 59 */ e.printStackTrace(); /* 60 */ throw e; /* */ } /* */ }