List of usage examples for java.lang Class getDeclaredField
@CallerSensitive public Field getDeclaredField(String name) throws NoSuchFieldException, SecurityException
From source file:com.jaspersoft.studio.wizards.functions.FunctionsLibraryInformationPage.java
private void setTooltipOnPrivateField(Class<?> targetClazz, String fieldName, String tooltip) { try {/*from w w w . jav a 2s . co m*/ Field containerWidget = targetClazz.getDeclaredField(fieldName); containerWidget.setAccessible(true); Object obj = containerWidget.get(this); if (obj instanceof DialogField) { ((DialogField) obj).getLabelControl(null).setToolTipText(tooltip); } } catch (Exception e) { JaspersoftStudioPlugin.getInstance().logError("Unable to set the tooltip on the label control", e); } }
From source file:com.fujitsu.dc.common.ads.AdsWriteFailureLogWriterTest.java
/** * ??ADS??????./* w ww. j a v a2s . c o m*/ * @param writer writer * @return ? */ private File getAdsWriteFailureLog() { File file = null; try { Class<?> clazz = AbstractAdsWriteFailureLog.class; Field baseDir = clazz.getDeclaredField("baseDir"); baseDir.setAccessible(true); String baseDirV = (String) baseDir.get(writer); clazz = writer.getClass(); Field createdTime = clazz.getDeclaredField("createdTime"); createdTime.setAccessible(true); Long createdTimeV = (Long) createdTime.get(writer); final String fileName = String.format(AbstractAdsWriteFailureLog.LOGNAME_FORMAT_ACTIVE, PIO_VERSION_DUMMY, createdTimeV); file = new File(baseDirV, fileName); } catch (Exception e) { e.printStackTrace(); fail("configuration failed."); } return file; }
From source file:com.fujitsu.dc.common.ads.AdsWriteFailureLogWriterTest.java
/** * ??ADS??????./*from www. j a v a2s. c o m*/ * @param writer writer * @return ? */ private File getRotatedAdsWriteFailureLog() { File file = null; try { Class<?> clazz = AbstractAdsWriteFailureLog.class; Field baseDir = clazz.getDeclaredField("baseDir"); baseDir.setAccessible(true); String baseDirV = (String) baseDir.get(writer); clazz = writer.getClass(); Field createdTime = clazz.getDeclaredField("createdTime"); createdTime.setAccessible(true); Long createdTimeV = (Long) createdTime.get(writer); final String fileName = String.format(AbstractAdsWriteFailureLog.LOGNAME_FORMAT_ROTATE, PIO_VERSION_DUMMY, createdTimeV); file = new File(baseDirV, fileName); } catch (Exception e) { e.printStackTrace(); fail("configuration failed."); } return file; }
From source file:com.fujitsu.dc.common.ads.AdsWriteFailureLogWriterErrorTest.java
/** * ??ADS??????./*from w w w . j av a2 s . com*/ * @param writer writer * @return ? */ private File getAdsWriteFailureLog() { File file = null; try { Class<?> clazz = AbstractAdsWriteFailureLog.class; Field baseDir = clazz.getDeclaredField("baseDir"); baseDir.setAccessible(true); String baseDirV = (String) baseDir.get(writer); clazz = writer.getClass(); Field createdTime = clazz.getDeclaredField("createdTime"); createdTime.setAccessible(true); Long createdTimeV = (Long) createdTime.get(writer); final String fileName = String.format(AbstractAdsWriteFailureLog.LOGNAME_FORMAT_ACTIVE + AbstractAdsWriteFailureLog.ERROR_LOGNAME_SUFFIX, PIO_VERSION_DUMMY, createdTimeV); file = new File(baseDirV, fileName); } catch (Exception e) { e.printStackTrace(); fail("configuration failed."); } return file; }
From source file:com.fujitsu.dc.common.ads.AdsWriteFailureLogWriterErrorTest.java
/** * ??ADS??????./*from w w w . jav a 2 s. c o m*/ * @param writer writer * @return ? */ private File getRotatedAdsWriteFailureLog() { File file = null; try { Class<?> clazz = AbstractAdsWriteFailureLog.class; Field baseDir = clazz.getDeclaredField("baseDir"); baseDir.setAccessible(true); String baseDirV = (String) baseDir.get(writer); clazz = writer.getClass(); Field createdTime = clazz.getDeclaredField("createdTime"); createdTime.setAccessible(true); Long createdTimeV = (Long) createdTime.get(writer); final String fileName = String.format(AbstractAdsWriteFailureLog.LOGNAME_FORMAT_ROTATE + AbstractAdsWriteFailureLog.ERROR_LOGNAME_SUFFIX, PIO_VERSION_DUMMY, createdTimeV); file = new File(baseDirV, fileName); } catch (Exception e) { e.printStackTrace(); fail("configuration failed."); } return file; }
From source file:com.fujitsu.dc.common.ads.AdsWriteFailureLogWriterRestoreTest.java
/** * ??ADS??????./*from ww w . j a va2s . c o m*/ * @param writer writer * @return ? */ private File getAdsWriteFailureLog() { File file = null; try { Class<?> clazz = AbstractAdsWriteFailureLog.class; Field baseDir = clazz.getDeclaredField("baseDir"); baseDir.setAccessible(true); String baseDirV = (String) baseDir.get(writer); clazz = writer.getClass(); Field createdTime = clazz.getDeclaredField("createdTime"); createdTime.setAccessible(true); Long createdTimeV = (Long) createdTime.get(writer); final String fileName = String.format(AbstractAdsWriteFailureLog.LOGNAME_FORMAT_ACTIVE + AbstractAdsWriteFailureLog.RETRY_LOGNAME_SUFFIX, PIO_VERSION_DUMMY, createdTimeV); file = new File(baseDirV, fileName); } catch (Exception e) { e.printStackTrace(); fail("configuration failed."); } return file; }
From source file:com.fujitsu.dc.common.ads.AdsWriteFailureLogWriterRestoreTest.java
/** * ??ADS??????./* www .j a v a2 s . c om*/ * @param writer writer * @return ? */ private File getRotatedAdsWriteFailureLog() { File file = null; try { Class<?> clazz = AbstractAdsWriteFailureLog.class; Field baseDir = clazz.getDeclaredField("baseDir"); baseDir.setAccessible(true); String baseDirV = (String) baseDir.get(writer); clazz = writer.getClass(); Field createdTime = clazz.getDeclaredField("createdTime"); createdTime.setAccessible(true); Long createdTimeV = (Long) createdTime.get(writer); final String fileName = String.format(AbstractAdsWriteFailureLog.LOGNAME_FORMAT_ROTATE + AbstractAdsWriteFailureLog.RETRY_LOGNAME_SUFFIX, PIO_VERSION_DUMMY, createdTimeV); file = new File(baseDirV, fileName); } catch (Exception e) { e.printStackTrace(); fail("configuration failed."); } return file; }
From source file:com.canappi.connector.yp.yhere.SettingsView.java
public void viewDidLoad() { Bundle extras = getIntent().getExtras(); if (extras != null) { Set<String> keys = extras.keySet(); for (Iterator<String> iter = keys.iterator(); iter.hasNext();) { String key = iter.next(); Class c = SearchView.class; try { Field f = c.getDeclaredField(key); Object extra = extras.get(key); String value = extra.toString(); f.set(this, extras.getString(value)); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace();//from w w w .j a v a 2 s.co m } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } else { } settingsViewIds = new HashMap(); settingsViewValues = new HashMap(); isUserDefault = true; if (isUserDefault) { searchlocEditText.setText(retrieveFromUserDefaultsFor("searchloc"), TextView.BufferType.EDITABLE); } String updateZipButtonText = "Update"; String updateZipButtonPressedText = ""; updateZipButton = (Button) findViewById(R.id.updateZipButton); updateZipButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click updateDefaults(v); } }); didSelectViewController(); }
From source file:io.teak.sdk.Amazon.java
public void init(Context context) { skuDetailsRequestMap = new HashMap<>(); skuPriceMap = new HashMap<>(); try {//from w w w .j a v a2 s .com Class<?> purchasingListenerClass = Class.forName("com.amazon.device.iap.PurchasingListener"); InvocationHandler handler = new PurchasingListenerInvocationHandler(); Object proxy = Proxy.newProxyInstance(purchasingListenerClass.getClassLoader(), new Class[] { purchasingListenerClass }, handler); Class<?> purchasingServiceClass = Class.forName("com.amazon.device.iap.PurchasingService"); Method m = purchasingServiceClass.getMethod("registerListener", Context.class, purchasingListenerClass); m.invoke(null, context, proxy); if (Teak.isDebug) { Field sandbox = purchasingServiceClass.getDeclaredField("IS_SANDBOX_MODE"); Log.d(LOG_TAG, "Amazon In-App Purchasing 2.0 registered."); Log.d(LOG_TAG, " Sandbox Mode: " + sandbox.getBoolean(null)); } } catch (Exception e) { Log.e(LOG_TAG, "Reflection error: " + Log.getStackTraceString(e)); Teak.sdkRaven.reportException(e); } }
From source file:com.expressui.core.util.BeanPropertyType.java
private boolean initFieldAnnotations(Class containerType) { boolean foundProperty = false; Field field;//from w w w .ja v a 2s .com try { field = containerType.getDeclaredField(id); foundProperty = true; Annotation[] fieldAnnotations = field.getAnnotations(); Collections.addAll(annotations, fieldAnnotations); } catch (NoSuchFieldException e) { // no need to get annotations if field doesn't exist } return foundProperty; }