Example usage for java.lang ClassCastException printStackTrace

List of usage examples for java.lang ClassCastException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:org.apache.axis.transport.jms.SimpleJMSListener.java

/**
 * This method is called asynchronously whenever a message arrives.
 * @param message//from ww  w . j a  v  a2s .c  o m
 */
public void onMessage(javax.jms.Message message) {
    try {
        // pass off the message to a worker as a BytesMessage
        SimpleJMSWorker worker = new SimpleJMSWorker(this, (BytesMessage) message);

        // do we allow multi-threaded workers?
        if (doThreads) {
            Thread t = new Thread(worker);
            t.start();
        } else {
            worker.run();
        }
    } catch (ClassCastException cce) {
        log.error(Messages.getMessage("exception00"), cce);
        cce.printStackTrace();
        return;
    }
}

From source file:com.ssn.listener.SSNFacebookAlbumSelectionListener.java

@Override
public void valueChanged(TreeSelectionEvent event) {
    DefaultMutableTreeNode node = treeHelper.getTreeNode(event.getPath());

    if (this.form.getHiveTree() != null) {
        this.form.getHiveTree().clearSelection();
    }//from w  w w.j a v  a 2 s  . c o m
    if (this.form.getInstagramTree() != null) {
        this.form.getInstagramTree().clearSelection();
    }

    if (node.isLeaf()) {
        this.form.setCursor(new Cursor(Cursor.WAIT_CURSOR));
        SSNAlbumNode fnode = null;
        try {
            if (((SSNIconData) node.getUserObject()).getObject() instanceof SSNAlbumNode)
                fnode = (SSNAlbumNode) ((SSNIconData) node.getUserObject()).getObject();
        } catch (ClassCastException ee) {
            ee.printStackTrace();
            this.form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
        String facebookDirPath = SSNHelper.getFacebookPhotosDirPath();
        if (fnode != null)
            fileTree.m_display.setText(facebookDirPath + File.separator + fnode);

        SSNIconData iconData = (SSNIconData) node.getUserObject();
        SSNAlbumNode albumNode = (SSNAlbumNode) iconData.getObject();

        MediaOperations mediaOperations = facebook.mediaOperations();

        List<Photo> listPhoto, completePhotoList = new ArrayList<Photo>();
        do {
            PagingParameters pagingParameters = new PagingParameters(100, completePhotoList.size(), null,
                    Calendar.getInstance().getTimeInMillis());
            listPhoto = mediaOperations.getPhotos(albumNode.getAlbum().getId(), pagingParameters);
            completePhotoList.addAll(listPhoto);

        } while (listPhoto.size() > 0);

        createComponents(this.form, completePhotoList, albumNode);
    }

}

From source file:com.example.kharlamov.cheesetask.CheeseListFragment.java

@Nullable
@Override/*from  ww w  . ja v  a2  s  .  c o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setRetainInstance(true);
    loaderId = getArguments().getInt(KEY_FRAGMENT_NUMBER);
    View view = inflater.inflate(R.layout.fragment_cheese_list, container, false);
    mRvCheeses = (RecyclerView) view.findViewById(R.id.recyclerview);
    if (savedInstanceState != null) {
        try {
            mCheeseList = (ArrayList<Cheese>) savedInstanceState.get(KEY_CHEESES);
        } catch (ClassCastException e) {
            e.printStackTrace();
        }
    }
    setupRecyclerView(mRvCheeses);
    return view;
}

From source file:org.mariotaku.twidere.fragment.ActivityHostFragment.java

@SuppressWarnings({ "deprecation", "unchecked" })
@Override// ww  w . j av  a  2 s  .co m
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Intent intent = new Intent(getActivity(), getActivityClass());
    final Bundle args = getArguments();
    if (args != null) {
        intent.putExtras(args);
    }

    final Window w = getLocalActivityManager().startActivity(ACTIVITY_TAG, intent);
    mAttachedActivity = null;
    final Context context = w.getContext();
    if (context instanceof Activity) {
        try {
            mAttachedActivity = (A) context;
            if (context instanceof FragmentCallback) {
                ((FragmentCallback<A>) context).setCallbackFragment(this);
            }
        } catch (final ClassCastException e) {
            // This should't happen.
            e.printStackTrace();
        }
    }
    final View wd = w != null ? w.getDecorView() : null;

    if (wd != null) {
        final ViewParent parent = wd.getParent();
        if (parent != null) {
            final ViewGroup v = (ViewGroup) parent;
            v.removeView(wd);
        }

        wd.setVisibility(View.VISIBLE);
        wd.setFocusableInTouchMode(true);
        if (wd instanceof ViewGroup) {
            ((ViewGroup) wd).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
        }
    }
    return wd;
}

From source file:org.sapia.soto.state.control.If.java

/**
 * @see org.sapia.soto.state.helpers.CompositeStep#doExecute(Result)
 *//*from  w  w w. j  a va2 s .  c  o  m*/
protected boolean doExecute(Result st) {
    Map scopes = st.getContext().getScopes();
    ScopeMap map = new ScopeMap(scopes, _scopes);
    Object evaled = null;

    try {
        evaled = _expr.evaluate(map);

        Boolean b = (Boolean) evaled;

        return b.booleanValue();
    } catch (ClassCastException e) {
        st.error("'if' must evaluate to a Boolean, not a " + evaled);

        return false;
    } catch (Exception e) {
        e.printStackTrace();
        st.error("Could not evaluate: '" + _expr.getExpression() + "'", e);

        return false;
    }
}

From source file:com.seraphim.chips.ChipsEditText.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    try {/*  w  ww  . j av  a2 s. c  o  m*/
        ChipEntry entry = (ChipEntry) parent.getItemAtPosition(position);
        setText("");
        mItemClickListener.clicked(entry);
    } catch (ClassCastException e) {
        e.printStackTrace();
    }
}

From source file:org.onosproject.drivers.fujitsu.FujitsuVoltControllerConfig.java

/**
 * Forms XML string to change controller information.
 *
 * @param cfg a hierarchical configuration
 * @param target the type of configuration
 * @param netconfOperation operation type
 * @param controllers list of controllers
 * @return XML string//from  www  .  j a  va2s  .  c  om
 */
private String createVoltControllersConfig(HierarchicalConfiguration cfg, String target,
        String netconfOperation, List<ControllerInfo> controllers) {
    XMLConfiguration editcfg = null;

    cfg.setProperty(EDIT_CONFIG_TG, target);
    cfg.setProperty(EDIT_CONFIG_DO, netconfOperation);

    List<ConfigurationNode> newControllers = new ArrayList<>();
    for (ControllerInfo ci : controllers) {
        XMLConfiguration controller = new XMLConfiguration();
        controller.setRoot(new HierarchicalConfiguration.Node(OF_CONTROLLER));
        controller.setProperty(OFCONFIG_ID, ci.annotations().value(OFCONFIG_ID));
        controller.setProperty(CONTROLLER_INFO_ID, ci.annotations().value(OFCONFIG_ID));
        controller.setProperty(CONTROLLER_INFO_IP, ci.ip());
        controller.setProperty(CONTROLLER_INFO_PORT, ci.port());
        controller.setProperty(CONTROLLER_INFO_PROTOCOL, ci.type());
        newControllers.add(controller.getRootNode());
    }
    cfg.addNodes(VOLT_EDITCONFIG, newControllers);

    try {
        editcfg = (XMLConfiguration) cfg;
    } catch (ClassCastException e) {
        e.printStackTrace();
    }
    StringWriter stringWriter = new StringWriter();
    try {
        editcfg.save(stringWriter);
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
    String s = stringWriter.toString();
    String fromStr = buildStartTag(TARGET, false) + target + buildEndTag(TARGET, false);
    String toStr = buildStartTag(TARGET, false) + buildEmptyTag(target, false) + buildEndTag(TARGET, false);
    s = s.replace(fromStr, toStr);
    return s;
}

From source file:edu.hm.muse.controller.Logincontroller.java

@RequestMapping(value = "/adminlogin.secu", method = RequestMethod.POST)
public ModelAndView doAdminLogin(@RequestParam(value = "mpwd", required = false) String mpwd,
        @RequestParam(value = "csrftoken", required = false) String csrfParam, HttpServletResponse response,
        HttpSession session) {//from  www . ja va 2  s. c om
    if (null == mpwd || mpwd.isEmpty()) {
        throw new SuperFatalAndReallyAnnoyingException(
                "I can not process, because the requestparam mpwd is empty or null or something like this");
    }

    String sql = "select count (*) from M_ADMIN where mpwd = ?";

    try {
        String digest = calculateSHA256(new ByteArrayInputStream(mpwd.getBytes("UTF8")));

        int res = 0;

        res = jdbcTemplate.queryForInt(sql, new Object[] { digest }, new int[] { Types.VARCHAR });

        Integer csrfTokenSess = (Integer) session.getAttribute("csrftoken");
        if (res != 0 && csrfParam != null && !csrfParam.isEmpty() && csrfTokenSess != null) {
            Integer csrfParamToken = Integer.parseInt(csrfParam);
            if (csrfParamToken.intValue() == csrfTokenSess.intValue()) {
                SecureRandom random = new SecureRandom();
                int token = random.nextInt();
                session.setAttribute("user", "admin");
                session.setAttribute("login", true);
                session.setAttribute("admintoken", token);
                response.addCookie(new Cookie("admintoken", String.valueOf(token)));
                session.removeAttribute("csrftoken");
                return new ModelAndView("redirect:adminintern.secu");
            }
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    } catch (ClassCastException ccastEx) {
        ccastEx.printStackTrace();
    } catch (NumberFormatException nfoEx) {
        nfoEx.printStackTrace();
    } catch (DataAccessException e) {
        throw new SuperFatalAndReallyAnnoyingException(
                String.format("Sorry but %sis a bad grammar or has following problem %s", sql, e.getMessage()));
    }
    ModelAndView mv = returnToAdminLogin(session);
    return mv;
}

From source file:com.reliqartz.firsttipcalc.gui.RatioDialog.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    try {/*  w  w w.  j av a  2 s . c  o m*/
        mActivity = (SplitRatioChangeListener) activity;
    } catch (ClassCastException e) {
        Log.e(TAG, "Calling activity must implement SplitRatioChangeListener!!");
        e.printStackTrace();
    }
}

From source file:org.opendatakit.common.android.data.RawRow.java

/**
 * Return the data stored in the cursor at the given cellIndex column position
 * as null OR whatever data type it is./*from   ww  w. jav  a2s  .co m*/
 * <p>
 * This does not actually convert data types from one type to the other.
 * Instead, it safely preserves null values and returns boxed data values.
 * If you specify ArrayList or HashMap, it JSON deserializes the value into
 * one of those.
 *
 * @param cellIndex
 *          cellIndex of data or metadata column (0..nCol-1)
 * @param clazz
 * @return
 */
@SuppressWarnings("unchecked")
public final <T> T getRawDataType(int cellIndex, Class<T> clazz) {
    // If you add additional return types here be sure to modify the javadoc.
    try {
        String value = getRawDataOrMetadataByIndex(cellIndex);
        if (value == null) {
            return null;
        }
        if (clazz == Long.class) {
            Long l = Long.parseLong(value);
            return (T) (Long) l;
        } else if (clazz == Integer.class) {
            Integer l = Integer.parseInt(value);
            return (T) (Integer) l;
        } else if (clazz == Double.class) {
            Double d = Double.parseDouble(value);
            return (T) (Double) d;
        } else if (clazz == String.class) {
            return (T) (String) value;
        } else if (clazz == Boolean.class) {
            // booleans are stored as integer 1 or 0 in user tables.
            return (T) (Boolean) Boolean.valueOf(!value.equals("0"));
        } else if (clazz == ArrayList.class) {
            // json deserialization of an array
            return (T) ODKFileUtils.mapper.readValue(value, ArrayList.class);
        } else if (clazz == HashMap.class) {
            // json deserialization of an object
            return (T) ODKFileUtils.mapper.readValue(value, HashMap.class);
        } else if (clazz == TreeMap.class) {
            // json deserialization of an object
            return (T) ODKFileUtils.mapper.readValue(value, TreeMap.class);
        } else {
            throw new IllegalStateException("Unexpected data type in SQLite table");
        }
    } catch (ClassCastException e) {
        e.printStackTrace();
        throw new IllegalStateException(
                "Unexpected data type conversion failure " + e.toString() + " in SQLite table ");
    } catch (JsonParseException e) {
        e.printStackTrace();
        throw new IllegalStateException(
                "Unexpected data type conversion failure " + e.toString() + " on SQLite table");
    } catch (JsonMappingException e) {
        e.printStackTrace();
        throw new IllegalStateException(
                "Unexpected data type conversion failure " + e.toString() + " on SQLite table");
    } catch (IOException e) {
        e.printStackTrace();
        throw new IllegalStateException(
                "Unexpected data type conversion failure " + e.toString() + " on SQLite table");
    }
}