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.card.loop.xyz.dao.LearningElementDAO.java

public boolean updateList(LearningElement object) throws UnknownHostException {
    boolean ok = false;
    try {//from w w w. j a v a2s. c om
        mongoOps.insert(object);
        ok = true;
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    return ok;
}

From source file:io.amira.zen.core.ZenFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    try {//from  ww  w. j a va2  s.c  om
        //long p = System.nanoTime();
        //ZenLog.l("CREATING VIEW "+((Object) this).getClass().getCanonicalName());
        //ZenLog.l(this.layoutId);
        if (savedInstanceState != null) {
            //ZenLog.l("RESUMING FRAGMENT");
            isResumed = true;
            isNew = false;
            if (this.layoutId == 0) {
                //ZenLog.l("RELOADING LAYOUT ON RESUME");
                this.layoutId = savedInstanceState.getInt("layoutid");
                current = (HashMap<String, Object>) savedInstanceState.getSerializable("current");
            }
        } else {
            isResumed = false;
            isNew = true;
        }
        //ZenLog.l(this.layoutId);
        rootView = inflater.inflate(layoutId, container, false);
        _res = new HashMap<String, Integer>();
        //long d = System.nanoTime();
        //ZenLog.l("TIME to inflate view "+(d-p));
    } catch (NullPointerException e) {
        e.printStackTrace();
        return null;
    }

    //: load parameters from Zen
    parameters = ZenApplication.navigation().getParameters();

    //: always launch preLoad method
    preLoad();
    //: if Fragment is resumed, we load helpers now (otherwise we'll wait for animations)
    if (!isNew) {
        //ZenLog.l("FRAGMENT NOT NEW");
        getElements();
        buildElements();
    }
    return rootView;
}

From source file:jgraspcheckstyle.indentation.IndentationCheck.java

/**
 * {@inheritDoc}//from   w w w.  j  a va  2  s.  c o m
 */
public void visitToken(DetailAST aAST) {
    if ((aAST.getType() == TokenTypes.VARIABLE_DEF) && ScopeUtils.isLocalVariableDef(aAST)) {
        // we have handler only for members
        return;
    }

    final ExpressionHandler handler = mHandlerFactory.getHandler(this, aAST,
            (ExpressionHandler) mHandlers.peek());
    mHandlers.push(handler);
    try {
        handler.checkIndentation();
    } catch (NullPointerException npe) {
        npe.printStackTrace();
    }
}

From source file:org.ecocean.servlet.EncounterAddImage.java

public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String context = "context0";
    context = ServletUtilities.getContext(request);
    Shepherd myShepherd = new Shepherd(context);
    myShepherd.setAction("EncounterAddImage.class");

    //setup data dir
    String rootWebappPath = getServletContext().getRealPath("/");
    File webappsDir = new File(rootWebappPath).getParentFile();
    File shepherdDataDir = new File(webappsDir, CommonConfiguration.getDataDirectoryName(context));
    if (!shepherdDataDir.exists()) {
        shepherdDataDir.mkdirs();//from  ww  w  .ja  va2  s . co  m
    }
    File encountersDir = new File(shepherdDataDir.getAbsolutePath() + "/encounters");
    if (!encountersDir.exists()) {
        encountersDir.mkdirs();
    }

    //set up for response
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    boolean locked = false;

    String fileName = "None";
    String encounterNumber = "None";
    String fullPathFilename = "";

    try {
        MultipartParser mp = new MultipartParser(request,
                (CommonConfiguration.getMaxMediaSizeInMegabytes(context) * 1048576));
        Part part;
        while ((part = mp.readNextPart()) != null) {
            String name = part.getName();
            if (part.isParam()) {

                // it's a parameter part
                ParamPart paramPart = (ParamPart) part;
                String value = paramPart.getStringValue();

                //determine which variable to assign the param to
                if (name.equals("number")) {
                    encounterNumber = value;
                }

            }

            ////TODO this will need to be generified for offsite storage prob via SinglePhotoVideo? as in EncounterForm?
            if (part.isFile()) {
                FilePart filePart = (FilePart) part;
                fileName = ServletUtilities.cleanFileName(filePart.getFileName());
                if (fileName != null) {
                    //fileName = Util.generateUUID() + "-orig." + FilenameUtils.getExtension(fileName);
                    //File thisSharkDir = new File(encountersDir.getAbsolutePath() +"/"+ Encounter.subdir(encounterNumber));
                    File thisSharkDir = new File(Encounter.dir(shepherdDataDir, encounterNumber));
                    if (!thisSharkDir.exists()) {
                        thisSharkDir.mkdirs();
                    }
                    File finalFile = new File(thisSharkDir, fileName);
                    fullPathFilename = finalFile.getCanonicalPath();
                    long file_size = filePart.writeTo(finalFile);

                }
            }
        }

        //File thisEncounterDir = new File(encountersDir, Encounter.subdir(encounterNumber));
        File thisEncounterDir = new File(Encounter.dir(shepherdDataDir, encounterNumber));

        myShepherd.beginDBTransaction();
        if (myShepherd.isEncounter(encounterNumber)) {

            int positionInList = 10000;

            Encounter enc = myShepherd.getEncounter(encounterNumber);
            try {

                SinglePhotoVideo newSPV = new SinglePhotoVideo(encounterNumber, (new File(fullPathFilename)));
                enc.addSinglePhotoVideo(newSPV);
                ///// NOT YET -->  enc.refreshAssetFormats(myShepherd);
                //enc.refreshAssetFormats(context, ServletUtilities.dataDir(context, rootWebappPath), newSPV, false);
                enc.addComments("<p><em>" + request.getRemoteUser() + " on " + (new java.util.Date()).toString()
                        + "</em><br>" + "Submitted new encounter image graphic: " + fileName + ".</p>");
                positionInList = enc.getAdditionalImageNames().size();
            } catch (Exception le) {
                locked = true;
                myShepherd.rollbackDBTransaction();
                myShepherd.closeDBTransaction();
            }

            if (!locked) {
                myShepherd.commitDBTransaction();
                myShepherd.closeDBTransaction();
                out.println(ServletUtilities.getHeader(request));
                out.println(
                        "<strong>Success!</strong> I have successfully uploaded your new encounter image file.");
                if (positionInList == 1) {
                    out.println(
                            "<p><i>You should also reset the thumbnail image for this encounter. You can do so by <a href=\"http://"
                                    + CommonConfiguration.getURLLocation(request)
                                    + "/resetThumbnail.jsp?number=" + encounterNumber
                                    + "\">clicking here.</a></i></p>");
                }
                out.println("<p><a href=\"http://" + CommonConfiguration.getURLLocation(request)
                        + "/encounters/encounter.jsp?number=" + encounterNumber + "\">Return to encounter "
                        + encounterNumber + "</a></p>\n");
                out.println(ServletUtilities.getFooter(context));
                String message = "An additional image file has been uploaded for encounter #" + encounterNumber
                        + ".";
                ServletUtilities.informInterestedParties(request, encounterNumber, message, context);
            } else {

                out.println(ServletUtilities.getHeader(request));
                out.println(
                        "<strong>Failure!</strong> This encounter is currently being modified by another user. Please wait a few seconds before trying to add this image again.");
                out.println("<p><a href=\"http://" + CommonConfiguration.getURLLocation(request)
                        + "/encounters/encounter.jsp?number=" + encounterNumber + "\">Return to encounter "
                        + encounterNumber + "</a></p>\n");
                out.println(ServletUtilities.getFooter(context));

            }
        } else {
            myShepherd.rollbackDBTransaction();
            myShepherd.closeDBTransaction();
            out.println(ServletUtilities.getHeader(request));
            out.println(
                    "<strong>Error:</strong> I was unable to upload your image file. I cannot find the encounter that you intended it for in the database.");
            out.println(ServletUtilities.getFooter(context));

        }
    } catch (IOException lEx) {
        lEx.printStackTrace();
        out.println(ServletUtilities.getHeader(request));
        out.println(
                "<strong>Error:</strong> I was unable to upload your image file. Please contact the web master about this message.");
        out.println(ServletUtilities.getFooter(context));
    } catch (NullPointerException npe) {
        npe.printStackTrace();
        out.println(ServletUtilities.getHeader(request));
        out.println("<strong>Error:</strong> I was unable to upload an image as no file was specified.");
        out.println(ServletUtilities.getFooter(context));
    }
    out.close();
}

From source file:timer.com.maydaysdk.MayDayMessageChatFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View viewInfo = inflater.inflate(R.layout.messagechat, container, false);

    // Initialize UI
    ImageButton imageButtonChatSend = (ImageButton) viewInfo.findViewById(R.id.imageButton_send);
    ImageButton imageButtonChatClose = (ImageButton) viewInfo.findViewById(R.id.imageButton_chat_close);
    mTextViewAgentName = (TextView) viewInfo.findViewById(R.id.textView_chat_agent_name);
    mLinearLayoutMessage = (LinearLayout) viewInfo.findViewById(R.id.linearLayout_message);
    mImageButtonChatResize = (ImageButton) viewInfo.findViewById(R.id.imageButton_chat_resize);
    mEditTextChatMessage = (EditText) viewInfo.findViewById(R.id.editText_chat_message);
    mAlertDialog = new AlertDialog.Builder(getActivity()).create();

    imageButtonChatClose.setOnClickListener(this);
    mImageButtonChatResize.setOnClickListener(this);
    imageButtonChatSend.setOnClickListener(this);
    mEditTextChatMessage.setOnClickListener(this);

    mListFragment = (MayDayMessageListFragment) getChildFragmentManager().findFragmentById(R.id.message_list);

    // Get RCClient device list
    try {//  w  w  w  .  j av  a 2 s.  c  o m
        mDevice = RCClient.listDevices().get(0);
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    // Get device resolution width and height
    Point size = new Point();
    getActivity().getWindowManager().getDefaultDisplay().getSize(size);
    final int windowHeight = size.y;

    // Message chat resize from top to bottom
    mLinearLayoutMessage.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {

            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mLinearLayoutMessage
                    .getLayoutParams();
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                break;
            case MotionEvent.ACTION_MOVE:
                int y_cord = (int) event.getRawY();

                if (y_cord > windowHeight) {
                    y_cord = windowHeight;
                }

                layoutParams.topMargin = y_cord - MARGIN_TOP;
                mLinearLayoutMessage.setLayoutParams(layoutParams);
                break;
            default:
                break;
            }
            return true;
        }
    });

    Bundle bundle = getArguments();
    String agentName = "", domainAddress = "";
    // Get the event data from the fragment, which pass agent name and domain address
    if (bundle.getString(MayDayConstant.AGENT_NAME) != null) {
        agentName = bundle.getString(MayDayConstant.AGENT_NAME);
    }
    if (bundle.getString(MayDayConstant.DOMAIN_ADDRESS) != null) {
        domainAddress = bundle.getString(MayDayConstant.DOMAIN_ADDRESS);
    }
    initializeChat(agentName, domainAddress);

    return viewInfo;
}

From source file:freed.cam.ui.videoprofileeditor.VideoProfileEditorFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    button_profile = (Button) view.findViewById(id.button_Profile);
    button_profile.setOnClickListener(profileClickListner);
    editText_profilename = (EditText) view.findViewById(id.editText_ProfileName);
    editText_audiobitrate = (EditText) view.findViewById(id.editText_audioBitrate);
    editText_audiosamplerate = (EditText) view.findViewById(id.editText_audioSampleRate);
    editText_videobitrate = (EditText) view.findViewById(id.editText_videoBitrate);
    editText_videoframerate = (EditText) view.findViewById(id.editText_videoframerate);
    editText_maxrecordtime = (EditText) view.findViewById(id.editText_recordtime);
    button_save = (Button) view.findViewById(id.button_Save_profile);
    switch_Audio = (Switch) view.findViewById(id.switchAudio);
    button_recordMode = (Button) view.findViewById(id.button_recordMode);
    button_recordMode.setOnClickListener(recordModeClickListner);
    button_videoCodec = (Button) view.findViewById(id.button_videoCodec);
    button_videoCodec.setOnClickListener(onVideoCodecClickListner);
    button_audioCodec = (Button) view.findViewById(id.button_audioCodec);
    button_audioCodec.setOnClickListener(onAudioCodecClickListner);

    button_save.setOnClickListener(onSavebuttonClick);
    button_delete = (Button) view.findViewById(id.button_delete_profile);
    button_delete.setOnClickListener(ondeleteButtonClick);
    videoMediaProfiles = new HashMap<>();

    appSettingsManager = new AppSettingsManager(
            PreferenceManager.getDefaultSharedPreferences(getActivity().getBaseContext()), getResources());
    appSettingsManager.getCamApi();/* w ww  . j  ava 2  s .com*/
    videoMediaProfiles = appSettingsManager.getMediaProfiles();
    try {
        setMediaProfile(
                videoMediaProfiles.get(appSettingsManager.getApiString(AppSettingsManager.VIDEOPROFILE)));
    } catch (NullPointerException ex) {
        ex.printStackTrace();
    }
}

From source file:com.business.rushour.businessapp.RiderMainActivity.java

/**
 * Display image from a path to ImageView
 *//* w  ww . j  av  a 2 s  .c om*/
private void previewCapturedImage() {
    try {
        // hide video preview

        Intent cropIntent = new Intent("com.android.camera.action.CROP");
        //indicate image type and Uri
        cropIntent.setDataAndType(fileUri, "image/*");
        //set crop properties
        cropIntent.putExtra("crop", "true");
        //indicate aspect of desired crop
        cropIntent.putExtra("aspectX", 1);
        cropIntent.putExtra("aspectY", 1);
        //indicate output X and Y
        cropIntent.putExtra("outputX", 256);
        cropIntent.putExtra("outputY", 256);
        //retrieve data on return
        cropIntent.putExtra("return-data", true);
        //start the activity - we handle returning in onActivityResult
        startActivityForResult(cropIntent, PIC_CROP);

    } catch (NullPointerException e) {
        e.printStackTrace();
    }
}

From source file:jp.co.cyberagent.android.gpuimage.sample.activity.ActivityGallery.java

@SuppressLint("NewApi")
@Override//w w w. j a  v a  2s .c  om
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);

    //Get height, width
    mWindowSize = new Point();
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
        getWindowManager().getDefaultDisplay().getSize(mWindowSize);
    } else {
        Display display = getWindowManager().getDefaultDisplay();
        mWindowSize.x = display.getWidth();
        mWindowSize.y = display.getHeight();
    }
    Log.v(DEBUG_TAG, "Window Size  = " + mWindowSize.x + "  = " + mWindowSize.y);
    //((SeekBar) findViewById(R.id.seekBar)).setOnSeekBarChangeListener(this);
    //findViewById(R.id.button_choose_filter).setOnClickListener(this);
    //findViewById(R.id.button_save).setOnClickListener(this);

    mGPUImageView = (GPUImageView) findViewById(R.id.gpuimage);

    //Drawable water = getResources().getDrawable(R.drawable.water_over_coral_reef_303786);
    //BitmapDrawable = getResources().getDrawable(R.drawable.water_over_coral_reef_303786);
    Bitmap water = BitmapFactory.decodeResource(getResources(), R.drawable.water_over_coral_reef_303786);
    mGPUImageView.setImage(water);

    /*Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
    photoPickerIntent.setType("image/*");
    startActivityForResult(photoPickerIntent, REQUEST_PICK_IMAGE);*/

    switchFilterTo(new WaterRippleEffect(mWindowSize.x, mWindowSize.y));

    mGPUImageView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            int action = MotionEventCompat.getActionMasked(event);

            switch (action) {
            case (MotionEvent.ACTION_DOWN):
                Log.d(DEBUG_TAG, "Action was DOWN X = " + event.getX() + " | Y =" + event.getY());
                //if(mFilter.getClass() == WaterRippleEffect.class) {
                try {
                    float points[] = convertFromAndroiSpaceToOpenGL(event.getX(), event.getY());
                    ((WaterRippleEffect) mFilter).setTouches(points[0], points[1]);
                } catch (NullPointerException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                //}

                return true;
            case (MotionEvent.ACTION_MOVE):
                Log.d(DEBUG_TAG, "Action was MOVE");
                return true;
            case (MotionEvent.ACTION_UP):
                Log.d(DEBUG_TAG, "Action was UP");
                return true;
            case (MotionEvent.ACTION_CANCEL):
                Log.d(DEBUG_TAG, "Action was CANCEL");
                return true;
            case (MotionEvent.ACTION_OUTSIDE):
                Log.d(DEBUG_TAG, "Movement occurred outside bounds " + "of current screen element");
                return true;
            default:
                return true;
            }
        }
    });

}

From source file:io.github.jeremgamer.editor.panels.Actions.java

public Actions(final JFrame frame, final ActionPanel ap) {
    this.frame = frame;

    this.setBorder(BorderFactory.createTitledBorder(""));
    JButton add = null;/*from  www  . j  a v  a2s  .  c  om*/
    try {
        add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    add.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                JOptionPane jop = new JOptionPane();
                @SuppressWarnings("static-access")
                String name = jop.showInputDialog(null, "Nommez l'action :", "Crer une action",
                        JOptionPane.QUESTION_MESSAGE);

                if (name != null) {
                    for (int i = 0; i < data.getSize(); i++) {
                        if (data.get(i).equals(name)) {
                            name += "1";
                        }
                    }
                    data.addElement(name);
                    new ActionSave(name);
                    OtherPanel.updateLists();
                    ButtonPanel.updateLists();
                    ActionPanel.updateLists();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    });

    JButton remove = null;
    try {
        remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    remove.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                if (actionList.getSelectedValue() != null) {
                    File file = new File("projects/" + Editor.getProjectName() + "/actions/"
                            + actionList.getSelectedValue() + ".rbd");
                    JOptionPane jop = new JOptionPane();
                    @SuppressWarnings("static-access")
                    int option = jop.showConfirmDialog(null,
                            "tes-vous sr de vouloir supprimer cette action?", "Avertissement",
                            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

                    if (option == JOptionPane.OK_OPTION) {
                        if (actionList.getSelectedValue().equals(ap.getFileName())) {
                            ap.setFileName("");
                        }
                        ap.hide();
                        file.delete();
                        data.remove(actionList.getSelectedIndex());
                        OtherPanel.updateLists();
                        ButtonPanel.updateLists();
                    }
                }
            } catch (NullPointerException npe) {
                npe.printStackTrace();
            }

        }

    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS));
    buttons.add(add);
    buttons.add(remove);

    updateList();
    actionList.addMouseListener(new MouseAdapter() {
        @SuppressWarnings("unchecked")
        public void mouseClicked(MouseEvent evt) {
            JList<String> list = (JList<String>) evt.getSource();
            if (evt.getClickCount() == 2) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    ap.show();
                    ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            ap.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            ap.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        ap.hide();
                        list.clearSelection();
                    }
                }
            } else if (evt.getClickCount() == 3) {
                int index = list.locationToIndex(evt.getPoint());
                if (isOpen == false) {
                    ap.show();
                    ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                            + list.getModel().getElementAt(index) + ".rbd"));
                    previousSelection = list.getSelectedValue();
                    isOpen = true;
                } else {
                    try {
                        if (previousSelection.equals(list.getModel().getElementAt(index))) {
                            ap.hide();
                            previousSelection = list.getSelectedValue();
                            list.clearSelection();
                            isOpen = false;
                        } else {
                            ap.hideThenShow();
                            previousSelection = list.getSelectedValue();
                            ap.load(new File("projects/" + Editor.getProjectName() + "/actions/"
                                    + list.getModel().getElementAt(index) + ".rbd"));
                        }
                    } catch (NullPointerException npe) {
                        ap.hide();
                        list.clearSelection();
                    }
                }
            }
        }
    });
    JScrollPane listPane = new JScrollPane(actionList);
    listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    this.add(buttons);
    this.add(listPane);
    OtherPanel.updateLists();
}

From source file:org.pentaho.reporting.engine.classic.extensions.datasources.mondrian.DenormalizedMDXTableModel.java

public Object getValueAt(final int rowIndex, final int columnIndex) {
    if (columnIndex >= columnNames.size()) {
        throw new IndexOutOfBoundsException();
    }//w  ww .  j  av a  2s. c  om

    if (isMeasureColumn(columnIndex)) {
        final int[] cellKey = computeCellKey(rowIndex);
        try {
            final Cell cell = resultSet.getCell(cellKey);
            if (cell.isNull()) {
                return null;
            }
            return cell.getValue();
        } catch (NullPointerException pe) {
            pe.printStackTrace();
        }
    }

    final int[] cellKey = computeCellKey(rowIndex);
    Member candidateMember = getCandidateMembers(columnIndex, cellKey);
    if (candidateMember != null) {
        return candidateMember.getName();
    }
    return null;
}