Object getClass - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Object getClass method.

This code example shows how to use the following methods:getClass, format, getDateFormatSymbols, toPattern
    } 
 
    public void test_ConstructorLjava_lang_StringLjava_util_Locale() { 
        // Test for method java.text.SimpleDateFormat(java.lang.String, 
        // java.util.Locale) 
        SimpleDateFormat f2 = new SimpleDateFormat("'yyyy' MM yy",
                Locale.GERMAN);
        assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
        assertEquals("Wrong pattern", "'yyyy' MM yy", f2.toPattern());
        assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(
                new DateFormatSymbols(Locale.GERMAN)));
        assertTrue("Doesn't work",
                f2.format(new Date()).getClass() == String.class);
 
        try { 
            new SimpleDateFormat(null, Locale.GERMAN);
            fail("NullPointerException was not thrown.");
        } catch(NullPointerException npe) {
            //expected 
        } 
8
CodeRank
This code example shows how to use the following methods:getContentDescription, getHeight, getId, getLocationOnScreen, getWidth
 
	@SuppressWarnings({ "rawtypes", "unchecked" }) 
	public static Object extractDataFromView(View v) {		
		 
		Map data = new HashMap();
		data.put("class", v.getClass().getName());		
		data.put("description", v.toString());
		CharSequence description = v.getContentDescription();
		data.put("contentDescription", description != null ? description.toString() : null);
		data.put("enabled", v.isEnabled());
		String id = null;
		try { 
			id = InstrumentationBackend.solo.getCurrentActivity()
					.getResources().getResourceEntryName(v.getId());
		} catch (Resources.NotFoundException e) {
			System.out.println("Resource not found for " + v.getId()
					+ ". Moving on."); 
		} 
		data.put("id", id);
 

8
CodeRank
This code example shows how to use the following methods:getActivity, getApplicationContext, getClass
 
	private MoSyncNFCForegroundUtil(Activity activity, NfcAdapter nfc) {
	    this.activity = activity;
	    this.nfc = nfc;
 
	    intent = PendingIntent.getActivity(activity, 0, new Intent(activity, activity.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
 
	    // TODO: NDEF!? 
	    IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
 
//	    try { 
//	        ndef.addDataType("*/*"); 
//	    } catch (MalformedMimeTypeException e) { 
//	        throw new RuntimeException("Unable to speciy */* Mime Type", e); 
//	    } 
 
	    intentFilters = new IntentFilter[] { ndef };
 
	    // TODO: READ FROM NFC.XML OR SMTHG 
	    techLists = new String[][] {

8
CodeRank
This code example shows how to use the following methods:getClass
	 * the local name of the supplied {@link Node}. Supports both {@link Element Elements} 
	 * and {@link Attr Attrs}. 
	 */ 
	private BeanDefinitionDecorator findDecoratorForNode(Node node, ParserContext parserContext) {
		BeanDefinitionDecorator decorator = null;
		String localName = parserContext.getDelegate().getLocalName(node);
		if (node instanceof Element) {
			decorator = this.decorators.get(localName);
		} 
		else if (node instanceof Attr) {
			decorator = this.attributeDecorators.get(localName);
		} 
		else { 
			parserContext.getReaderContext().fatal(
					"Cannot decorate based on Nodes of type [" + node.getClass().getName() + "]", node);
		} 
		if (decorator == null) {
			parserContext.getReaderContext().fatal("Cannot locate BeanDefinitionDecorator for " +
					(node instanceof Element ? "element" : "attribute") + " [" + localName + "]", node);
		} 

8
CodeRank
This code example shows how to use the following methods:getClass, getNextException, getSQLState
 * @author Thomas Risberg 
 * @see java.sql.SQLException#getSQLState() 
 * @see SQLErrorCodeSQLExceptionTranslator 
 */ 
public class SQLStateSQLExceptionTranslator extends AbstractFallbackSQLExceptionTranslator { 
 
	private static final Set<String> BAD_SQL_GRAMMAR_CODES = new HashSet<String>(8); 
 
	private static final Set<String> DATA_INTEGRITY_VIOLATION_CODES = new HashSet<String>(8); 
 
	private static final Set<String> DATA_ACCESS_RESOURCE_FAILURE_CODES = new HashSet<String>(8); 
 
	private static final Set<String> TRANSIENT_DATA_ACCESS_RESOURCE_CODES = new HashSet<String>(8); 
 
	private static final Set<String> CONCURRENCY_FAILURE_CODES = new HashSet<String>(4); 
 
 
	static { 
		BAD_SQL_GRAMMAR_CODES.add("07");	// Dynamic SQL error 
		BAD_SQL_GRAMMAR_CODES.add("21");	// Cardinality violation 

8
CodeRank
This code example shows how to use the following methods:getSystemService, setVolumeControlStream, getClass
	 
	public void disableKeyguard(Activity activity) {
		if (mKeyguardLock != null) {
			mKeyguardLock.disableKeyguard();
		} else { 
			KeyguardManager keyguardManager = (KeyguardManager) activity.getSystemService(Activity.KEYGUARD_SERVICE);
			mKeyguardLock = keyguardManager.newKeyguardLock(KEYGUARD_TAG);
			mKeyguardLock.disableKeyguard();
		} 
	} 
	 
	public void enableKeyguard() { 
		if (mKeyguardLock != null) {
			mKeyguardLock.reenableKeyguard();
		} 
		mKeyguardLock = null;
	} 
 
 
	public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {

7
CodeRank
This code example shows how to use the following methods:getClass
        } 
    } 
 
    @Override 
    protected void onRestoreInstanceState(Parcelable state) {
        if (!state.getClass().equals(SavedState.class)) {
            super.onRestoreInstanceState(state);
            return; 
        } 
        SavedState myState = (SavedState) state;
        super.onRestoreInstanceState(myState.getSuperState());
        mProgress = myState.progress;
        mMax = myState.max;
        notifyChanged(); 
    } 
 
    @Override 
    protected Parcelable onSaveInstanceState() {
        final Parcelable superState = super.onSaveInstanceState();
        if (isPersistent()) {
7
CodeRank
This code example shows how to use the following methods:newWakeLock, getClass
	private final static int WAIT_FOR_PROXIMITY_NEGATIVE = 1;
	private final static int WAKE_UP_IMMEDIATELY = 0;
 
	public WakeLockManager(Context context){
		mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
		mFullLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK
											  | PowerManager.ACQUIRE_CAUSES_WAKEUP
											  | PowerManager.ON_AFTER_RELEASE, LOG_TAG);
		mPartialLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOG_TAG);
 
		// Check if PROXIMITY_SCREEN_OFF_WAKE_LOCK is implemented, not part of public api. 
		try { 
			Method method = mPowerManager.getClass().getDeclaredMethod("getSupportedWakeLockFlags");
			int supportedWakeLockFlags = (Integer) method.invoke(mPowerManager);
			Field field = PowerManager.class.getDeclaredField("PROXIMITY_SCREEN_OFF_WAKE_LOCK");
			int proximityScreenOffWakeLock = (Integer) field.get(null);
			if ((supportedWakeLockFlags & proximityScreenOffWakeLock) != 0x0) {
				mProximityLock = mPowerManager.newWakeLock(proximityScreenOffWakeLock, LOG_TAG);
			} 
		} catch (Exception e){

7
CodeRank
This code example shows how to use the following methods:getClass, format, getDateFormatSymbols, toPattern
    } 
 
    public void test_ConstructorLjava_lang_StringLjava_util_Locale() { 
        // Test for method java.text.SimpleDateFormat(java.lang.String, 
        // java.util.Locale) 
        SimpleDateFormat f2 = new SimpleDateFormat("'yyyy' MM yy",
                Locale.GERMAN);
        assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
        assertEquals("Wrong pattern", "'yyyy' MM yy", f2.toPattern());
        assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(
                new DateFormatSymbols(Locale.GERMAN)));
        assertTrue("Doesn't work",
                f2.format(new Date()).getClass() == String.class);
 
        try { 
            new SimpleDateFormat(null, Locale.GERMAN);
            fail("NullPointerException was not thrown.");
        } catch(NullPointerException npe) {
            //expected 
        } 
8
CodeRank
This code example shows how to use the following methods:getClass, getName
            if (test instanceof TestCase) {
                TestCase testCase = (TestCase) test;
                checkForNewSuite(testCase);
                mSerializer.startTag("", TAG_CASE);
                mSerializer.attribute("", ATTRIBUTE_CLASS, mCurrentSuite);
                mSerializer.attribute("", ATTRIBUTE_NAME, testCase.getName());
 
                mTimeAlreadyWritten = false;
                mTestStartTime = System.currentTimeMillis();
            } 
        } catch (IOException e) {
            Log.e(LOG_TAG, safeMessage(e));
        } 
    } 
 
    private void checkForNewSuite(TestCase testCase) throws IOException {
        String suiteName = testCase.getClass().getName();
        if (mCurrentSuite == null || !mCurrentSuite.equals(suiteName)) {
            if (mCurrentSuite != null) {
                if (mMultiFile) {

7
CodeRank

Related Object getClass Questions & Answers:

getClass Method Overview
Returns the runtime class of this Object.
See Code Examples for other Java 8 Object Methods: