Example usage for java.lang NoSuchFieldException toString

List of usage examples for java.lang NoSuchFieldException toString

Introduction

In this page you can find the example usage for java.lang NoSuchFieldException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:nc.noumea.mairie.annuairev2.saisie.viewmodel.ContainsSimpleListModel.java

public ContainsSimpleListModel(List<T> data, Class<T> clazz, String property) {
    super(data);//from  w w  w.  jav  a  2s .  co m
    this.clazz = clazz;
    this.property = property;

    try {
        this.field = clazz.getDeclaredField(property);
    } catch (NoSuchFieldException e) {
        LOGGER.error(e.toString(), e);
        try {
            this.field = clazz.getSuperclass().getDeclaredField(property);
        } catch (NoSuchFieldException e1) {
            LOGGER.error(e1.toString(), e1);
        }
    }

    field.setAccessible(true);
}

From source file:com.krayzk9s.imgurholo.activities.ImgurHoloActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    apiCall = new ApiCall();
    apiCall.setSettings(settings);/*from ww  w  . j  a  v  a  2s . c  o m*/
    theme = settings.getString("theme", MainActivity.HOLO_LIGHT);
    if (theme.equals(MainActivity.HOLO_LIGHT))
        setTheme(R.style.AppTheme);
    else
        setTheme(R.style.AppThemeDark);
    super.onCreate(savedInstanceState);
    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (NoSuchFieldException e) {
        // Ignore
        Log.e("Error!", e.toString());
    } catch (IllegalAccessException e) {
        // Ignore
        Log.e("Error!", e.toString());
    }

    if (Integer
            .parseInt(settings.getString(getString(R.string.icon_size), getString(R.string.onetwenty))) < 120) { //getting rid of 90 because it may crash the app for large screens
        SharedPreferences.Editor editor = settings.edit();
        editor.putString(getString(R.string.icon_size), getString(R.string.onetwenty));
        editor.commit();
    }
    setContentView(R.layout.activity_other);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }
}

From source file:org.powertac.samplebroker.core.MessageDispatcher.java

private boolean validateId(Object thing) {
    try {// w  ww .ja  v  a2  s.c o m
        Field idField = thing.getClass().getDeclaredField("id");
        idField.setAccessible(true);
        long value = idField.getLong(thing);
        if (IdGenerator.getPrefix() != IdGenerator.extractPrefix(value)) {
            log.error("Invalid id value " + value + " in message " + thing.toString());
            return false;
        }
    } catch (NoSuchFieldException e) {
        // no id field, OK to send
        return true;
    } catch (SecurityException e) {
        // Should not happen
        log.error("Exception accessing id field: " + e.toString());
    } catch (IllegalArgumentException e) {
        // Should not happen
        log.error("Exception reading id field: " + e.toString());
    } catch (IllegalAccessException e) {
        // Should not happen
        log.error("Exception reading id field: " + e.toString());
    }
    return true;
}

From source file:org.dcm4che2.tool.dcm2dcm.Dcm2Dcm.java

/**
 * Recodes the images from the source transfer syntax, as read from the src
 * file, to the specified destination syntax.
 *//* ww  w  .j  a v  a  2 s  .  co  m*/
public void recodeImages(File src, File dest) throws IOException {
    ImageReader reader = new DicomImageReaderSpi().createReaderInstance();
    ImageWriter writer = new DicomImageWriterSpi().createWriterInstance();

    DicomStreamMetaData writeMeta = (DicomStreamMetaData) writer.getDefaultStreamMetadata(null);

    DicomObject ds;
    int frames;

    FileImageOutputStream output = null;

    try {
        FileImageInputStream input = new FileImageInputStream(src);

        try {
            reader.setInput(input);
            if (dest.exists())
                dest.delete();
            output = new FileImageOutputStream(dest);
            writer.setOutput(output);
            DicomStreamMetaData streamMeta = (DicomStreamMetaData) reader.getStreamMetadata();
            ds = streamMeta.getDicomObject();

            DicomObject newDs = new BasicDicomObject();
            ds.copyTo(newDs);
            writeMeta.setDicomObject(newDs);
            frames = ds.getInt(Tag.NumberOfFrames, 1);
            newDs.putString(Tag.TransferSyntaxUID, VR.UI, destinationSyntax.uid());
            newDs.putString(Tag.ImplementationClassUID, VR.UI, Implementation.classUID());
            newDs.putString(Tag.ImplementationVersionName, VR.SH, Implementation.versionName());
            if (overwriteObject != null) {
                overwriteObject.copyTo(newDs);
            }
        } finally {
            reader.dispose();
        }
        writer.prepareWriteSequence(writeMeta);
        for (int i = 0; i < frames; i++) {
            FileInputStream inputStream = new FileInputStream(src);
            try {
                WritableRaster r = (WritableRaster) readRaster(inputStream, i);

                ColorModel cm = ColorModelFactory.createColorModel(ds);
                BufferedImage bi = new BufferedImage(cm, r, false, null);
                IIOImage iioimage = new IIOImage(bi, null, null);
                writer.writeToSequence(iioimage, null);
            } catch (NoSuchFieldException ex) {
                System.err.println(ex.toString());
            } catch (IllegalAccessException ex) {
                System.err.println(ex.toString());
            } finally {
                inputStream.close();
            }
        }
        writer.endWriteSequence();
    } finally {
        if (output != null) {
            output.close();
        }
    }
}

From source file:ti.modules.titanium.ui.widget.TiUIDrawerLayout.java

private void setDrawMargin(Integer width) {
    try {//from   ww w  .  j  a  v  a  2  s . c  o  m
        Field mDragger = layout.getClass().getDeclaredField("mLeftDragger");
        mDragger.setAccessible(true);
        ViewDragHelper draggerObj = (ViewDragHelper) mDragger.get(layout);
        Field mEdgeSize = draggerObj.getClass().getDeclaredField("mEdgeSize");
        mEdgeSize.setAccessible(true);
        mEdgeSize.setInt(draggerObj, width);
    } catch (NoSuchFieldException e) {
        Log.e(TAG, e.toString());
    } catch (IllegalAccessException e) {
        Log.e(TAG, e.toString());
    }
}

From source file:com.streamsets.datacollector.creation.PipelineBeanCreator.java

@SuppressWarnings("unchecked")
private PipelineConfigBean createPipelineConfigs(PipelineConfiguration pipelineConf, List<Issue> errors,
        Map<String, Object> runtimeParameters) {
    PipelineConfigBean pipelineConfigBean = new PipelineConfigBean();
    StageConfiguration stageConf = getPipelineConfAsStageConf(pipelineConf);
    if (ConfigInjector.get().createConfigBeans(pipelineConfigBean, "", new ConfigInjector.StageInjectorContext(
            PIPELINE_DEFINITION, stageConf, runtimeParameters, errors))) {

        // To support parameters in Pipeline Configuration inject "parameters" (constants) field first
        Config parametersConfigConf = stageConf.getConfig(PARAMETERS);
        ConfigDefinition parametersConfigDef = PIPELINE_DEFINITION.getConfigDefinitionsMap().get(PARAMETERS);
        if (parametersConfigConf != null) {
            try {
                ConfigInjector.get().injectConfigValue(pipelineConfigBean,
                        PipelineConfigBean.class.getField(PARAMETERS), parametersConfigConf.getValue(),
                        parametersConfigDef, new ConfigInjector.StageInjectorContext(PIPELINE_DEFINITION,
                                stageConf, Collections.EMPTY_MAP, errors));
            } catch (NoSuchFieldException ex) {
                IssueCreator issueCreator = IssueCreator.getStage(stageConf.getStageName());
                errors.add(issueCreator.create(CreationError.CREATION_000, "pipeline",
                        parametersConfigDef.getLabel(), ex.toString()));
                pipelineConfigBean.constants = Collections.EMPTY_MAP;
            }//  w w w .j  a va 2 s.c om
        }

        Map<String, Object> resolvedConstants = pipelineConfigBean.constants;

        if (pipelineConfigBean.constants == null) {
            pipelineConfigBean.constants = Collections.emptyMap();
            resolvedConstants = Collections.emptyMap();
        } else {
            // Merge constant and runtime Constants
            if (runtimeParameters != null) {
                for (String key : runtimeParameters.keySet()) {
                    if (resolvedConstants.containsKey(key)) {
                        resolvedConstants.put(key, runtimeParameters.get(key));
                    }
                }
            }
        }

        ConfigInjector.get().injectConfigs(pipelineConfigBean, "", new ConfigInjector.StageInjectorContext(
                PIPELINE_DEFINITION, stageConf, pipelineConfigBean.constants, errors));

        if (runtimeParameters != null) {
            pipelineConfigBean.constants = resolvedConstants;
        }
    }
    return pipelineConfigBean;
}