Example usage for java.lang InstantiationException printStackTrace

List of usage examples for java.lang InstantiationException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:corner.orm.tapestry.component.gain.GainPoint.java

/**
 * ?entity//from w w w . ja v a 2 s.c om
 */
private <T> void entityWorkshop() {

    Object entity = null;

    int Size = this.getForegroundLength();

    Class entityClass = null;
    try {
        entityClass = Class.forName(getEntityClass());
    } catch (ClassNotFoundException e1) {
        e1.printStackTrace();
    }

    neatenPersistentEntity(); //??

    Object temp = null; //??

    Iterator FEList = null;

    String epname = null;

    for (int i = 0; i < Size; i++) {

        if (i < this.getPersistentSize()) {
            entity = this.getEntitys().get(i);
        } else {
            try {
                entity = entityClass.newInstance();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }

        FEList = this.getForegroundEntitys().iterator();

        for (int j = 0; j < this.getForegroundEntitys().size(); j++) {

            List foregroundEntity = (List) FEList.next();

            try {
                temp = foregroundEntity.get(i);

                if (temp != null && !temp.equals("")) {

                    epname = this.getEntityPropertys().get(j);

                    if (getPagePersistentId().equals(epname)) { //??id????id
                        epname = getPersistentId();
                    }

                    PropertyUtils.setProperty(entity, epname, temp);
                }

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

        this.getSaveOrUpdateEntitys().add(entity);
    }

    //
    delNullEntity();
}

From source file:com.t2.compassionMeditation.DeviceManagerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mInstance = this;
    sharedPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    //this.sendBroadcast(new Intent(BioFeedbackService.ACTION_SERVICE_START));

    this.setContentView(R.layout.device_manager_activity_layout);

    this.findViewById(R.id.bluetoothSettingsButton).setOnClickListener(this);

    Resources resources = this.getResources();
    AssetManager assetManager = resources.getAssets();
    try {//from w  ww  .j  a v  a 2s  . c o  m
        mSpineManager = SPINEFactory.createSPINEManager("SPINETestApp.properties", resources);
    } catch (InstantiationException e) {
        Log.e(TAG, this.getClass().getSimpleName() + " Exception creating SPINE manager: " + e.toString());
        e.printStackTrace();
    }
    // ... then we need to register a SPINEListener implementation to the SPINE manager instance
    // to receive sensor node data from the Spine server
    // (I register myself since I'm a SPINEListener implementation!)
    mSpineManager.addListener(this);

    // Create a broadcast receiver. Note that this is used ONLY for command messages from the service
    // All data from the service goes through the mail SPINE mechanism (received(Data data)).
    // See public void received(Data data)
    this.mCommandReceiver = new SpineReceiver(this);
    // Set up filter intents so we can receive broadcasts
    IntentFilter filter = new IntentFilter();
    filter.addAction("com.t2.biofeedback.service.status.BROADCAST");
    filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
    filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
    filter.addAction(BioFeedbackService.ACTION_STATUS_BROADCAST);

    this.registerReceiver(this.mCommandReceiver, filter);

    // Tell the bluetooth service to send us a list of bluetooth devices and system status
    // Response comes in public void onStatusReceived(BioFeedbackStatus bfs) STATUS_PAIRED_DEVICES      
    mSpineManager.pollBluetoothDevices();

    //      this.deviceManager = DeviceManager.getInstance(this.getBaseContext(), null);
    this.deviceList = (ListView) this.findViewById(R.id.list);

    this.deviceListAdapter = new ManagerItemAdapter(this, R.layout.manager_item);
    this.deviceList.setAdapter(this.deviceListAdapter);

    this.bluetoothDisabledDialog = new AlertDialog.Builder(this).setMessage("Bluetooth is not enabled.")
            .setOnCancelListener(new OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    finish();
                }
            }).setPositiveButton("Setup Bluetooth", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    startBluetoothSettings();
                }
            }).create();

    try {
        PackageManager packageManager = this.getPackageManager();
        PackageInfo info = packageManager.getPackageInfo(this.getPackageName(), 0);
        mVersionName = info.versionName;
        Log.i(TAG, this.getClass().getSimpleName() + " Spine server Test Application Version " + mVersionName);
    } catch (NameNotFoundException e) {
        Log.e(TAG, this.getClass().getSimpleName() + e.toString());
    }
}

From source file:net.reichholf.dreamdroid.activities.MainActivity.java

@Override
public void showDetails(Class<? extends Fragment> fragmentClass) {
    try {// www. ja v  a2 s . com
        Fragment fragment = fragmentClass.newInstance();
        showDetails(fragment);
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:hd3gtv.mydmam.db.orm.CassandraOrm.java

private T createOrmObject() {
    try {/*from   www.j  av a2 s .  co  m*/
        return (T) reference.newInstance();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:org.dllearner.core.AbstractAxiomLearningAlgorithm.java

protected <K, J extends Set<V>, V> void addToMap(Map<K, J> map, K key, Collection<V> newValues) {
    J values = map.get(key);//from   w w w . j av  a2s .  c  o m
    if (values == null) {
        try {
            values = (J) newValues.getClass().newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        map.put(key, values);
    }
    values.addAll(newValues);
}

From source file:org.dllearner.core.AbstractAxiomLearningAlgorithm.java

protected <K, J extends Set<V>, V> void addToMap(Map<K, J> map, K key, V value) {
    J values = map.get(key);//from   w  ww. ja v a2 s  . com
    if (values == null) {
        try {
            values = (J) value.getClass().newInstance();
            values.add(value);
        } catch (InstantiationException e) {
            e.printStackTrace();
            return;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            return;
        }
    }
    values.add(value);
}

From source file:org.kuali.kpme.tklm.leave.accrual.bucket.KPMEAccrualCategoryBucket.java

private void adjustBalances(CalendarEntry calendarEntry, DateTime rolloverDate, Set<String> assignmentKeys)
        throws KPMEBalanceException {

    //fetch calendar entries in this sequence belonging to the current leave year.
    String dateString = TKUtils.formatDate(LocalDate.now());
    List<CalendarEntry> calendarEntries = HrServiceLocator.getCalendarEntryService()
            .getAllCalendarEntriesForCalendarIdAndYear(calendarEntry.getHrCalendarId(),
                    dateString.substring(6, 10));

    //calendar change into a different leave calendar year
    if (rolloverDate != null) {

        //clear all balances.
        clearLeaveBalances();//from  w w w  .  ja v a 2s . c o m

        //reset the asOfDate this bucket will go off of, as well as those of the leave balances
        adjustAsOfDates(calendarEntry, calendarEntries);

        //TODO: if in current calendar year, use current date + planning months for extent of fetch.
        List<LeaveBlock> leaveBlocks = LmServiceLocator.getLeaveBlockService().getLeaveBlocksSinceCarryOver(
                principalCalendar.getPrincipalId(),
                LmServiceLocator.getLeaveBlockService().getLastCarryOverBlocks(
                        principalCalendar.getPrincipalId(), rolloverDate.minusDays(1).toLocalDate()),
                rolloverDate.plusDays(365).toLocalDate(), true);

        //retrieve (if any) last carryover blocks given the new asOfDate
        Map<String, LeaveBlock> carryOverBlocks = LmServiceLocator.getLeaveBlockService()
                .getLastCarryOverBlocks(principalCalendar.getPrincipalId(), asOfDate);

        //method taken from leave summary service - map general leave block fetch by accrual category
        Map<String, List<LeaveBlock>> accrualCategoryMappedLeaveBlocks = mapLeaveBlocksByAccrualCategory(
                leaveBlocks);

        //merge carryOverBlock map with accrualCategoryMappedLeaveBlocks.
        for (Entry<String, LeaveBlock> entry : carryOverBlocks.entrySet()) {
            //TODO: modify CarryOverLeaveBalance to identify and make use of CARRY_OVER type leave block
            if (accrualCategoryMappedLeaveBlocks.containsKey(entry.getKey()))
                accrualCategoryMappedLeaveBlocks.get(entry.getKey()).add(entry.getValue());
            else {
                List<LeaveBlock> carryOverList = new ArrayList<LeaveBlock>();
                carryOverList.add(entry.getValue());
                accrualCategoryMappedLeaveBlocks.put(entry.getKey(), carryOverList);
            }

        }
        //add leave blocks, accrual category by accrual category, to this bucket.
        for (Entry<String, List<LeaveBlock>> entry : accrualCategoryMappedLeaveBlocks.entrySet()) {
            for (LeaveBlock leaveBlock : entry.getValue()) {
                try {
                    addLeaveBlock(leaveBlock);
                } catch (KPMEBalanceException e) {
                    InstantiationException ie = new InstantiationException();
                    ie.setStackTrace(e.getStackTrace());
                    ie.printStackTrace();
                }
            }
        }
    } else {
        //Calendar change within the same leave year.

        List<String> assignmentKeyList = new ArrayList<String>();
        assignmentKeyList.addAll(assignmentKeys);

        List<LeaveBlock> leaveBlocks = new ArrayList<LeaveBlock>();

        //determine which leave blocks are affected by the calendar change, remove them, and re-add them under the new asOfDate
        if (calendarEntry.getEndPeriodFullDateTime()
                .isBefore(viewingCalendarEntry.getEndPeriodFullDateTime().getMillis())) {
            //need to remove leave blocks from otherLeaveCalendarDocument begin date to thisLeaveCalendarDocument end date
            leaveBlocks = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(
                    principalCalendar.getPrincipalId(),
                    calendarEntry.getBeginPeriodFullDateTime().toLocalDate(),
                    viewingCalendarEntry.getEndPeriodFullDateTime().toLocalDate());
            //leaveBlocks = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForLeaveCalendar(principalCalendar.getPrincipalId(), LocalDate.fromDateFields(calendarEntry.getBeginPeriodDateTime()), LocalDate.fromDateFields(viewingCalendarEntry.getEndPeriodDateTime()), assignmentKeyList);
        } else {
            //need to remove leave blocks from thisLeaveCalendarDocument begin date to otherLeaveCalendarDocument end date
            leaveBlocks = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(
                    principalCalendar.getPrincipalId(),
                    viewingCalendarEntry.getBeginPeriodFullDateTime().toLocalDate(),
                    calendarEntry.getEndPeriodFullDateTime().toLocalDate());
            //leaveBlocks = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForLeaveCalendar(principalCalendar.getPrincipalId(), LocalDate.fromDateFields(viewingCalendarEntry.getBeginPeriodDateTime()), LocalDate.fromDateFields(calendarEntry.getEndPeriodDateTime()), assignmentKeyList);
        }
        //remove affected leave blocks
        for (LeaveBlock block : leaveBlocks) {
            removeLeaveBlock(block);
        }

        //update this bucket and its leave balances with new relative date information
        LocalDate newAsOfDate = null;
        DateTime currentLeavePlanStartDate = HrServiceLocator.getLeavePlanService()
                .getFirstDayOfLeavePlan(principalCalendar.getLeavePlan(), LocalDate.now());
        if (calendarEntry.getEndPeriodFullDateTime().isBefore(currentLeavePlanStartDate)) {
            //require balances as of the final day of the leave calendar year.
            DateTime calendarEntryLeavePlanRolloverDate = HrServiceLocator.getLeavePlanService()
                    .getRolloverDayOfLeavePlan(principalCalendar.getLeavePlan(),
                            calendarEntry.getEndPeriodFullDateTime().toLocalDate());
            newAsOfDate = LocalDate.fromDateFields(calendarEntryLeavePlanRolloverDate.toDate()).minusDays(1);
        } else {
            Interval interval = new Interval(calendarEntry.getBeginPeriodFullDateTime(),
                    calendarEntry.getEndPeriodFullDateTime());
            if (interval.contains(LocalDate.now().toDate().getTime())) {
                newAsOfDate = LocalDate.now();
            } else if (calendarEntry.getBeginPeriodFullDateTime().toLocalDate().isBefore(LocalDate.now()))
                newAsOfDate = calendarEntry.getEndPeriodFullDateTime().toLocalDate().minusDays(1);
            else // if it's in the calendar interval above, the equals case is taken care of, begin date must be after today
                newAsOfDate = calendarEntry.getBeginPeriodFullDateTime().toLocalDate().minusDays(1);
        }

        asOfDate = newAsOfDate;

        for (Entry<String, List<LeaveBalance>> leaveBalance : leaveBalances.entrySet()) {
            for (LeaveBalance balance : leaveBalance.getValue()) {
                balance.calendarPeriodBeginDate = calendarEntry.getBeginPeriodFullDateTime().toLocalDate();
                balance.calendarPeriodEndDate = calendarEntry.getEndPeriodFullDateTime().toLocalDate();
                balance.asOfDate = newAsOfDate;
            }
        }
        //re-add the affected leave blocks under the new date / calendar information
        for (LeaveBlock block : leaveBlocks) {
            addLeaveBlock(block);
        }
    }
}

From source file:org.protorabbit.Config.java

public ICommand getCommand(String name) {
    String className = commandMap.get(name);

    Class<?> clazz = null;//from  w w w  . ja  v  a  2s  .c o m

    // look for custom commands
    if (className == null) {
        try {
            clazz = Class.forName(commandBase + name + "Command");
        } catch (ClassNotFoundException cnfe) {
            getLogger().log(Level.SEVERE, "Error locating class impementation for command " + name + ".");

            return null;
        }
    } else {
        try {
            clazz = Class.forName(className);
        } catch (ClassNotFoundException cnfe) {
            getLogger().log(Level.SEVERE, "Could not find class " + className);
            return null;
        }
    }

    try {

        Object o = clazz.newInstance();
        if (o instanceof ICommand) {
            ICommand ic = (ICommand) o;
            return ic;
        } else {
            getLogger().log(Level.SEVERE, "Error creating instance of " + className
                    + ". The command needs to implement org.protorabbit.model.Command");
        }

    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:gr.upatras.ece.nam.fci.core.FCI.java

public void loadSFAService() {
    ClassLoader classLoader = FCI.class.getClassLoader();

    //Dynamic loading UoPServices plugin if exists
    Class<?> ServicesClass;
    try {//from w ww.j  a  v  a  2  s  .  c om

        ServicesClass = classLoader.loadClass("gr.upatras.ece.nam.fci.sfa.SFAServices");
        log.info("Found aClass.getName() = " + ServicesClass.getName());
        iSFAServices = (IFCIService) ServicesClass.newInstance();

    } catch (ClassNotFoundException e1) {
        //e1.printStackTrace();
        log.warn("SFAServices class not found");
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        //         e.printStackTrace();

        log.warn("SFAServices class not instantiated");
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:gr.upatras.ece.nam.fci.core.FCI.java

/**
 * @return // w  w w .  j  a  v a  2s. c  o  m
 * 
 */

public void loadUoPService() {
    ClassLoader classLoader = FCI.class.getClassLoader();

    //Dynamic loading UoPServices plugin if exists
    Class<?> ServicesClass;
    try {
        ServicesClass = classLoader.loadClass("gr.upatras.ece.nam.fci.uop.UoPServices");
        log.info("Found aClass.getName() = " + ServicesClass.getName());
        iUoPServices = (IFCIService) ServicesClass.newInstance();

    } catch (ClassNotFoundException e1) {
        //e1.printStackTrace();
        log.warn("UoPServices class not found");
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        //         e.printStackTrace();

        log.warn("UoPServices class not instantiated");
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}