本文整理了Java中org.eclipse.jface.util.Assert
类的一些代码示例,展示了Assert
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert
类的具体详情如下:
包路径:org.eclipse.jface.util.Assert
类名称:Assert
[英]Assert
is useful for for embedding runtime sanity checks in code. The static predicate methods all test a condition and throw some type of unchecked exception if the condition does not hold.
Assertion failure exceptions, like most runtime exceptions, are thrown when something is misbehaving. Assertion failures are invariably unspecified behavior; consequently, clients should never rely on these being thrown (or not thrown). If you find yourself in the position where you need to catch an assertion failure, you have most certainly written your program incorrectly.
Note that an assert
statement is slated to be added to the Java language in JDK 1.4, rending this class obsolete.
[中]Assert
对于在代码中嵌入运行时健全性检查非常有用。静态谓词方法都测试一个条件,如果条件不成立,则抛出某种类型的未检查异常。
与大多数运行时异常一样,断言失败异常是在出现错误时抛出的。断言失败总是未指定的行为;因此,客户机永远不应该依赖于这些被抛出(或不被抛出)。如果您发现自己处于需要捕获断言失败的位置,那么您的程序肯定写错了。
注意,一个assert
语句将被添加到JDK1.4中的Java语言中,从而使这个类过时。
代码示例来源:origin: org.eclipse/org.eclipse.datatools.sqltools.sqleditor
/**
* Sets the status to INFO.
* @param infoMessage the info message (can be empty, but not null)
*/
public void setInfo(String infoMessage)
{
Assert.isNotNull(infoMessage);
fStatusMessage= infoMessage;
fSeverity= IStatus.INFO;
}
代码示例来源:origin: org.eclipse/org.eclipse.datatools.sqltools.sqleditor
/**
* Sets the descriptors adornments. Valid values are:</code> WARNING <code>,</code> ERROR <code>,
* <code>PORTABLE</code>, or any combination of those.
*
* @param adornments the image descritpors adornments
*/
public void setAdornments(int adornments)
{
Assert.isTrue(adornments >= 0);
_fFlags = adornments;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface
/**
* Asserts that an argument is legal. If the given boolean is
* not <code>true</code>, an <code>IllegalArgumentException</code>
* is thrown.
*
* @param expression the outcome of the check
* @return <code>true</code> if the check passes (does not return
* if the check fails)
* @exception IllegalArgumentException if the legality test failed
*/
public static boolean isLegal(boolean expression) {
// succeed as quickly as possible
if (expression) {
return true;
}
return isLegal(expression, "");//$NON-NLS-1$
}
代码示例来源:origin: org.eclipse/org.eclipse.datatools.sqltools.sqleditor
/**
* Sets the size of the image created by calling <code>createImage()</code>.
*
* @param size the size of the image returned from calling <code>createImage()</code>
* @see ImageDescriptor#createImage()
*/
public void setImageSize(Point size)
{
Assert.isNotNull(size);
Assert.isTrue(size.x >= 0 && size.y >= 0);
_fSize = size;
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
protected void setGroups(ActionGroup[] groups) {
Assert.isTrue(fGroups == null);
Assert.isNotNull(groups);
fGroups= groups;
}
代码示例来源:origin: org.eclipse/org.eclipse.datatools.sqltools.sqleditor
/**
* Sets the status to WARNING.
* @param warningMessage the warning message (can be empty, but not null)
*/
public void setWarning(String warningMessage)
{
Assert.isNotNull(warningMessage);
fStatusMessage= warningMessage;
fSeverity= IStatus.WARNING;
}
代码示例来源:origin: org.eclipse/org.eclipse.compare
/**
* Called whenever a copy operation has been performed on a tree node.
* This implementation throws an <code>AssertionFailedException</code>
* since we cannot update a zip archive.
*
* @param structure the node for which to save the new content
* @param input the object from which the structure tree was created in <code>getStructure</code>
*/
public void save(IStructureComparator structure, Object input) {
Assert.isTrue(false); // Cannot update zip archive
}
代码示例来源:origin: org.eclipse/org.eclipse.datatools.sqltools.sqleditor
/**
* Creates a new SQLImageDescriptor.
*
* @param baseImage an image descriptor used as the base image
* @param flags flags indicating which adornments are to be rendered. See <code>setAdornments</code> for valid
* values.
* @param size the size of the resulting image
* @see #setAdornments(int)
*/
public SQLImageDescriptor(ImageDescriptor baseImage, int flags, Point size)
{
_fBaseImage = baseImage;
Assert.isNotNull(_fBaseImage);
_fFlags = flags;
Assert.isTrue(_fFlags >= 0);
_fSize = size;
Assert.isNotNull(_fSize);
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface
/**
* Asserts that an argument is legal. If the given boolean is
* not <code>true</code>, an <code>IllegalArgumentException</code>
* is thrown.
*
* @param expression the outcome of the check
* @return <code>true</code> if the check passes (does not return
* if the check fails)
* @exception IllegalArgumentException if the legality test failed
*/
public static boolean isLegal(boolean expression) {
// succeed as quickly as possible
if (expression) {
return true;
}
return isLegal(expression, "");//$NON-NLS-1$
}
代码示例来源:origin: org.apache.uima/uimaj-ep-configurator
/**
* Constructor for NonRuleBasedDamagerRepairer.
*
* @param defaultTextAttribute the default text attribute
*/
public NonRuleBasedDamagerRepairer(TextAttribute defaultTextAttribute) {
Assert.isNotNull(defaultTextAttribute);
fDefaultTextAttribute = defaultTextAttribute;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface
/**
* Asserts that the given boolean is <code>true</code>. If this
* is not the case, some kind of unchecked exception is thrown.
*
* @param expression the outcome of the check
* @return <code>true</code> if the check passes (does not return
* if the check fails)
*/
public static boolean isTrue(boolean expression) {
// succeed as quickly as possible
if (expression) {
return true;
}
return isTrue(expression, "");//$NON-NLS-1$
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface
/**
* Asserts that an argument is legal. If the given boolean is
* not <code>true</code>, an <code>IllegalArgumentException</code>
* is thrown.
*
* @param expression the outcome of the check
* @return <code>true</code> if the check passes (does not return
* if the check fails)
* @exception IllegalArgumentException if the legality test failed
*/
public static boolean isLegal(boolean expression) {
// succeed as quickly as possible
if (expression) {
return true;
}
return isLegal(expression, "");//$NON-NLS-1$
}
代码示例来源:origin: org.eclipse/org.eclipse.datatools.sqltools.sqleditor
/**
* Sets the status to ERROR.
* @param errorMessage the error message (can be empty, but not null)
*/
public void setError(String errorMessage)
{
Assert.isNotNull(errorMessage);
fStatusMessage= errorMessage;
fSeverity= IStatus.ERROR;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface
/**
* Asserts that the given boolean is <code>true</code>. If this
* is not the case, some kind of unchecked exception is thrown.
*
* @param expression the outcome of the check
* @return <code>true</code> if the check passes (does not return
* if the check fails)
*/
public static boolean isTrue(boolean expression) {
// succeed as quickly as possible
if (expression) {
return true;
}
return isTrue(expression, "");//$NON-NLS-1$
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
public XSDSearchActionGroup(IEditorPart editor)
{
Assert.isNotNull(editor);
// fEditor = editor;
// fReferencesGroup = new ReferencesSearchGroup(editor);
// fDeclarationsGroup = new DeclarationsSearchGroup();
// fImplementorsGroup = new ImplementorsSearchGroup();
// fOccurrencesGroup = new OccurrencesSearchGroup();
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface
/**
* Asserts that the given boolean is <code>true</code>. If this
* is not the case, some kind of unchecked exception is thrown.
*
* @param expression the outcome of the check
* @return <code>true</code> if the check passes (does not return
* if the check fails)
*/
public static boolean isTrue(boolean expression) {
// succeed as quickly as possible
if (expression) {
return true;
}
return isTrue(expression, "");//$NON-NLS-1$
}
代码示例来源:origin: org.eclipse/org.eclipse.datatools.sqltools.sqleditor
/**
* Creates a new action with no text and no image.
* <p>
* Configure the action later using the set methods.
* </p>
*
* @param site the site this action is working on
*/
protected SelectionDispatchAction(IWorkbenchSite site)
{
Assert.isNotNull(site);
_fSite = site;
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.common.ui.properties
/**
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
Assert.isTrue(inputElement instanceof ISelection);
return registry
.getTabDescriptors(currentPart, (ISelection) inputElement);
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
protected SelectionDispatchAction(ISelection selection) {
Assert.isNotNull(selection);
this.selection = selection;
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.common.ui.properties
/**
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
* java.lang.Object, java.lang.Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (tabbedPropertyViewer == null) {
Assert.isTrue(viewer instanceof TabbedPropertyViewer);
init((TabbedPropertyViewer) viewer);
}
}
内容来源于网络,如有侵权,请联系作者删除!