Example usage for java.lang InternalError InternalError

List of usage examples for java.lang InternalError InternalError

Introduction

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

Prototype

public InternalError(Throwable cause) 

Source Link

Document

Constructs an InternalError with the specified cause and a detail message of (cause==null ?

Usage

From source file:HashCodeAssist.java

/**
 * <p>/*w w w. j  a va2  s  . c o  m*/
 * Appends the fields and values defined by the given object of the given
 * <code>Class</code>.
 * </p>
 * 
 * @param object
 *            the object to append details of
 * @param clazz
 *            the class to append details of
 * @param builder
 *            the builder to append to
 * @param useTransients
 *            whether to use transient fields
 * @param excludeFields
 *            Collection of String field names to exclude from use in
 *            calculation of hash code
 */
private static void reflectionAppend(Object object, Class<?> clazz, HashCodeAssist builder,
        boolean useTransients, String... excludeFields) {
    if (isRegistered(object)) {
        return;
    }
    try {
        register(object);
        Field[] fields = clazz.getDeclaredFields();
        List<String> excludedFieldList = excludeFields != null ? Arrays.asList(excludeFields)
                : Collections.EMPTY_LIST;
        AccessibleObject.setAccessible(fields, true);
        for (int i = 0; i < fields.length; i++) {
            Field field = fields[i];
            if (!excludedFieldList.contains(field.getName()) && (field.getName().indexOf('$') == -1)
                    && (useTransients || !Modifier.isTransient(field.getModifiers()))
                    && (!Modifier.isStatic(field.getModifiers()))) {
                try {
                    Object fieldValue = field.get(object);
                    builder.append(fieldValue);
                } catch (IllegalAccessException e) {
                    // this can't happen. Would get a Security exception
                    // instead
                    // throw a runtime exception in case the impossible
                    // happens.
                    throw new InternalError("Unexpected IllegalAccessException");
                }
            }
        }
    } finally {
        unregister(object);
    }
}

From source file:org.tinygroup.commons.tools.EqualsUtil.java

/**
* <p>Appends the fields and values defined by the given object of the
* given Class.</p>/*from  w  ww. j  a v  a 2s. com*/
* 
* @param lhs  the left hand object
* @param rhs  the right hand object
* @param clazz  the class to append details of
* @param builder  the builder to append to
* @param useTransients  whether to test transient fields
* @param excludeFields  array of field names to exclude from testing
*/
private static void reflectionCompareAppend(Object lhs, Object rhs, Class clazz, EqualsBuilder builder,
        boolean useTransients, String[] compareFields) {
    Field[] fields = clazz.getDeclaredFields();
    List compareFieldList = compareFields != null ? Arrays.asList(compareFields) : Collections.EMPTY_LIST;
    AccessibleObject.setAccessible(fields, true);
    for (int i = 0; i < fields.length && builder.isEquals(); i++) {
        Field f = fields[i];
        if (compareFieldList.contains(f.getName()) && (f.getName().indexOf('$') == -1)
                && (useTransients || !Modifier.isTransient(f.getModifiers()))
                && (!Modifier.isStatic(f.getModifiers()))) {
            try {
                builder.append(f.get(lhs), f.get(rhs));
            } catch (IllegalAccessException e) {
                //this can't happen. Would get a Security exception instead
                //throw a runtime exception in case the impossible happens.
                throw new InternalError("Unexpected IllegalAccessException");
            }
        }
    }
}

From source file:com.clustercontrol.accesscontrol.dialog.RoleSettingDialog.java

/**
 * ????/*from www. java 2  s . c  om*/
 *
 * @param parent ?
 *
 * @see com.clustercontrol.dialog.CommonDialog#customizeDialog(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void customizeDialog(Composite parent) {
    Shell shell = this.getShell();

    // 
    shell.setText(Messages.getString("dialog.accesscontrol.role.setting"));

    // ??
    RoleInfo info = null;
    try {
        AccessEndpointWrapper wrapper = AccessEndpointWrapper.getWrapper(this.managerName);
        info = wrapper.getRoleInfo(this.roleId);
    } catch (InvalidRole_Exception e) {
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.accesscontrol.16"));
        throw new InternalError(e.getMessage());
    } catch (Exception e) {
        m_log.warn("customizeDialog(), " + HinemosMessage.replace(e.getMessage()), e);
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.hinemos.failure.unexpected") + ", "
                        + HinemosMessage.replace(e.getMessage()));
        throw new InternalError(e.getMessage());
    }

    // 
    GridLayout layout = new GridLayout(1, true);
    layout.marginWidth = 10;
    layout.marginHeight = 10;
    layout.numColumns = WIDTH;
    parent.setLayout(layout);

    /*
     * ??
     */
    // 
    Label label = new Label(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, "role", label);
    GridData gridData = new GridData();
    gridData.horizontalSpan = WIDTH;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("role.name") + " : " + info.getRoleName());

    /*
     * ?
     */
    Composite compositeNotRole = new Composite(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, "all", compositeNotRole);

    layout = new GridLayout(1, true);
    layout.numColumns = 1;
    compositeNotRole.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 6;
    gridData.verticalSpan = 2;
    compositeNotRole.setLayoutData(gridData);

    //  
    label = new Label(compositeNotRole, SWT.NONE);
    WidgetTestUtil.setTestId(this, "alluserlist", label);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("RoleSettingDialog.not_role_user"));

    //  
    this.listNotRoleUser = new List(compositeNotRole, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    WidgetTestUtil.setTestId(this, "all", compositeNotRole);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = this.listNotRoleUser.getItemHeight() * 12;
    this.listNotRoleUser.setLayoutData(gridData);

    //  ?
    this.mapNotRoleUser = new HashMap<String, String>();

    /*
     * ??
     */
    Composite compositeButton = new Composite(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, "composite", compositeButton);
    layout = new GridLayout(1, true);
    layout.numColumns = 1;
    compositeButton.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 3;
    compositeButton.setLayoutData(gridData);

    // 
    label = new Label(compositeButton, SWT.NONE);
    WidgetTestUtil.setTestId(this, "blank1", label);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);

    // 
    Label dummy = new Label(compositeButton, SWT.NONE);
    WidgetTestUtil.setTestId(this, "dummy", dummy);
    this.buttonRoleUser = this.createButton(compositeButton,
            Messages.getString("RoleSettingDialog.role_user_button"));
    WidgetTestUtil.setTestId(this, "assign", buttonRoleUser);
    this.buttonRoleUser.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String[] items = listNotRoleUser.getSelection();
            for (String item : items) {
                listNotRoleUser.remove(item);
                listRoleUser.add(item);

                // ?????ID?HashMap???????
                mapRoleUser.put(item, mapNotRoleUser.get(item));
                mapNotRoleUser.remove(item);
            }
        }
    });

    // 
    dummy = new Label(compositeButton, SWT.NONE);
    WidgetTestUtil.setTestId(this, "unassign", dummy);
    this.buttonNotRoleUser = this.createButton(compositeButton,
            Messages.getString("RoleSettingDialog.not_role_user_button"));
    WidgetTestUtil.setTestId(this, "unassign", buttonNotRoleUser);
    this.buttonNotRoleUser.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String[] items = listRoleUser.getSelection();
            for (String item : items) {
                listRoleUser.remove(item);
                listNotRoleUser.add(item);

                // ?????ID?HashMap???????
                mapNotRoleUser.put(item, mapRoleUser.get(item));
                mapRoleUser.remove(item);
            }
        }
    });

    // 
    label = new Label(compositeButton, SWT.NONE);
    WidgetTestUtil.setTestId(this, "blank", label);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);

    /*
     * ?
     */
    Composite compositeRole = new Composite(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, "role", compositeRole);
    layout = new GridLayout(1, true);
    layout.numColumns = 1;
    compositeRole.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 6;
    gridData.verticalSpan = 2;
    compositeRole.setLayoutData(gridData);

    //  
    label = new Label(compositeRole, SWT.NONE);
    WidgetTestUtil.setTestId(this, "userlist", label);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("RoleSettingDialog.role_user"));

    //  
    this.listRoleUser = new List(compositeRole, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    WidgetTestUtil.setTestId(this, "roleuserlist", listRoleUser);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = this.listRoleUser.getItemHeight() * 12;
    this.listRoleUser.setLayoutData(gridData);

    //  ?
    this.mapRoleUser = new HashMap<String, String>();

    // ?
    // ????????????????????
    shell.pack();
    shell.setSize(new Point(550, shell.getSize().y));

    // ??
    Display display = shell.getDisplay();
    shell.setLocation((display.getBounds().width - shell.getSize().x) / 2,
            (display.getBounds().height - shell.getSize().y) / 2);

    this.setInputData(this.managerName, info);
}

From source file:com.swordlord.jalapeno.datarow.DataRowBase.java

public DataRowKeyBase getKey() {
    throw new InternalError("getKey must be overwritten!");
}

From source file:com.swordlord.jalapeno.datarow.DataRowBase.java

public String getKeyName() {
    throw new InternalError("getKeyName must be overwritten!");
}

From source file:com.clustercontrol.agent.job.CheckSumThread.java

/**
 * ??/*from   w  ww  . j av  a  2  s. c om*/
 * 
 * @param path
 * @return
 */
private String getCheckSum(String path) {
    m_log.debug("get checksum start");

    String checksum = null;
    FileInputStream inputStream = null;
    try {
        inputStream = new FileInputStream(path);
        MessageDigest md = MessageDigest.getInstance(ALGORITHM);

        byte[] readData = new byte[256];
        int len;
        while ((len = inputStream.read(readData)) >= 0) {
            md.update(readData, 0, len);
        }
        inputStream.close();

        checksum = changeString(md.digest());

    } catch (Exception e) {
        m_log.warn("getCheckSum error. " + e.getMessage(), e);
    } finally {
        if (inputStream != null)
            try {
                inputStream.close();
            } catch (IOException e) {
                throw new InternalError("failed to close the FileInputStream");
            }
    }

    m_log.debug("get checksum end. path=" + path + ", md5=" + checksum);
    return checksum;
}

From source file:org.isatools.tablib.mapping.pipeline.DataNodeTabMapper.java

/**
 * Setup this mapper as the last mapper.
 *///from   w w w  . ja v  a  2s . c o  m
public void setAsLastMapper() {
    if (isLastMapper != null && !isLastMapper) {
        throw new InternalError(
                "Internal error, a data node mapper can be set as the last mapper in the pipeline only before the mapping starts");
    }

    isLastMapper = true;

    // As last node, you have the responsibility to harvest the factor values
    this.mappingHelpersConfig.put("Factor Value", new MappingHelperConfig<AssayResultFVMappingHelper>(
            AssayResultFVMappingHelper.class, new String[][] { { "lookAllHeaders", "true" } }));
}

From source file:org.openmrs.PersonAddress.java

/**
 * bitwise copy of the personAddress object. NOTICE: THIS WILL NOT COPY THE PATIENT OBJECT. The
 * PersonAddress.person object in this object AND the cloned object will point at the same
 * person/*from   w w w.  ja  va 2 s  .  c  o m*/
 *
 * @return New PersonAddress object
 */
public Object clone() {
    try {
        return super.clone();
    } catch (CloneNotSupportedException e) {
        throw new InternalError("PersonAddress should be cloneable");
    }
}

From source file:com.clustercontrol.jobmanagement.view.action.EditModeAction.java

/**
 * []????????????/*from ww  w. j  a v a 2s . c o m*/
 *
 * @see org.eclipse.core.commands.IHandler#execute
 * @see com.clustercontrol.jobmanagement.view.JobPlanListView
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    this.window = HandlerUtil.getActiveWorkbenchWindow(event);
    // In case this action has been disposed
    if (null == this.window || !isEnabled()) {
        return null;
    }

    // ???
    this.viewPart = HandlerUtil.getActivePart(event);
    // ??????????????????

    if (!(viewPart instanceof JobListView)) {
        return null;
    }

    JobListView jobListView = null;
    try {
        jobListView = (JobListView) viewPart.getAdapter(JobListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (jobListView == null) {
        m_log.info("execute: view is null");
        return null;
    }

    // ???
    JobTreeItem selectedItem = null;
    // ??
    JobTreeItem item = null;
    JobTreeItem parent = null;

    selectedItem = jobListView.getSelectJobTreeItemList().get(0);
    ICommandService commandService = (ICommandService) window.getService(ICommandService.class);
    Command command = commandService.getCommand(ID);
    State state = command.getState(RegistryToggleState.STATE_ID);
    boolean isChecked = jobListView.getEditEnable();

    if (selectedItem != null) {
        item = JobUtil.getTopJobUnitTreeItem(selectedItem);
    } else {
        // OFF??
        state.setValue(false);
    }
    if (item != null) {
        parent = item.getParent();
    }
    if (parent == null) {
        // ??????????????
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.job.110"));
        return null;
    }

    String jobunitId = item.getData().getJobunitId();
    String managerName = "";
    JobTreeItem managerTree = JobTreeItemUtil.getManager(item);
    if (managerTree == null)
        throw new InternalError("JobTreeItem is null");

    managerName = managerTree.getData().getName();
    JobEditState jobEditState = JobEditStateUtil.getJobEditState(managerName);
    if (!isChecked) {
        if (jobEditState.getLockedJobunitList().contains(item.getData())) {
            // ????????????(?????)
            return null;
        }
        // ?
        Long updateTime = jobEditState.getJobunitUpdateTime(jobunitId);
        Integer result = null;
        try {
            result = JobUtil.getEditLock(managerName, jobunitId, updateTime, false);
        } catch (OtherUserGetLock_Exception e) {
            // ??????
            String message = HinemosMessage.replace(e.getMessage());
            if (MessageDialog.openQuestion(null, Messages.getString("confirmed"), message)) {
                try {
                    result = JobUtil.getEditLock(managerName, jobunitId, updateTime, true);
                } catch (Exception e1) {
                    // ??????????
                    m_log.error("run() : logical error");
                }
            }
        }

        if (result != null) {
            // ???
            m_log.debug("run() : get editLock(jobunitId=" + jobunitId + ")");
            jobEditState.addLockedJobunit(item.getData(), JobTreeItemUtil.clone(item, null), result);
            jobListView.getJobTreeComposite().refresh(parent);
            JobTreeComposite tree = jobListView.getJobTreeComposite();
            tree.getTreeViewer().setSelection(new StructuredSelection(selectedItem), true);
        } else {
            // ?????
            m_log.debug("run() : cannot get editLock(jobunitId=" + jobunitId + ")");
            state.setValue(false);
        }
    } else {
        // ??
        if (!jobEditState.getLockedJobunitList().contains(item.getData())) {
            // ????????????(????????)
            return null;
        }
        try {
            if (MessageDialog.openQuestion(null, Messages.getString("confirmed"),
                    Messages.getString("message.job.103"))) {
                // ?
                JobTreeItem manager = JobTreeItemUtil.getManager(item);
                JobEndpointWrapper wrapper = JobEndpointWrapper.getWrapper(managerName);
                wrapper.releaseEditLock(jobEditState.getEditSession(item.getData()));

                //???
                JobTreeItem backup = jobEditState.getLockedJobunitBackup(item.getData());
                JobTreeItemUtil.removeChildren(parent, item);
                if (backup != null) {
                    JobPropertyUtil.setJobFullTree(manager.getData().getName(), backup);
                    JobTreeItemUtil.addChildren(parent, backup);
                }

                jobEditState.exitEditMode(item);
                jobListView.getJobTreeComposite().getTreeViewer().sort(parent);
                jobListView.getJobTreeComposite().refresh();
            } else {
                //???
                state.setValue(false);
            }
        } catch (InvalidRole_Exception e) {
            // ??????
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
        } catch (Exception e) {
            m_log.warn("updateJobunitUpdateTime() : " + e.getMessage(), e);
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.hinemos.failure.unexpected") + ", "
                            + HinemosMessage.replace(e.getMessage()));
        }
    }
    return null;
}

From source file:org.shredzone.cilla.web.comment.CommentThreadServiceImpl.java

/**
 * Computes a mail hash that can be used at Gravatar.
 *
 * @param mail/*from   ww w.j  a  v  a2s .  c om*/
 *            mail address
 * @return md5 hash
 */
private static String computeMailHash(String mail) {
    try {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.reset();
        md5.update(mail.trim().toLowerCase().getBytes("UTF-8"));

        StringBuilder digest = new StringBuilder();
        for (byte b : md5.digest()) {
            digest.append(String.format("%02x", b & 0xFF));
        }

        return digest.toString();
    } catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
        // we expect no exception, since MD5 and UTF-8 are standards
        throw new InternalError(ex.getMessage());
    }
}