Example usage for java.lang NoSuchMethodException printStackTrace

List of usage examples for java.lang NoSuchMethodException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.achep.header2actionbar.HeaderFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Activity activity = getActivity();
    assert activity != null;
    mFrameLayout = new FrameLayout(activity);

    mHeader = onCreateHeaderView(inflater, mFrameLayout);
    mHeaderHeader = mHeader.findViewById(android.R.id.title);
    mHeaderBackground = mHeader.findViewById(android.R.id.background);
    assert mHeader.getLayoutParams() != null;
    mHeaderHeight = mHeader.getLayoutParams().height;

    mFakeHeader = new Space(activity);
    mFakeHeader.setLayoutParams(new ListView.LayoutParams(0, mHeaderHeight));

    View content = onCreateContentView(inflater, mFrameLayout);
    if (content instanceof ListView) {
        isListViewEmpty = true;//from   w  w w .  j av a  2s.c  o  m

        final ListView listView = (ListView) content;
        listView.addHeaderView(mFakeHeader);
        onSetAdapter();
        listView.setOnScrollListener(new AbsListView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView absListView, int scrollState) {
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScrollStateChanged(absListView, scrollState);
                }
            }

            @Override
            public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount);
                }

                isListViewEmpty = listView.getAdapter() == null;
                if (isListViewEmpty) {
                    scrollHeaderTo(0);
                } else {
                    final View child = absListView.getChildAt(0);
                    assert child != null;
                    scrollHeaderTo(child == mFakeHeader ? child.getTop() : -mHeaderHeight);
                    //                        Log.v("header height",String.format("mHeaderHeight:%s",mHeaderHeight));
                }
            }
        });
    } else if (content instanceof GridView) {
        isListViewEmpty = true;

        final GridView grid = (GridView) content;
        //isListViewEmpty = grid.getAdapter() == null;
        //            grid.addHeaderView(mFakeHeader);

        // Merge fake header view and content view.
        final LinearLayout view = new LinearLayout(activity);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        view.setOrientation(LinearLayout.VERTICAL);
        view.addView(mFakeHeader);
        view.addView(grid);

        grid.setOnScrollListener(new AbsListView.OnScrollListener() {

            private ListViewScrollTracker mScrollTracker;;

            @Override
            public void onScrollStateChanged(AbsListView absListView, int scrollState) {
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScrollStateChanged(absListView, scrollState);
                }
            }

            public int getGridScrollY(GridView grid) {

                Method privateStringMethod = null;
                Integer scrollOffset = null;
                Integer scrollExtent = null;
                Integer scrollRange = null;
                try {
                    privateStringMethod = GridView.class.getDeclaredMethod("computeVerticalScrollOffset", null);
                    privateStringMethod.setAccessible(true);
                    scrollOffset = (Integer) privateStringMethod.invoke(grid, null);

                    privateStringMethod = GridView.class.getDeclaredMethod("computeVerticalScrollExtent", null);
                    privateStringMethod.setAccessible(true);
                    scrollExtent = (Integer) privateStringMethod.invoke(grid, null);

                    privateStringMethod = GridView.class.getDeclaredMethod("computeVerticalScrollRange", null);
                    privateStringMethod.setAccessible(true);
                    scrollRange = (Integer) privateStringMethod.invoke(grid, null);
                } catch (NoSuchMethodException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalArgumentException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return scrollRange;//scrollExtent*scrollOffset;  

            }

            @Override
            public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                if (mScrollTracker == null)
                    mScrollTracker = new ListViewScrollTracker(absListView);
                mScrollPosition = mScrollTracker.calculateIncrementalOffset(firstVisibleItem, visibleItemCount);
                Log.v("header", "scrollPosition:" + mScrollPosition);
                if (mOnScrollListener != null) {
                    mOnScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount);
                }

                final View child = absListView.getChildAt(0);
                if (child != null) {
                    int gridScrollY = mScrollPosition;//getGridScrollY((GridView) absListView);
                    scrollHeaderTo(-gridScrollY);

                    //change the size of the fake header on scrolling                        
                    int currentHeight = mFakeHeader.getLayoutParams().height;
                    Integer fakeHeaderHeight = (int) (mHeaderHeight - (gridScrollY * 2));
                    mFakeHeader.setLayoutParams(new android.widget.LinearLayout.LayoutParams(
                            mFakeHeader.getWidth(), fakeHeaderHeight));
                    //                  setViewTranslationY(mFrameLayout, -1*(gridScrollY));
                } else
                    scrollHeaderTo(0);
            }
        });
        content = view;
    } else {

        // Merge fake header view and content view.
        final LinearLayout view = new LinearLayout(activity);
        view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        view.setOrientation(LinearLayout.VERTICAL);
        view.addView(mFakeHeader);
        view.addView(content);

        // Put merged content to ScrollView
        final NotifyingScrollView scrollView = new NotifyingScrollView(activity);
        scrollView.addView(view);
        scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() {
            @Override
            public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
                scrollHeaderTo(-t);
            }
        });
        content = scrollView;
    }

    mFrameLayout.addView(content);
    mFrameLayout.addView(mHeader);

    // Content overlay view always shows at the top of content.
    if ((mContentOverlay = onCreateContentOverlayView(inflater, mFrameLayout)) != null) {
        mFrameLayout.addView(mContentOverlay, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
    }

    // Post initial scroll
    mFrameLayout.post(new Runnable() {
        @Override
        public void run() {
            scrollHeaderTo(0, true);
        }
    });

    return mFrameLayout;
}

From source file:fr.inria.atlanmod.neoemf.graph.blueprints.datastore.BlueprintsPersistenceBackendFactory.java

@Override
public BlueprintsPersistenceBackend createPersistentBackend(File file, Map<?, ?> options)
        throws InvalidDataStoreException {
    BlueprintsPersistenceBackend graphDB = null;
    PropertiesConfiguration neoConfig = null;
    PropertiesConfiguration configuration = null;
    try {//from  www  .  java2s  .  c  o m
        // Try to load previous configurations
        Path path = Paths.get(file.getAbsolutePath()).resolve(CONFIG_FILE);
        try {
            configuration = new PropertiesConfiguration(path.toFile());
        } catch (ConfigurationException e) {
            throw new InvalidDataStoreException(e);
        }
        // Initialize value if the config file has just been created
        if (!configuration.containsKey(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE)) {
            configuration.setProperty(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE,
                    BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE_DEFAULT);
        } else if (options.containsKey(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE)) {
            // The file already existed, check that the issued options
            // are not conflictive
            String savedGraphType = configuration
                    .getString(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE);
            String issuedGraphType = options.get(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE)
                    .toString();
            if (!savedGraphType.equals(issuedGraphType)) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, "Unable to create graph as type " + issuedGraphType
                        + ", expected graph type was " + savedGraphType + ")");
                throw new InvalidDataStoreException("Unable to create graph as type " + issuedGraphType
                        + ", expected graph type was " + savedGraphType + ")");
            }
        }

        // Copy the options to the configuration
        for (Entry<?, ?> e : options.entrySet()) {
            configuration.setProperty(e.getKey().toString(), e.getValue().toString());
        }

        // Check we have a valid graph type, it is needed to get the
        // graph name
        String graphType = configuration.getString(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE);
        if (graphType == null) {
            throw new InvalidDataStoreException("Graph type is undefined for " + file.getAbsolutePath());
        }

        String[] segments = graphType.split("\\.");
        if (segments.length >= 2) {
            String graphName = segments[segments.length - 2];
            String upperCaseGraphName = Character.toUpperCase(graphName.charAt(0)) + graphName.substring(1);
            String configClassQualifiedName = MessageFormat.format(
                    "fr.inria.atlanmod.neoemf.graph.blueprints.{0}.config.Blueprints{1}Config", graphName,
                    upperCaseGraphName);
            try {
                ClassLoader classLoader = BlueprintsPersistenceBackendFactory.class.getClassLoader();
                Class<?> configClass = classLoader.loadClass(configClassQualifiedName);
                Field configClassInstanceField = configClass.getField("eINSTANCE");
                AbstractBlueprintsConfig configClassInstance = (AbstractBlueprintsConfig) configClassInstanceField
                        .get(configClass);
                Method configMethod = configClass.getMethod("putDefaultConfiguration", Configuration.class,
                        File.class);
                configMethod.invoke(configClassInstance, configuration, file);
                Method setGlobalSettingsMethod = configClass.getMethod("setGlobalSettings");
                setGlobalSettingsMethod.invoke(configClassInstance);
            } catch (ClassNotFoundException e1) {
                NeoLogger.log(NeoLogger.SEVERITY_WARNING,
                        "Unable to find the configuration class " + configClassQualifiedName);
                e1.printStackTrace();
            } catch (NoSuchFieldException e2) {
                NeoLogger.log(NeoLogger.SEVERITY_WARNING,
                        MessageFormat.format(
                                "Unable to find the static field eINSTANCE in class Blueprints{0}Config",
                                upperCaseGraphName));
                e2.printStackTrace();
            } catch (NoSuchMethodException e3) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR,
                        MessageFormat.format(
                                "Unable to find configuration methods in class Blueprints{0}Config",
                                upperCaseGraphName));
                e3.printStackTrace();
            } catch (InvocationTargetException e4) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, MessageFormat.format(
                        "An error occured during the exection of a configuration method", upperCaseGraphName));
                e4.printStackTrace();
            } catch (IllegalAccessException e5) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, MessageFormat.format(
                        "An error occured during the exection of a configuration method", upperCaseGraphName));
                e5.printStackTrace();
            }
        } else {
            NeoLogger.log(NeoLogger.SEVERITY_WARNING, "Unable to compute graph type name from " + graphType);
        }

        Graph baseGraph = null;
        try {
            baseGraph = GraphFactory.open(configuration);
        } catch (RuntimeException e) {
            throw new InvalidDataStoreException(e);
        }
        if (baseGraph instanceof KeyIndexableGraph) {
            graphDB = new BlueprintsPersistenceBackend((KeyIndexableGraph) baseGraph);
        } else {
            NeoLogger.log(NeoLogger.SEVERITY_ERROR,
                    "Graph type " + file.getAbsolutePath() + " does not support Key Indices");
            throw new InvalidDataStoreException(
                    "Graph type " + file.getAbsolutePath() + " does not support Key Indices");
        }
        // Save the neoconfig file
        Path neoConfigPath = Paths.get(file.getAbsolutePath()).resolve(NEO_CONFIG_FILE);
        try {
            neoConfig = new PropertiesConfiguration(neoConfigPath.toFile());
        } catch (ConfigurationException e) {
            throw new InvalidDataStoreException(e);
        }
        if (!neoConfig.containsKey(BACKEND_PROPERTY)) {
            neoConfig.setProperty(BACKEND_PROPERTY, BLUEPRINTS_BACKEND);
        }
    } finally {
        if (configuration != null) {
            try {
                configuration.save();
            } catch (ConfigurationException e) {
                // Unable to save configuration, supposedly it's a minor error,
                // so we log it without rising an exception
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, e);
            }
        }
        if (neoConfig != null) {
            try {
                neoConfig.save();
            } catch (ConfigurationException e) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, e);
            }
        }
    }
    return graphDB;
}

From source file:com.example.percentlayout.view.PercentLayoutHelper.java

private void supportMinOrMaxDimesion(int widthHint, int heightHint, View view, PercentLayoutInfo info) {
    Log.d(TAG, "supportMinOrMaxDimesion");
    try {//from  ww w.j a  v  a 2 s .  c om
        Class clazz = view.getClass();
        invokeMethod("setMaxWidth", widthHint, heightHint, view, clazz, info.maxWidthPercent);
        invokeMethod("setMaxHeight", widthHint, heightHint, view, clazz, info.maxHeightPercent);
        invokeMethod("setMinWidth", widthHint, heightHint, view, clazz, info.minWidthPercent);
        invokeMethod("setMinHeight", widthHint, heightHint, view, clazz, info.minHeightPercent);

    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

}

From source file:KSView.PercentLayoutHelper.java

private void supportMinOrMaxDimesion(int widthHint, int heightHint, View view, PercentLayoutInfo info) {
    LogUtil.d(TAG, "supportMinOrMaxDimesion");
    try {/*from w w  w  . j a  v  a2s.  co  m*/
        Class clazz = view.getClass();
        invokeMethod("setMaxWidth", widthHint, heightHint, view, clazz, info.maxWidthPercent);
        invokeMethod("setMaxHeight", widthHint, heightHint, view, clazz, info.maxHeightPercent);
        invokeMethod("setMinWidth", widthHint, heightHint, view, clazz, info.minWidthPercent);
        invokeMethod("setMinHeight", widthHint, heightHint, view, clazz, info.minHeightPercent);

    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

}

From source file:uk.org.catnip.eddie.parser.BaseSAXParser.java

/** 
 * Look for a method to deal with the state of the current element. 
 * Creates a new state object.//ww  w.  ja v  a 2  s  .c  om
 * Deals with inline xml content
 * If the element method fails to push the state, we do it for them. 
 * We default to not expecting content
 * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
 */
public void startElement(final String uri, final String localName, final String qName, final Attributes atts)
        throws SAXException {

    State state = new State(uri, localName, qName, atts, getCurrentState());

    if (log.isTraceEnabled()) {
        log.trace("startElement:" + localName + " (" + state.getElement() + ")");
    }

    if (in_content > 0 && "escaped".equals(state.getMode())) {
        state.setMode("xml");
    }
    if (in_content > 0 && "xml".equals(state.getMode())) {
        handle_data(state, Sanitize.clean_html_start(state), false);
        state.content = true;
        push(state);
        return;
    }

    try {
        Class[] argTypes = { State.class };
        Object[] values = { state };
        int stacksize = stack.size();
        this.getClass().getMethod("startElement_" + state.getElement(), argTypes).invoke(this, values);
        if (stack.size() == stacksize) {
            //naughty handler didn't push state
            push(state);
        }
    } catch (NoSuchMethodException e) {
        log.trace("unhandled element " + state.getElement());
        state.setExpectingText(true);
        push(state);
        // } catch (InvocationTargetException e) {
        // throw e.getCause();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.example.android.wifidirect.WiFiDirectActivity.java

/**
 * DeviceListListener?//from   w  ww  . ja va2 s . c om
 */

private void removeAndDeleteGroup() {
    try {
        Method deletePersistentGroup = WifiP2pManager.class.getMethod("deletePersistentGroup");
        for (int netid = 0; netid < 32; netid++) {
            deletePersistentGroup.invoke(manager, channel, netid, null);
        }
    } catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.kuali.kra.budget.calculator.QueryList.java

/** returns the field value in the base bean for the specified field.
 * @param fieldName fieldname whose value has to be got.
 * @param baseBean Bean containing the field.
 * @return value of the field./*from ww  w  .  jav a  2  s  .  c o m*/
 */
private Object getFieldValue(String fieldName, Object baseBean) {
    Field field = null;
    Method method = null;
    Class dataClass = baseBean.getClass();
    Object value = null;

    try {
        field = dataClass.getDeclaredField(fieldName);
        if (!field.isAccessible()) {
            throw new NoSuchFieldException();
        }
    } catch (NoSuchFieldException noSuchFieldException) {
        try {
            String methodName = "get" + (fieldName.charAt(0) + "").toUpperCase() + fieldName.substring(1);
            method = dataClass.getMethod(methodName, null);
        } catch (NoSuchMethodException noSuchMethodException) {
            noSuchMethodException.printStackTrace();
        }
    }

    try {
        if (field != null && field.isAccessible()) {
            value = field.get(baseBean);
        } else {
            value = method.invoke(baseBean, null);
        }
    } catch (IllegalAccessException illegalAccessException) {
        illegalAccessException.printStackTrace();
    } catch (InvocationTargetException invocationTargetException) {
        invocationTargetException.printStackTrace();
    }
    return value;
}

From source file:org.kuali.kra.budget.calculator.QueryList.java

/** calculates the sum of the field in this QueryList.
 * @param fieldName field of bean whose sum has to be calculated.
 * @param arg argument for the getter method of field if it takes any argumnt,
 * else can be null.//from   w  w w .  j  ava2  s .  c o  m
 * @param value value for the argument, else can be null.
 * @return returns sum.
 */
public double sum(String fieldName, Class arg, Object value) {
    if (size() == 0) {
        return 0;
    }

    Object current;
    Field field = null;
    Method method = null;
    Class dataClass = get(0).getClass();
    double sum = 0;

    try {
        field = dataClass.getDeclaredField(fieldName);

        Class fieldClass = field.getType();
        if (!(fieldClass.equals(Integer.class) || fieldClass.equals(Long.class)
                || fieldClass.equals(Double.class) || fieldClass.equals(Float.class)
                || fieldClass.equals(BigDecimal.class) || fieldClass.equals(BigInteger.class)
                || fieldClass.equals(BudgetDecimal.class) || fieldClass.equals(KualiDecimal.class)
                || fieldClass.equals(int.class) || fieldClass.equals(long.class)
                || fieldClass.equals(float.class) || fieldClass.equals(double.class))) {
            throw new UnsupportedOperationException("Data Type not numeric");
        }

        if (!field.isAccessible()) {
            throw new NoSuchFieldException();
        }
    } catch (NoSuchFieldException noSuchFieldException) {
        try {
            String methodName = "get" + (fieldName.charAt(0) + "").toUpperCase() + fieldName.substring(1);
            if (arg != null) {
                Class args[] = { arg };
                method = dataClass.getMethod(methodName, args);
            } else {
                method = dataClass.getMethod(methodName, null);
            }
        } catch (NoSuchMethodException noSuchMethodException) {
            noSuchMethodException.printStackTrace();
        }
    }

    for (int index = 0; index < size(); index++) {
        current = get(index);

        try {
            if (field != null && field.isAccessible()) {
                sum = sum + Double.parseDouble(((Comparable) field.get(current)).toString());
            } else {
                Comparable dataValue;
                if (value != null) {
                    Object values[] = { value };
                    dataValue = (Comparable) method.invoke(current, values);
                } else {
                    dataValue = (Comparable) method.invoke(current, null);
                }
                if (dataValue != null) {
                    sum += Double.parseDouble(dataValue.toString());
                }

            }
        } catch (IllegalAccessException illegalAccessException) {
            illegalAccessException.printStackTrace();
        } catch (InvocationTargetException invocationTargetException) {
            invocationTargetException.printStackTrace();
        }
    }
    return sum;
}

From source file:org.malaguna.cmdit.service.reflection.ReflectionUtils.java

public boolean compareAndUpdateAttribute(Object oldObj, Object newObj, String atributo, boolean update,
        StringBuffer msgBuffer, String msgContext) {
    boolean result = false;

    if (oldObj != null && newObj != null) {
        oldObj = hpu.unproxy(oldObj);/*from   w  ww  . j  a v a  2  s .com*/
        newObj = hpu.unproxy(newObj);

        if (!isHibernateProxy(oldObj) && !isHibernateProxy(newObj)) {
            PropertyDescriptor desc = null;

            try {
                String firstAttribute = null;
                String restAttribute = null;

                int pos = atributo.indexOf(".");
                if (pos >= 0) {
                    firstAttribute = atributo.substring(0, pos);
                    restAttribute = atributo.substring(pos + 1);
                } else {
                    firstAttribute = atributo;
                }

                desc = PropertyUtils.getPropertyDescriptor(oldObj, firstAttribute);

                if (desc != null) {
                    Object oldValue = hpu.unproxy(desc.getReadMethod().invoke(oldObj));
                    Object newValue = hpu.unproxy(desc.getReadMethod().invoke(newObj));

                    if (restAttribute == null && !isHibernateProxy(oldValue) && !isHibernateProxy(newValue)) {
                        String auxChangeMsg = null;

                        result = (oldValue != null) ? compareObjects(desc, oldValue, newValue)
                                : (newValue == null);
                        if (!result) {
                            if (msgBuffer != null) {
                                auxChangeMsg = buildChangeMessage(desc, firstAttribute, oldValue, newValue,
                                        msgContext);
                            }
                            if (update) {
                                updateOldValue(oldObj, desc, oldValue, newValue);
                            }
                        }

                        if (msgBuffer != null)
                            msgBuffer.append(getAppendMsg(auxChangeMsg, msgBuffer));
                    }

                    if (restAttribute != null) {
                        if (Collection.class.isAssignableFrom(desc.getPropertyType())) {
                            Collection<?> oldSetAux = (Collection<?>) oldValue;
                            Collection<?> newSetAux = (Collection<?>) newValue;

                            if (oldValue != null && newValue != null) {
                                Collection<?> intersection = CollectionUtils.intersection(oldSetAux, newSetAux);

                                for (Object obj : intersection) {
                                    RUPredicate rup = new RUPredicate(obj.hashCode());
                                    Object oldElement = CollectionUtils.find(oldSetAux, rup);
                                    Object newElement = CollectionUtils.find(newSetAux, rup);

                                    String context = (msgContext != null) ? msgContext + firstAttribute
                                            : firstAttribute;
                                    context += "([" + oldElement.toString() + "]).";
                                    compareAndUpdateAttribute(oldElement, newElement, restAttribute, update,
                                            msgBuffer, context);
                                }
                            }
                        } else {
                            compareAndUpdateAttribute(oldValue, newValue, restAttribute, update, msgBuffer);
                        }
                    }
                }
            } catch (NoSuchMethodException e) {
                String error = "Error in compareAndUpdateAttribute, class type [%s] has no property [%s]";
                throw new RuntimeException(String.format(error, oldObj.getClass(), atributo), e);
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    return result;
}

From source file:com.flyingcrop.ScreenCaptureFragment.java

private void get_Metrics() {
    final DisplayMetrics metrics = new DisplayMetrics();
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Method mGetRawH = null;//from w  w  w.  java2 s.  c o m
    Method mGetRawW = null;

    try {
        // For JellyBean 4.2 (API 17) and onward
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
            display.getRealMetrics(metrics);

            mWidth = metrics.widthPixels;
            mHeight = metrics.heightPixels;
            screen_width = mWidth;
            screen_height = mHeight;
            mScreenDensity = metrics.densityDpi;
        } else {
            mGetRawH = Display.class.getMethod("getRawHeight");
            mGetRawW = Display.class.getMethod("getRawWidth");

            try {
                mWidth = (Integer) mGetRawW.invoke(display);
                mHeight = (Integer) mGetRawH.invoke(display);
            } catch (IllegalArgumentException 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 e3) {
        e3.printStackTrace();
    }
    Log.d("getMetrics", "Width " + mWidth);
    Log.d("getMetrics", "Height " + mHeight);
    //crop bitmap
    x_inicial = getActivity().getIntent().getFloatExtra("x_inicial", -1);
    y_inicial = getActivity().getIntent().getFloatExtra("y_inicial", -1);
    x_final = getActivity().getIntent().getFloatExtra("x_final", -1);
    y_final = getActivity().getIntent().getFloatExtra("y_final", -1);
    if (y_inicial < 0)
        y_inicial = 0;

    status_bar_height = getStatusBarHeight();

    SharedPreferences settings = getActivity().getSharedPreferences("data", 0);
    int scale = settings.getInt("scale", 1);
    switch (scale) {
    case 0: // low
        mWidth *= 0.25;
        mHeight *= 0.25;
        x_inicial *= 0.25;
        x_final *= 0.25;
        y_inicial *= 0.25;
        y_final *= 0.25;
        status_bar_height *= 0.25;
        break;
    case 1: // medium
        mWidth *= 0.5;
        mHeight *= 0.5;
        x_inicial *= 0.5;
        x_final *= 0.5;
        y_inicial *= 0.5;
        y_final *= 0.5;
        status_bar_height *= 0.5;
        break;
    case 2: //high
        mWidth *= 0.75;
        mHeight *= 0.75;
        x_inicial *= 0.75;
        x_final *= 0.75;
        y_inicial *= 0.75;
        y_final *= 0.75;
        status_bar_height *= 0.75;
        break;

    }
    storage = Environment.getExternalStorageDirectory().getAbsolutePath();
}