List of usage examples for java.lang InternalError InternalError
public InternalError(Throwable cause)
From source file:com.commsen.apropos.core.PropertyPackage.java
/** * Reads external {@link Properties} and adds them all to this package. * //from w ww . j av a 2 s .c o m * @param externalProperties the external properties to be added * @param overwrite boolean flag indicating whether to overwrite existing properties * @throws IllegalArgumentException if <code>externalProperties</code> is null */ public void importProperties(Properties externalProperties, boolean overwrite) { if (externalProperties == null) throw new IllegalArgumentException("properties can not be null"); for (Object key : externalProperties.keySet()) { String propertyName = (String) key; if (!overwrite && this.properties.containsKey(propertyName)) continue; try { this.properties.put(propertyName, new Property(propertyName, externalProperties.getProperty(propertyName), null, null)); } catch (PropertiesException e) { /* * this should never happen since the key in Properties can not be null and that is * the only case where new Property() throws PropertiesException */ throw new InternalError(e.getMessage()); } } }
From source file:org.shredzone.cilla.plugin.tumblr.TumblrPublicationServiceImpl.java
/** * Converts a {@link Page} to a {@link TextPost}. * * @param page// ww w.j a v a 2 s.c o m * {@link Page} to convert from * @param post * {@link TextPost} to convert into */ private void pageToPost(Page page, TextPost post) { try { Supplier<LinkBuilder> linkBuilderSupplier = () -> linkService.linkTo().page(page).external(); String url = linkBuilderSupplier.get().toString(); StringBuilder sb = new StringBuilder(); sb.append(textFormatter.format(page.getTeaser(), linkBuilderSupplier)); sb.append("<p><a href=").append(URLEncoder.encode(url, "utf8")).append('>').append(url) .append("</a></p>"); post.setDate(page.getPublication()); post.setTitle(page.getTitle()); post.setBody(sb.toString()); post.setState(tumblrState); List<String> tags = new ArrayList<>(); tags.addAll(page.getCategories().stream().map(Category::getName).collect(toList())); tags.addAll(page.getTags().stream().map(Tag::getName).collect(toList())); if (tumblrAutotags != null && !tumblrAutotags.isEmpty()) { tags.addAll(AUTOTAG_SEPARATOR.splitAsStream(tumblrAutotags).map(String::trim).collect(toList())); } post.setTags(tags); } catch (UnsupportedEncodingException ex) { // Should never happen, as utf8 is standard throw new InternalError(ex); } }
From source file:com.clustercontrol.monitor.view.action.MonitorCopyAction.java
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // ???/*from www .j ava2 s . c o m*/ this.viewPart = HandlerUtil.getActivePart(event); MonitorListView monitorListView = null; try { monitorListView = (MonitorListView) this.viewPart.getAdapter(MonitorListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (monitorListView == null) { m_log.info("execute: view is null"); return null; } MonitorListComposite composite = (MonitorListComposite) monitorListView.getListComposite(); StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection(); List<?> list = (List<?>) selection.getFirstElement(); if (list == null || list.size() == 0) throw new InternalError("select element is not find"); String managerName = (String) list.get(GetMonitorListTableDefine.MANAGER_NAME); String pluginId = (String) list.get(GetMonitorListTableDefine.MONITOR_TYPE_ID); String monitorId = (String) list.get(GetMonitorListTableDefine.MONITOR_ID); int monitorType = MonitorTypeMessage .stringToType((String) list.get(GetMonitorListTableDefine.MONITOR_TYPE)); dialogOpen(this.viewPart.getSite().getShell(), managerName, pluginId, monitorId, monitorType); // ? monitorListView.update(); return null; }
From source file:com.clustercontrol.performance.monitor.dialog.PerformanceCreateDialog.java
/** * ????/* ww w.j ava2s.com*/ * * @param parent * ? */ @Override protected void customizeDialog(Composite parent) { // ????? item1 = Messages.getString("select.value"); item2 = Messages.getString("select.value"); super.customizeDialog(parent); itemName.setEditable(false); measure.setEditable(false); // shell.setText(Messages.getString("dialog.performance.monitor.create.modify")); // ???? GridData gridData = null; /* * ???? */ Group groupCheckRule = new Group(groupRule, SWT.NONE); WidgetTestUtil.setTestId(this, "checkrule", groupCheckRule); GridLayout layout = new GridLayout(1, true); layout.marginWidth = 5; layout.marginHeight = 5; layout.numColumns = BASIC_UNIT; groupCheckRule.setLayout(layout); gridData = new GridData(); gridData.horizontalSpan = BASIC_UNIT; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; groupCheckRule.setLayoutData(gridData); groupCheckRule.setText(Messages.getString("check.rule")); // this.m_comboCollectorItem = new CollectorItemComboComposite(groupCheckRule, SWT.DROP_DOWN | SWT.READ_ONLY); WidgetTestUtil.setTestId(this, "collectoritem", m_comboCollectorItem); gridData = new GridData(); gridData.horizontalSpan = BASIC_UNIT; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_comboCollectorItem.setLayoutData(gridData); // ????????? m_comboCollectorItem.setCollectorItemCombo(this.m_monitorBasic.getManagerListComposite().getText(), null); m_monitorBasic.getButtonScope().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { m_comboCollectorItem.setCollectorItemCombo(PerformanceCreateDialog.this.getManagerName(), m_monitorBasic.getFacilityId()); } }); //???? if (!updateFlg) { this.getMonitorBasicScope().getManagerListComposite().getComboManagerName() .addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { m_comboCollectorItem.setCollectorItemCombo( PerformanceCreateDialog.this.getManagerName(), m_monitorBasic.getFacilityId()); } }); } // this.m_breakdownFlg = new Button(groupCheckRule, SWT.CHECK); WidgetTestUtil.setTestId(this, "breakdownflg", m_breakdownFlg); this.m_breakdownFlg.setText(Messages.getString("dialog.performance.monitor.collect.detail")); gridData = new GridData(); gridData.horizontalSpan = BASIC_UNIT; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_breakdownFlg.setLayoutData(gridData); // ??????? m_comboCollectorItem.getCombo().addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { itemName.setText(m_comboCollectorItem.getCombo().getText()); if (m_comboCollectorItem.getCollectorItem() != null) { measure.setText(HinemosMessage.replace( CollectorItemCodeFactory.getMeasure(PerformanceCreateDialog.this.getManagerName(), m_comboCollectorItem.getCollectorItem().getItemCode()))); update(); } } }); // this.adjustDialog(); // ? MonitorInfo info = null; if (this.monitorId == null) { // ??? info = new MonitorInfo(); this.setInfoInitialValue(info); } else { // ???? try { MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper .getWrapper(this.getManagerName()); info = wrapper.getMonitor(this.monitorId); } 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() getMonitor, " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); throw new InternalError(e.getMessage()); } } this.setInputData(info); }
From source file:gov.nih.nci.calims2.taglib.form.SingleSelectTag.java
@SuppressWarnings("unchecked") private List<Option> getOptionsForRendering(RequestContext requestContext) { switch (collectionType) { case ENUMERATIONS: { return getOptionsFromEnums(requestContext, (Collection<I18nEnumeration>) options); }// ww w .ja v a 2 s . c o m case ENTITIES: { return getOptionsFromEntities(options); } default: { throw new InternalError("Can not happen"); } } }
From source file:org.jahia.utils.zip.legacy.ZipInputStream.java
/** * Reads from the current ZIP entry into an array of bytes. Blocks until * some input is available.//from w w w. j a v a 2 s .com * @param b the buffer into which the data is read * @param off the start offset of the data * @param len the maximum number of bytes read * @return the actual number of bytes read, or -1 if the end of the * entry is reached * @exception java.util.zip.ZipException if a ZIP file error has occurred * @exception IOException if an I/O error has occurred */ public int read(byte[] b, int off, int len) throws IOException { ensureOpen(); if (off < 0 || len < 0 || off > b.length - len) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (entry == null) { return -1; } switch (entry.method) { case DEFLATED: len = super.read(b, off, len); if (len == -1) { readEnd(entry); entryEOF = true; entry = null; } else { crc.update(b, off, len); } return len; case STORED: if (remaining <= 0) { entryEOF = true; entry = null; return -1; } if (len > remaining) { len = (int) remaining; } len = in.read(b, off, len); if (len == -1) { throw new ZipException("unexpected EOF"); } crc.update(b, off, len); remaining -= len; return len; default: throw new InternalError("invalid compression method"); } }
From source file:WorkThreadPool.java
Request getNextRequest() { synchronized (lock) { Request request = firstRequest; if (request == null) return null; firstRequest = firstRequest.next; if (firstRequest == null) lastRequest = null;// w ww.j a v a 2 s .com if (request.alreadyRun) throw new InternalError("AIEE!!! Request run twice!!! " + request.run); request.alreadyRun = true; /* * StringBuffer buf = new StringBuffer("request queue is now: "); Request * _request = request.next; while(_request != null) { * buf.append(_request.id); if(_request.next != null) buf.append(","); * _request = _request.next; } Log.log(Log.DEBUG,this,buf.toString()); */ return request; } }
From source file:HashCodeBuilder.java
/** * This method uses reflection to build a valid hash code. * <p>//from ww w. ja v a2s .c o m * It uses Field.setAccessible to gain access to private fields. This means * that it will throw a security exception if run under a security manger, if * the permissions are not set up. * It is also not as efficient as testing explicitly. * If the TestTransients parameter is set to true, transient members will be * tested, otherwise they are ignored, as they are likely derived fields, and * not part of the value of the object. * Static fields will not be tested. * <p> * Two randomly chosen, non-zero, odd numbers must be passed in. Ideally * these should be different for each class, however this is not vital. * Prime numbers are preferred, especially for the multiplier. * * @param initialNonZeroOddNumber * @param multiplierNonZeroOddNumber * @param object the object to create a hash code for * @param testTransients whether to include transient fields * @return int hash code * @throws IllegalArgumentException if the object is null * @throws IllegalArgumentException if the number is zero or even */ public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object object, boolean testTransients) { if (object == null) { throw new IllegalArgumentException("The object to build a hash code for must not be null"); } HashCodeBuilder hashCodeBuilder = new HashCodeBuilder(initialNonZeroOddNumber, multiplierNonZeroOddNumber); Field[] fields = object.getClass().getDeclaredFields(); Field.setAccessible(fields, true); for (int i = 0; i < fields.length; ++i) { Field f = fields[i]; if (testTransients || !Modifier.isTransient(f.getModifiers())) { if (!Modifier.isStatic(f.getModifiers())) { try { hashCodeBuilder.append(f.get(object)); } 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"); } } } } return hashCodeBuilder.toHashCode(); }
From source file:com.clustercontrol.monitor.view.action.MonitorModifyAction.java
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // ???/*from w w w . j av a2 s.c om*/ this.viewPart = HandlerUtil.getActivePart(event); MonitorListView view = null; try { view = (MonitorListView) this.viewPart.getAdapter(MonitorListView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (view == null) { m_log.info("execute: view is null"); return null; } MonitorListComposite composite = (MonitorListComposite) view.getListComposite(); StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection(); List<?> list = (List<?>) selection.getFirstElement(); if (list == null || list.size() == 0) throw new InternalError("select element is not find"); String managerName = (String) list.get(GetMonitorListTableDefine.MANAGER_NAME); String pluginId = (String) list.get(GetMonitorListTableDefine.MONITOR_TYPE_ID); String monitorId = (String) list.get(GetMonitorListTableDefine.MONITOR_ID); dialogOpen(this.viewPart.getSite().getShell(), managerName, pluginId, monitorId); // ? view.update(); return null; }
From source file:com.clustercontrol.process.dialog.ProcessCreateDialog.java
/** * ????//from ww w . j a va2s. c o m * * @param parent * ? */ @Override protected void customizeDialog(Composite parent) { // ???? item1 = Messages.getString("process.number"); item2 = Messages.getString("process.number"); super.customizeDialog(parent); m_numericValueInfo.setInfoWarnText("1", "99", "99", "99"); // shell.setText(Messages.getString("dialog.process.create.modify")); // ???? Label label = null; // ???? GridData gridData = null; /* * ???? */ Group groupCheckRule = new Group(groupRule, SWT.NONE); WidgetTestUtil.setTestId(this, "checkrule", groupCheckRule); GridLayout layout = new GridLayout(1, true); layout.marginWidth = 5; layout.marginHeight = 5; layout.numColumns = BASIC_UNIT; groupCheckRule.setLayout(layout); gridData = new GridData(); gridData.horizontalSpan = BASIC_UNIT; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; groupCheckRule.setLayoutData(gridData); groupCheckRule.setText(Messages.getString("check.rule")); /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "command", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("command") + " : "); // this.m_textCommand = new Text(groupCheckRule, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "command", m_textCommand); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_textCommand.setLayoutData(gridData); this.m_textCommand.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "space1", label); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "param", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("param") + " : "); // this.m_textParam = new Text(groupCheckRule, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, "param", m_textParam); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_textParam.setLayoutData(gridData); this.m_textParam.setText(".*"); // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "space2", label); gridData = new GridData(); gridData.horizontalSpan = 4; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); // ????? this.m_checkCaseSensitive = new Button(groupCheckRule, SWT.CHECK); WidgetTestUtil.setTestId(this, "casesensitive", m_checkCaseSensitive); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_checkCaseSensitive.setLayoutData(gridData); this.m_checkCaseSensitive.setText(Messages.getString("case.sensitive")); // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "space3", label); gridData = new GridData(); gridData.horizontalSpan = 14; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); // ???? this.itemName.setText(Messages.getString("process.number")); // ???? this.measure.setText(Messages.getString("process.measure")); // this.adjustDialog(); // ? MonitorInfo info = null; if (this.monitorId == null) { // ??? info = new MonitorInfo(); this.setInfoInitialValue(info); } else { // ???? try { MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(managerName); info = wrapper.getMonitor(this.monitorId); } 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.openInformation(null, Messages.getString("message"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); throw new InternalError(e.getMessage()); } } this.setInputData(info); }