List of usage examples for java.lang InternalError InternalError
public InternalError(Throwable cause)
From source file:FontChooser.java
/** * Return a copy of this object.// w ww. ja v a 2 s . co m */ public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException ex) { throw new InternalError(ex.getMessage()); // Impossible. } }
From source file:com.athenahealth.api.APIConnection.java
/** * Convert parameters into a URL query string. * * @param parameters keys and values to encode * @return the query string/*from ww w. j av a 2 s. com*/ */ private String urlencode(Map<?, ?> parameters) { StringBuilder sb = new StringBuilder(); boolean first = true; try { for (Map.Entry<?, ?> pair : parameters.entrySet()) { String k = pair.getKey().toString(); String v; if (null == pair.getValue()) v = "null"; else v = pair.getValue().toString(); String current = URLEncoder.encode(k, "UTF-8") + "=" + URLEncoder.encode(v, "UTF-8"); if (first) { first = false; } else { sb.append("&"); } sb.append(current); } } catch (UnsupportedEncodingException uee) { throw new InternalError("Java suddenly does not support UTF-8 character encoding"); } return sb.toString(); }
From source file:com.clustercontrol.ping.dialog.PingCreateDialog.java
/** * ????/*from ww w. j ava2s. c o m*/ * * @param parent * ? */ @Override protected void customizeDialog(Composite parent) { // ???(%)?? item1 = Messages.getString("response.time.milli.sec"); item2 = Messages.getString("ping.reach"); // ?ping?????? criterion1 = Messages.getString("less"); criterion2 = Messages.getString("less"); super.customizeDialog(parent); m_numericValueInfo.setInfoWarnText("1000", "1", "3000", "51"); // shell.setText(Messages.getString("dialog.ping.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, "runcount", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("run.count") + " : "); // this.m_textRunCount = new Text(groupCheckRule, SWT.BORDER); WidgetTestUtil.setTestId(this, "runcount", m_textRunCount); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_textRunCount.setLayoutData(gridData); this.m_textRunCount.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // ?? label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "count", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setText(Messages.getString("count")); label.setLayoutData(gridData); /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "runinterval", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("run.interval") + " : "); // this.m_textRunInterval = new Text(groupCheckRule, SWT.BORDER); WidgetTestUtil.setTestId(this, "runinterval", m_textRunInterval); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_textRunInterval.setLayoutData(gridData); this.m_textRunInterval.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // ?? label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "millisec", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setText(Messages.getString("milli.sec")); label.setLayoutData(gridData); /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "timeout", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("time.out") + " : "); // this.m_textTimeout = new Text(groupCheckRule, SWT.BORDER); WidgetTestUtil.setTestId(this, "timeout", m_textTimeout); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_textTimeout.setLayoutData(gridData); this.m_textTimeout.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // ?? label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "labelmillisec", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_VALUE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("milli.sec")); // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "responsetime", label); gridData = new GridData(); gridData.horizontalSpan = 14; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); // ???? this.itemName.setText(Messages.getString("response.time")); // ???? this.measure.setText(Messages.getString("time.msec")); // this.adjustDialog(); // ? MonitorInfo info = null; if (this.monitorId == null) { // ??? info = new MonitorInfo(); this.setInfoInitialValue(info); } else { // ???? try { MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(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(), " + 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:Which4J.java
/** * Determine the element type of the array type. This can be the name * of a primitive type or the fully qualified class name of a non primitive * type.// w ww .j a va 2 s. co m * * @param classname the array type * @return the name of the base element type. */ private static String getElementType(String classname) { // remove leading '[' String elementType = classname.split("^\\[+")[1]; char encoding = elementType.charAt(0); if (encoding == 'L') { // don't include the first char 'L' or last char ';' return elementType.substring(1, elementType.length() - 1); } else if (encoding == 'Z') { return "boolean"; } else if (encoding == 'B') { return "byte"; } else if (encoding == 'C') { return "char"; } else if (encoding == 'D') { return "double"; } else if (encoding == 'F') { return "float"; } else if (encoding == 'I') { return "int"; } else if (encoding == 'J') { return "long"; } else if (encoding == 'S') { return "short"; } else { throw new InternalError("unknown array type: '" + encoding + "'.\nplease file a bug report at http://which4j.dev.java.net"); } }
From source file:WorkThreadPool.java
private Request getNextAWTRequest() { Request request = firstAWTRequest; firstAWTRequest = firstAWTRequest.next; if (firstAWTRequest == null) lastAWTRequest = null;/*from ww w . j ava2s.co m*/ if (request.alreadyRun) throw new InternalError("AIEE!!! Request run twice!!! " + request.run); request.alreadyRun = true; /* * StringBuffer buf = new StringBuffer("AWT 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:com.commsen.apropos.core.PropertiesManager.java
/** * Updates {@link Property} in {@link PropertyPackage} called <code>packageName</code>. The * actual update is handled by {@link PropertyPackage#updateProperty(Property)} * //from www. j a v a 2 s .com * @param packageName the name of the package. Can not be <code>null</code> or empty. * @param property the {@link Property} to be updated. Can not be <code>null</code> * @return a new clone of the {@link PropertyPackage} made after the property is updated * @throws PropertiesException if no package called <code>packageName</code> found or if no * such {@link Property} exists in this package * @throws IllegalArgumentException if any of the arguments is <code>null</code> */ public static synchronized PropertyPackage updateProperty(String packageName, Property property) throws PropertiesException { if (StringUtils.isBlank(packageName)) throw new IllegalArgumentException("package name can not be null nor empty string"); if (property == null) throw new IllegalArgumentException("property can not be null"); if (!allPackages.containsKey(packageName)) throw new PropertiesException("No package called " + packageName + " found "); PropertyPackage propertyPackage = allPackages.get(packageName); try { propertyPackage.updateProperty((Property) property.clone()); save(); return (PropertyPackage) propertyPackage.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.toString()); } }
From source file:edu.ku.brc.af.ui.forms.validation.TypeSearchForQueryFactory.java
/** * Returns the instance to the singleton * /*from w w w.java 2 s . c o m*/ * @return the instance to the singleton */ public static TypeSearchForQueryFactory getInstance() { if (instance != null) { return instance; } // else String factoryNameStr = AccessController.doPrivileged(new java.security.PrivilegedAction<String>() { public String run() { return System.getProperty(factoryName); } }); if (isNotEmpty(factoryNameStr)) { try { return instance = (TypeSearchForQueryFactory) Class.forName(factoryNameStr).newInstance(); } catch (Exception e) { e.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SecurityMgr.class, e); InternalError error = new InternalError( "Can't instantiate TypeSearchForQueryFactory factory " + factoryNameStr); //$NON-NLS-1$ error.initCause(e); throw error; } } return instance = new TypeSearchForQueryFactory(); }
From source file:net.sf.firemox.xml.XmlTools.java
private static int getNegativeConstant(int value) { if (value < 0) { if (value < -127) { throw new InternalError("Negative number cannot exceed -127 : " + value); }//from w w w .ja v a2s.com return IdConst.NEGATIVE_NUMBER_MASK | -value; } return value; }
From source file:fullThreadDump.java
/** * Constructs a ThreadMonitor object to get thread information in a remote * JVM./* www . j a v a 2s. c o m*/ * @throws IOException */ public ThreadMonitor(MBeanServerConnection server, boolean stats) throws IOException { this.server = server; this.stats = stats; this.tmbean = newPlatformMXBeanProxy(server, THREAD_MXBEAN_NAME, ThreadMXBean.class); try { objname = new ObjectName(THREAD_MXBEAN_NAME); } catch (MalformedObjectNameException e) { // should not reach here InternalError ie = new InternalError(e.getMessage()); ie.initCause(e); throw ie; } parseMBeanInfo(); }
From source file:com.uber.stream.kafka.mirrormaker.controller.core.HelixMirrorMakerManager.java
public synchronized void updateTopicPartitionStateInMirrorMaker(String topicName, int partition, String state) { updateCurrentServingInstance();//from w w w .j a va2 s . c om if (!Constants.HELIX_OFFLINE_STATE.equalsIgnoreCase(state) && !Constants.HELIX_ONLINE_STATE.equalsIgnoreCase(state)) { throw new IllegalArgumentException(String.format( "Failed to update topic %s, partition %d to invalid state %s.", topicName, partition, state)); } IdealState idealState = _helixAdmin.getResourceIdealState(_helixClusterName, topicName); String partitionName = String.valueOf(partition); if (idealState == null || partition >= idealState.getNumPartitions()) { throw new IllegalArgumentException( String.format("Topic %s, partition %d not exists in current route.", topicName, partition)); } String instanceName; if (idealState.getInstanceStateMap(partitionName).keySet().isEmpty()) { if (Constants.HELIX_OFFLINE_STATE.equalsIgnoreCase(state)) { throw new IllegalArgumentException( String.format("Topic %s, partition %d not exists in current route.", topicName, partition)); } else if (_currentServingInstance.isEmpty()) { throw new InternalError("No available worker"); } instanceName = _currentServingInstance.poll().getInstanceName(); } else { instanceName = idealState.getInstanceStateMap(partitionName).keySet().iterator().next(); String oldState = idealState.getInstanceStateMap(partitionName).get(instanceName); if (oldState.equalsIgnoreCase(state)) { throw new IllegalArgumentException(String.format("Topic %s, partition %d already set %s", idealState.getResourceName(), partition, state)); } } idealState.setPartitionState(partitionName, instanceName, state); _helixAdmin.setResourceIdealState(_helixClusterName, topicName, idealState); }