Example usage for java.lang NullPointerException printStackTrace

List of usage examples for java.lang NullPointerException printStackTrace

Introduction

In this page you can find the example usage for java.lang NullPointerException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.pseudosudostudios.jdd.fragments.ScoreFragment.java

public void setDisplays(Bundle data) {
    try {//  www  .jav a2  s .co m
        this.time = data.getLong(WinActivity.timeKey);
        this.moves = data.getInt(WinActivity.moveKey);
        this.numColors = Grid.numberOfColors;
        Entry n = new Entry(data.getString(WinActivity.levelKey), moves, time, Grid.numberOfColors);
        this.score = n.getScore();
        timeDisplay.setText(time / 1000 + "");
        scoreDisplay.setText(score + "");
        movesDisplay.setText(moves + "");
        shareSocial.setVisibility(View.VISIBLE);
        ScoreSaves.addNewScore(getActivity(), n);
        highScores.setAdapter(new HighScoresAdapter(getActivity()));
        highScores.invalidate();
        // Google play games
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:com.softminds.matrixcalculator.base_fragments.VariableMul.java

private void AddToQueue(MatrixV2 click) {
    try {/*from   w w w. ja  v  a 2 s  .  com*/
        @SuppressWarnings("ConstantConditions") //to suppress the null pointer exception of the  textview
        TextView textView = getParentFragment().getView().findViewById(R.id.AdditionStatus);
        String Initial = textView.getText().toString();
        if (Initial.isEmpty()) {
            textView.setText(click.getName());
            ((GlobalValues) getActivity().getApplication()).MatrixQueue.add(click);
        } else {
            String Complete = Initial + " x " + click.getName();
            textView.setText(Complete);
            ((GlobalValues) getActivity().getApplication()).MatrixQueue.add(click);
        }
    } catch (NullPointerException e) {
        Log.d("AddToQueue", "Exception raised, cannot get textview from parent fragment");
        e.printStackTrace();
    }

}

From source file:it.cnr.icar.eric.server.interfaces.rest.UserDefinedURLHandler.java

/**
 * Attempt to get a RegistryObject by its URI.
 *
 *//*from   w w  w  . j a va 2s . c o  m*/
private List<?> getRegistryObjectByURI() throws IOException, RegistryException, ObjectNotFoundException {
    List<?> results = null;
    @SuppressWarnings("unused")
    Locale locale = request.getLocale();
    String pathInfo = request.getPathInfo();

    try {
        RegistryObjectType ro = null;

        String queryString = "SELECT ro.* FROM RegistryObject ro, Slot s " + "WHERE s.value='" + pathInfo
                + "' AND " + "s.name_='" + BindingUtility.CANONICAL_SLOT_LOCATOR + "' AND s.parent=ro.id";

        results = submitQueryAs(queryString, currentUser);

        if (results.size() == 0) {
            throw new ObjectNotFoundException(ServerResourceBundle.getInstance()
                    .getString("message.noRegistryObjectFound", new Object[] { pathInfo }));
        } else if (results.size() == 1) {
            ro = (RegistryObjectType) results.get(0);
            writeRegistryObject(ro);
        } else {
            throw new RegistryException(ServerResourceBundle.getInstance()
                    .getString("message.duplicateRegistryObjects", new Object[] { pathInfo }));
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new RegistryException(
                it.cnr.icar.eric.server.common.Utility.getInstance().getStackTraceFromThrowable(e));
    }

    if ((results == null) || (results.size() == 0)) {
        throw new ObjectNotFoundException(ServerResourceBundle.getInstance()
                .getString("message.noRegistryObjectFound", new Object[] { pathInfo }));
    }

    return results;
}

From source file:it.cnr.icar.eric.server.interfaces.rest.UserDefinedURLHandler.java

/**
 * Attempt to get a RepositoryItem by its URI.
 *
 *//*from  w ww .  jav  a2  s .c  o  m*/
private List<?> getRepositoryItemByURI() throws IOException, RegistryException, ObjectNotFoundException {
    List<?> results = null;
    String pathInfo = request.getPathInfo();

    //If path begins with a '/' then we also need to check for same patch but without leading '/'
    //because zip files with relative entry paths when cataloged do not have the leading '/'
    String pathInfo2 = new String(pathInfo);
    if (pathInfo2.charAt(0) == '/') {
        pathInfo2 = pathInfo2.substring(1);
    }

    try {
        ExtrinsicObjectType ro = null;

        String queryString = "SELECT eo.* FROM ExtrinsicObject eo, Slot s " + "WHERE (s.value='" + pathInfo
                + "' OR s.value='" + pathInfo2 + "') AND " + "s.name_='"
                + BindingUtility.CANONICAL_SLOT_CONTENT_LOCATOR + "' AND s.parent=eo.id";

        results = submitQueryAs(queryString, currentUser);

        if (results.size() == 0) {
            throw new ObjectNotFoundException(ServerResourceBundle.getInstance()
                    .getString("message.noRepositoryItemFound", new Object[] { pathInfo }));
        } else if (results.size() == 1) {
            ro = (ExtrinsicObjectType) results.get(0);
            writeRepositoryItem(ro);
        } else {
            throw new RegistryException(ServerResourceBundle.getInstance()
                    .getString("message.duplicateRegistryObjects", new Object[] { pathInfo }));
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
        throw new RegistryException(
                it.cnr.icar.eric.server.common.Utility.getInstance().getStackTraceFromThrowable(e));
    }

    return results;
}

From source file:com.pps.webos.util.AppInfoHelper.java

/**
 * Method should replace values in the appinfo.json with values specified by in the UI.
 * Reference materials:/*from  w  w  w.j  av a  2  s. c  o m*/
 *       org.eclipse.jface.text.FindReplaceDocumentAdapter to replace matches of file with the values of the domain table
 http://dev.eclipse.org/newslists/news.eclipse.platform/msg74246.html
 http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/filebuffers/package-summary.html
 * @param projectName
 * @param appInfo
 */
public void replaceAppInfoAttributes(String projectName, AppInfo appInfo) {

    try {
        /* get workspace location, since the directory structure should only contain 1 appinfo.json
         * logic will just look for the the name of the file **/
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IFile file = workspace.getRoot().getProject(projectName).getFile(AppInfoEnum.WEBOS_FILE_APPINFO);

        //%PROJECT_NAME%archive/webos/appinfo.json
        ITextFileBufferManager fileBufferManager = FileBuffers.getTextFileBufferManager();
        IPath location = file.getLocation();
        fileBufferManager.connect(location, LocationKind.NORMALIZE, new NullProgressMonitor());

        ITextFileBuffer textFileBuffer = fileBufferManager.getTextFileBuffer(location, LocationKind.NORMALIZE);
        IDocument document = textFileBuffer.getDocument();

        FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(document);

        // for each element in the enumeration
        // call method name from appInfo with MethodUtils
        PropertyUtilsBean propertyUtilsBean = new PropertyUtilsBean();
        Object tObj = null;
        for (AppInfoEnum appInfoEnum : AppInfoEnum.values()) {
            tObj = propertyUtilsBean.getProperty(appInfo, appInfoEnum.getFieldName());

            IRegion regionFind = findReplaceDocumentAdapter.find(0, appInfoEnum.getReplaceVal(), true, false,
                    true, false);
            IRegion regionReplace = findReplaceDocumentAdapter.replace(String.valueOf(tObj), false);
        }

        // commit replaced changes
        textFileBuffer.commit(new NullProgressMonitor(), true);

        // clean up  
        fileBufferManager.disconnect(location, LocationKind.NORMALIZE, new NullProgressMonitor());

    } catch (NullPointerException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (BadLocationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:org.geotools.feature.xpath.AttributePropertyHandler.java

public Object getProperty(Object o, String propName) {
    Object value = null;//from w  ww .j av a2 s  .  c o  m

    Attribute att = (Attribute) o;

    // the Filter spec says the xpath expresion may or may not
    // start with the Feature name. If it does, it is the self
    // location path
    AttributeDescriptor descriptor = att.getDescriptor();
    String attName;
    if (descriptor == null) {
        attName = att.getType().getName().getLocalPart();
    } else {
        attName = descriptor.getName().getLocalPart();
    }
    if (propName.equals(attName) || propName.startsWith(attName + "/")) {
        return o;
    }

    if (o instanceof ComplexAttribute) {
        ComplexAttribute attribute = (ComplexAttribute) o;
        Name name = Types.typeName(propName);
        Collection<Property> found;
        try {
            found = attribute.getProperties(name);
        } catch (NullPointerException e) {
            e.printStackTrace();
            throw e;
        }
        value = found.size() == 0 ? null : (found.size() == 1 ? found.iterator().next() : found);

        // FIXME HACK: this is due to the Filter subsystem not dealing with
        // PropertyHandler returning attribute, hence can't, for example,
        // compare
        // an Attribute with a Literal
        /*
        if (value instanceof Attribute && !(value instanceof ComplexAttribute)) {
        value = ((Attribute) value).get();
        }
        */
    }

    if (value == null && descriptor != null) {
        if ("id".equals(propName)) {
            value = att.getIdentifier();
        } else {
            String[] scopedAttName = propName.split(":");
            attName = scopedAttName[scopedAttName.length - 1];

            Map attributes = (Map) att.getUserData().get(Attributes.class);
            if (attributes != null) {
                for (Iterator it = attributes.entrySet().iterator(); it.hasNext();) {
                    Map.Entry entry = (Entry) it.next();
                    Name key = (Name) entry.getKey();
                    if (attName.equals(key.getLocalPart())) {
                        value = entry.getValue();
                        break;
                    }
                }
            }
        }
    }
    return value;
}

From source file:org.telscenter.sail.webapp.presentation.web.controllers.author.project.PostProjectController.java

/**
 * @see org.springframework.web.servlet.mvc.AbstractController#handleRequestInternal(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *///  ww  w  .  j  a v a2 s  . co  m
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    User user = ControllerUtil.getSignedInUser();
    try {
        String projectId = request.getParameter(PROJECT_ID_PARAM);
        String encodedOtmlString = request.getParameter(OTML_CONTENT_PARAM);
        String otmlString = URLDecoder.decode(encodedOtmlString, "UTF-8");

        Project project = projectService.getById(projectId);
        Curnit curnit = project.getCurnit();
        if (curnit instanceof RooloOtmlModuleImpl) {
            ((RooloOtmlModuleImpl) project.getCurnit()).getElo().getContent().setBytes(otmlString.getBytes());
        } else if (curnit instanceof OtmlModuleImpl) {
            ((OtmlModuleImpl) project.getCurnit()).setOtml(otmlString.getBytes());
            moduleService.updateCurnit(project.getCurnit());
        }
        projectService.updateProject(project, user);
    } catch (NullPointerException e) {
        response.setStatus(HttpStatus.SC_BAD_REQUEST);
    } catch (NotAuthorizedException e) {
        e.printStackTrace();
        return new ModelAndView(new RedirectView("/webapp/accessdenied.html"));
    }
    return null;
}

From source file:org.geefive.salesforce.soqleditor.SObjectDataLoader.java

public void executeObjectSearch() throws Exception {
    HttpClient restClient = new HttpClient();
    restClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
    restClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000);

    String restfulURLTarget = sfdcOauth.getServerURL() + sfdcOauth.getSobjectURI();
    GetMethod method = null;//from www.  j av  a  2s  . c om
    try {
        method = new GetMethod(restfulURLTarget);
        method.setRequestHeader("Authorization", "OAuth " + sfdcOauth.getSecureID());

        int httpResponseCode = restClient.executeMethod(method);
        System.out.println("HTTP_RESPONSE_CODE [" + httpResponseCode + "]");
        if (httpResponseCode == HttpStatus.SC_OK) {
            JSONObject response = new JSONObject(
                    new JSONTokener(new InputStreamReader(method.getResponseBodyAsStream())));
            //            JSONArray resultArray = response.getJSONArray("sobjects");
            //            JSONObject inner = null;
            //            inner = resultArray.getJSONObject(0);

            //            Iterator keys = inner.keys();
            //            HashMap columnNames = new HashMap();
            //            while(keys.hasNext()){
            //               String column = (String)keys.next();
            //               if(!column.equalsIgnoreCase("attributes")){
            //                  columnNames.put(column, "");
            //               }
            //            }
            JSONArray results = response.getJSONArray("sobjects");
            reference.setMaxValue(results.length());
            String objectName = null;
            for (int objID = 0; objID < results.length(); objID++) {
                try {
                    if (results.getJSONObject(objID).getString("searchable").equals("true")) {
                        objectName = results.getJSONObject(objID).getString("name");
                        //                        if(objectName.equals("userchild__c")){
                        sObjects.add(parseObjectDetails(new SObjectItem(objectName)));
                        //                        }
                        reference.updateProgressBar(objectName, objID);
                        if (objectName.endsWith("__c")) {
                            reference.incrementCustomObject();
                        } else {
                            reference.incrementStandardObject();
                        }
                    } //end if-else
                } catch (NullPointerException ex) {
                    ex.printStackTrace();
                }
            } //end for
        } //end success
    } finally {
        method.releaseConnection();
    }
    //      return sObjects;
}

From source file:com.karthikb351.vitinfo2.fragment.LoggingInFragment.java

private void loginToServer(String campus, String registerNumber, String dateOfBirth, String mobileNumber) {

    NetworkController networkController = NetworkController.getInstance(getActivity(), campus, registerNumber,
            dateOfBirth, mobileNumber);/*from www. ja v  a 2s.  co m*/

    final ResultListener resultListener = new ResultListener() {
        @Override
        public void onSuccess() {
            startActivity(new Intent(thisActivity, MainActivity.class));
        }

        @Override
        public void onFailure(Status status) {
            try {
                Toast.makeText(thisActivity, status.getMessage(), Toast.LENGTH_SHORT).show();
                getFragmentManager().popBackStack();
            } catch (NullPointerException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onProgress() {
            try {
                thisActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (progress < 6)
                            message.setText(messageList[progress++]);
                    }
                });
            } catch (NullPointerException e) {
                e.printStackTrace();
            }

        }
    };

    RequestConfig requestConfig = new RequestConfig(new ResultListener() {
        @Override
        public void onSuccess() {
            try {
                ((MainApplication) thisActivity.getApplication()).getDataHolderInstance()
                        .refreshData(thisActivity, resultListener);
            } catch (NullPointerException ignore) {
            }
        }

        @Override
        public void onFailure(Status status) {

            resultListener.onFailure(status);
        }

        @Override
        public void onProgress() {
            try {
                thisActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                    }
                });
            } catch (NullPointerException e) {
                e.printStackTrace();
            }
        }
    });
    requestConfig.addRequest(RequestConfig.REQUEST_SYSTEM);
    requestConfig.addRequest(RequestConfig.REQUEST_REFRESH);
    requestConfig.addRequest(RequestConfig.REQUEST_GRADES);
    requestConfig.addRequest(RequestConfig.REQUEST_TOKEN);

    networkController.dispatch(requestConfig);
}

From source file:se.leap.bitmaskclient.Provider.java

protected boolean hasEIP() {
    try {//from  w w  w  .  j  a v  a  2 s.c  o m
        JSONArray services = definition.getJSONArray(API_TERM_SERVICES); // returns ["openvpn"]
        for (int i = 0; i < API_EIP_TYPES.length + 1; i++) {
            try {
                // Walk the EIP types array looking for matches in provider's service definitions
                if (Arrays.asList(API_EIP_TYPES).contains(services.getString(i)))
                    return true;
            } catch (NullPointerException e) {
                e.printStackTrace();
                return false;
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                return false;
            }
        }
    } catch (Exception e) {
        // TODO: handle exception
    }
    return false;
}