Assertion facility is added in J2SE 1.4. In order to support this facility J2SE 1.4 added the keyword assert to the language, and AssertionError class. An assertion checks a boolean-typed expression that must be true during program runtime execution. The assertion facility can be enabled or disable at runtime.
Declaring Assertion
Assertion statements have two forms as given below
assert expression;
assert expression1 : expression2;
The first form is simple form of assertion, while second form takes another expression. In both of the form boolean expression represents condition that must be evaluate to true runtime.
If the condition evaluates to false and assertions are enabled, AssertionError will be thrown at runtime.
Some examples that use simple assertion form are as follows.
assert value > 5 ;
assert accontBalance > 0;
assert isStatusEnabled();
The expression that has to be asserted runtime must be boolean value. In third example isStatusEnabled() must return boolean value. If condition evaluates to true, execution continues normally, otherwise the AssertionError is thrown.
Following program uses simple form of assertion
//AssertionDemo.java
Class AssertionDemo{
Public static void main(String args[]){
System.out.println( withdrawMoney(1000,500) );
System.out.println( withdrawMoney(1000,2000) );
}
public double withdrawMoney(double balance , double amount){
assert balance >= amount;
return balance - amount;
}
}
In above given example, main method calls withdrawMoney method with balance and amount as arguments. The withdrawMoney method has a assert statement that checks whether the balance is grater than or equal to amount to be withdrawn. In first call the method will execute without any exception, but in second call it AssertionError is thrown if the assertion is enabled at runtime.
Enable/Disable Assertions
By default assertion are not enabled, but compiler complains if assert is used as an identifier or label. The following command will compile AssertionDemo with assertion enabled.
javac -source 1.4 AssertionDemo.java
The resulting AssertionDemo class file will contain assertion code.
By default assertion are disabled in Java runtime environment. The argument -eanbleassertion or -ea will enables assertion, while -disableassertion or -da will disable assertions at runtime.
The following command will run AssertionDemo with assertion enabled.
Java -ea AssertionDemo
or
Java -enableassertion AssertionDemo
Second form of Assertion
The second form of assertion takes another expression as an argument.
The syntax is,
assert expression1 : expression2;
where expression1 is the condition and must evaluate to true at runtime.
This statement is equivalent to
assert expression1 : throw new AssertionError(expression2);
Note: AssertionError is unchecked exception, because it is inherited from Error class.
Here, expression2 must evaluate to some value.
By default AssertionError doesn't provide useful message so this form can be helpful to display some informative message to the user.
Rahim Vindhani
Application Develper [Application Development & Webservices]
IBM Global Services, pune, India
email: rahim.vindhani@gmail.com
web: http://www.rahim.co.nr
MORE RESOURCES:
RELATED ARTICLES
Microsoft Great Plains Upgrade - Things to Consider and FAQ
If you have Microsoft Great Plains and support it for your company then you need to know some technical details about Great Plains version upgrade and what is going on behind the scenes, which options do you have in case of Dexterity, VBA, SQL customization, additional complexity comes with migration from ctree/Pervasive to MS SQL/MSDE.What is upgrade in the language of technology? Upgrade has server and client sides.
The Religion And Philosophy Of Small Internet Business
I have always had a tendency to focus on the positive. We, all of us, know the negative details in society and governments.
Builders Beware
Which Type of Shop Can Rely On A Home Built System?Not all shops are at a disadvantage when it comes to building their own system. To determine which avenue a shop should take, owners must know what type of shops benefit from a self built solution and what type is better off purchasing one.
Microsoft Great Plains Reporting - Overview for Developer
Looks like Microsoft Great Plains becomes more and more popular, partly because of Microsoft muscles behind it. Now it is targeted to the whole spectrum of horizontal and vertical market clientele.
The Truth: Netzero 3G
We've all seen the ads on TV for Netzero 3G. You know the ones, "speeds so fast you sworn it was broadband" Well if your using it, you may not think it really is.
Does your Company have Documentum?
Are you lost in the mess of documents that get passed around your company, never knowing what the latest version is and which one you should work on without worrying if someone else has already made the same editions that you are making? Perhaps you have heard of collaboration software solutions such as Documentum to help your company manage its documents that are passed around. Documentum is a very good solution to this problem but is it the only one? In this article you will be presented with some basic information about the differences in collaboration software from Documentum and NextPage.
Microsoft Great Plains: If You are Orphan Client - What to Do and FAQ
Microsoft Business Solutions Great Plains, former Great Plains Software eEnterprise, Dynamics and Dynamics C/S+ is very popular ERP and since 1994 has been successfully implemented for mid-size and mid-size to large companies in the USA, Canada, UK, Australia, New Zealand, South Africa and Middle East. During the economic recession time 2001-2004 the majority of businesses cut to virtually zero their IT/computer support expenses and stayed with hardware and software.
You Can Write Microsoft Office Program in About 60 Minutes
Microsoft Office program is a programming tool called Visual Basic for Applications (VBA) that comes with Microsoft Excel, Word, Outlook, Power Point, and Publisher. VBA can make your repeating jobs automatic.
Lowering The Risks In Developing Do-It-Yourself Software Projects
Mike Dunville* had a decision to make. As the new operations manager for Alpha Staffing, he wanted to make a difference at the dynamic staffing firm.
Great Plains Customization Upgrade- Overview For CIO/IT Director
Around the same time Microsoft made its move with .Net introduction and tried to gain portion of cheaper databases market: Pervasive SQL/Btrieve, Ctree/Faircom - and launched free MSDE database program.
Software Automation Helps Increase your Bottom Line
When you own a small business, time is money. And every time a task that should be automated is handled manually, it wastes your time and your business loses money.
Microsoft Business Solutions VAR/Partner Selection - Overview for IT Director/Manager/Controller
Microsoft Great Plains and Microsoft CRM become more and more popular, partly because of Microsoft muscles behind them. Now Great Plains is targeted to the whole spectrum of horizontal and vertical market clientele.
Microsoft CRM Programming Secrets - Tips For Developers
This article is for advanced Microsoft CRM SDK C# developers. It describes the technique of direct SQL programming, when SDK doesn't have the functionality to do the job.
MSN Messenger Is A Sweet Way To Communicate
MSN messenger is a pretty cool invention. I mean I'm not really into serious discussions on the email, answers to questions can often take a few days to arrive because people are so busy these days.
Unofficial Windows 98 SE Service Pack 2.0 RC2
Microsoft has never released a service pack for Windows98 SE, but I made a Service Pack for Windows98 SE users.It contains all Windows98 SE updates from Windows Update site and more.
Guide to Software Marketing
Intro This concise article will tell you in plain English how you can promote your software easily and effectively.Submit your software I recommend submitting your software to upload.
Beware of Spyware
One day, you suddenly realize that your computer started to work noticeably slower than it used to. You decide to run de-fragmentation of your hard drive and add more virtual memory to the system.
The Dirt on Screensavers
Remember back in the days where screensavers were the coolest thing at the office? You could stare at your co-worker's "fish in the ocean" screensaver at the cubicle next door for hours and actually have a full afternoon of conversation about that one screensaver.Well, screensavers are still "in", but not as "in" as they used to be.
Groupware Finds Home in American Business: Collaboration Tool Analysis
What is Groupware?Have you ever had to manage document collaboration in a hurry? No need to be ashamed if you said "yes." Virtually every American business has experienced moments of ad hoc team collaboration.
Imagine if Everyone Working In Your Office Was In Synch?
Microsoft-Outlook is a pretty amazing program. So much more than simply an e-mail client, it provides a task list, a powerful calendar with recurring scheduling capabilities, wonderful electronic sticky notes, mail-merge capability with MS-Word support and so much more.
Sunday, November 11, 2007
Microsoft CRM Data
Microsoft CRM has built-in conversion tool, however you should probably first try third party conversion tool, such as Scribe. It is relatively expensive and has bunch of importing capabilities, that you might never use and need. Scribe allows you to map objects in source and target, when source is ACT! for example. If you are just realized the need to load data into CRM - please research Microsoft CRM import tool and Scribe. Here we will describe other option and possibilities
? Master records import - you can import via MS CRM integration tool. Tools->Import and select contacts or leads
? Duplication dilemma. In version 1.2 as well as in 3.0 (as far as we know) you do not have duplication check and you can import duplicate leads or contacts.
? MS CRM SDK custom data migration. If data import is critical and you have reasonable budget for the migration - you can appeal to MS CRM customization partner who specializes in the complex data import. In MS CRM SDK you can program duplication check, special rules for security settings. We have to stress here, that this is not one thousand dollars project and if you are small company, you should stick to Scribe or native MS CRM import tool
? Large Scale MS CRM implementation. For corporate business security might have top priority and migration should be programmed in MS CRM SDK.
? Some technical tips. Post-call-outs. In MS CRM 3.0 which should be released in earlier 2006 there are so-called pre-call outs (in version 1.2 we have only post-call-outs). Pre-call-out should allow to check for duplication, based on your duplication recognition criteria and cancel record if it is duplicate contact, account or lead
If you have a need in large scale data import, you can always have us help you with MS CRM SDK data conversion. Give us a call: 866.528.0577 or 1.630.961.598, help@albaspectrum.com
Andrew Karasev is Chief Technology Officer at Alba Spectrum Technologies ( http://www.albaspectrum.com ) - Microsoft Business Solutions Great Plains, Navision, Axapta MS CRM, Oracle Financials and IBM Lotus Domino Partner, serving corporate customers in the following industries: Aerospace & Defense, Medical & Healthcare, Distribution & Logistics, Hospitality, Banking & Finance, Wholesale & Retail, Chemicals, Oil & Gas, Placement & Recruiting, Advertising & Publishing, Textile, Pharmaceutical, Non-Profit, Beverages, Conglomerates, Apparels, Durables, Manufacturing and having locations in multiple states and internationally.
MORE RESOURCES:
RELATED ARTICLES
Daffodil DB: Web Database
What is a Web Database?A web database is a database for the internet. You can get access to your data via the internet from anywhere in the world.
The Death of Windows
I have always regretted how Microsoft price gouges and rips off computer users. I really regret Windows XP activation.
QuarkXpress Tips: How to Move Content Between Print and Web Layouts
Since its release in 1987, QuarkXpress had made an immediate impact to computer enthusiasts. QuarkXPress introduced precision typography, layout and color control to the desktop computer, and delivered those features to designers at a fraction of the cost of proprietary typesetting systems.
A Symons Mark II Function Point Counting Example
I provide, here clear explanations and a count of function points, using the Symons Mark II method.We start by identifying the subprocesses (entry, exit, read, write) for each functional process; The size of a functional process is the sum of its data movements (entry, exit, read, write) and the size of a piece of software is the sum of the sizes of all of its functional processes.
Programming Environments And The Software Production Process
Introduction: The creating of a computer program involves a number of stages which can be made easier with several separate software utilities. There are now integrated set of support programs which combine all the necessary utilities to provide a complete program development environment.
Passwords Used In Microsoft Word Documents
You would like to protect your documents, wouldn't you? Reasons may vary but the problem is the same - you need to protect your Microsoft Word documents from unauthorized editing or viewing. What document protection features does Microsoft® Office Word 2003, a part of Microsoft Office Professional Edition 2003 provide?Microsoft Word features for document protection.
Beware of The Pirated Software E-Mail Scams!
You have gotten those E_Mails buy software at deep discounts. It is very tempting to save 85% to 95% on your favorite Software Titles.
Microsoft Great Plains Installation - Overview for IT Director/Controller
Microsoft Great Plains is main mid-market application from Microsoft Business Solutions. This is short article, written in question/answer/FAQ style to give IT Director/Controller balanced top level information on Microsoft Business Solutions Great Plains implementation.
Databases - How We Love to Hate Them!
You've finally created databases that you can actually use to store and manipulate all your critical data. That's great news and quite an accomplishment.
Groupware and Version History: Collaboration Series #1
This article is the first of a series of articles exploring specific aspects of groupware. The brief informational articles in this series discuss some of the technologies associated with groupware, as well as some of the characteristics of groupware.
OLAP, An Alternative Technology Over Spreadsheets
Are Spreadsheets Robbing your Enterprise of Competitive Advantage?'90% of "average" companies are not confident that their forecasts and reports are accurate and reliable'In a recent study, 81% of FD's cited that their highest priority is the accuracy of revenue and earnings forecasts while 63% complained of inadequate budgeting and forecasting systems .The modern FD is coming under increasing pressure from all sides to produce more robust, meaningful and accurate financial information.
Unwanted Files
A LOT OF UNWANTED FILES.When you uninstall an item of software, there are generally a number of redundant files left behind to clutter up your hard drive.
Groupware Finds Home in American Business: Collaboration Tool Analysis
What is Groupware?Have you ever had to manage document collaboration in a hurry? No need to be ashamed if you said "yes." Virtually every American business has experienced moments of ad hoc team collaboration.
Great Plains Dexterity Customization Options - Overview For Developers
Looks like Microsoft Great Plains becomes more and more popular, partly because of Microsoft muscles behind it. Now it is targeted to the whole spectrum of horizontal and vertical market clientele.
Microsoft Great Plains Furniture & Fixtures - Implementation & Customization Highlights
Microsoft Great Plains, former Great Plains Software Dynamics / eEnterprise was introduced in 1993 as first Microsoft Windows and Macintosh based graphical accounting/ERP application for Mid-Size businesses. Considering the history of furniture retailer and custom assembly lines - they showed up on the market about five decades ago and they have automated their business operations with Unix-based businesses in the late 1960th and earlier 1970th.
Spyware Statistics -- Whats New in May 2005?
Although statistics often is blamed for various deadly sins -- from being biased to being inaccurate -- there is nothing left to those who are anyhow connected with IT but to keep up with fresh data. Since spyware is literally ubiquitous, nobody who owns or uses a PC can say that it is none of his business.
Professional XP Style Icons in Software and Website Development
Using professional icons in your application or website can bring a modern and aesthetically pleasing appearance to your product or service. This will not only help you to attract potential customers but also give you that "edge" you need to stand out from your competitors.
40/sec to 500/sec
IntroductionSurprised, by the title? well, this is a tour of how we cracked the scalability jinx from handling a meagre 40 records per second to 500 records per second. Beware, most of the problems we faced were straight forward, so experienced people might find this superfluous.
.Net Charts and Graphs Interact with Businesses and Customers
Bar charts, bar graphs, and any other chart or graph used in financial statements, inventory reports, sales reports, and a slew of other types of reports have typically been paper reports or online reports depicting various levels of complex information for tracking, investing, planning, and buying. However, until the .
Are You Waiting for Microsoft Longhorn Operating System
I love new technology. I am still ready to wait long for Longhorn.
? Master records import - you can import via MS CRM integration tool. Tools->Import and select contacts or leads
? Duplication dilemma. In version 1.2 as well as in 3.0 (as far as we know) you do not have duplication check and you can import duplicate leads or contacts.
? MS CRM SDK custom data migration. If data import is critical and you have reasonable budget for the migration - you can appeal to MS CRM customization partner who specializes in the complex data import. In MS CRM SDK you can program duplication check, special rules for security settings. We have to stress here, that this is not one thousand dollars project and if you are small company, you should stick to Scribe or native MS CRM import tool
? Large Scale MS CRM implementation. For corporate business security might have top priority and migration should be programmed in MS CRM SDK.
? Some technical tips. Post-call-outs. In MS CRM 3.0 which should be released in earlier 2006 there are so-called pre-call outs (in version 1.2 we have only post-call-outs). Pre-call-out should allow to check for duplication, based on your duplication recognition criteria and cancel record if it is duplicate contact, account or lead
If you have a need in large scale data import, you can always have us help you with MS CRM SDK data conversion. Give us a call: 866.528.0577 or 1.630.961.598, help@albaspectrum.com
Andrew Karasev is Chief Technology Officer at Alba Spectrum Technologies ( http://www.albaspectrum.com ) - Microsoft Business Solutions Great Plains, Navision, Axapta MS CRM, Oracle Financials and IBM Lotus Domino Partner, serving corporate customers in the following industries: Aerospace & Defense, Medical & Healthcare, Distribution & Logistics, Hospitality, Banking & Finance, Wholesale & Retail, Chemicals, Oil & Gas, Placement & Recruiting, Advertising & Publishing, Textile, Pharmaceutical, Non-Profit, Beverages, Conglomerates, Apparels, Durables, Manufacturing and having locations in multiple states and internationally.
MORE RESOURCES:
RELATED ARTICLES
Daffodil DB: Web Database
What is a Web Database?A web database is a database for the internet. You can get access to your data via the internet from anywhere in the world.
The Death of Windows
I have always regretted how Microsoft price gouges and rips off computer users. I really regret Windows XP activation.
QuarkXpress Tips: How to Move Content Between Print and Web Layouts
Since its release in 1987, QuarkXpress had made an immediate impact to computer enthusiasts. QuarkXPress introduced precision typography, layout and color control to the desktop computer, and delivered those features to designers at a fraction of the cost of proprietary typesetting systems.
A Symons Mark II Function Point Counting Example
I provide, here clear explanations and a count of function points, using the Symons Mark II method.We start by identifying the subprocesses (entry, exit, read, write) for each functional process; The size of a functional process is the sum of its data movements (entry, exit, read, write) and the size of a piece of software is the sum of the sizes of all of its functional processes.
Programming Environments And The Software Production Process
Introduction: The creating of a computer program involves a number of stages which can be made easier with several separate software utilities. There are now integrated set of support programs which combine all the necessary utilities to provide a complete program development environment.
Passwords Used In Microsoft Word Documents
You would like to protect your documents, wouldn't you? Reasons may vary but the problem is the same - you need to protect your Microsoft Word documents from unauthorized editing or viewing. What document protection features does Microsoft® Office Word 2003, a part of Microsoft Office Professional Edition 2003 provide?Microsoft Word features for document protection.
Beware of The Pirated Software E-Mail Scams!
You have gotten those E_Mails buy software at deep discounts. It is very tempting to save 85% to 95% on your favorite Software Titles.
Microsoft Great Plains Installation - Overview for IT Director/Controller
Microsoft Great Plains is main mid-market application from Microsoft Business Solutions. This is short article, written in question/answer/FAQ style to give IT Director/Controller balanced top level information on Microsoft Business Solutions Great Plains implementation.
Databases - How We Love to Hate Them!
You've finally created databases that you can actually use to store and manipulate all your critical data. That's great news and quite an accomplishment.
Groupware and Version History: Collaboration Series #1
This article is the first of a series of articles exploring specific aspects of groupware. The brief informational articles in this series discuss some of the technologies associated with groupware, as well as some of the characteristics of groupware.
OLAP, An Alternative Technology Over Spreadsheets
Are Spreadsheets Robbing your Enterprise of Competitive Advantage?'90% of "average" companies are not confident that their forecasts and reports are accurate and reliable'In a recent study, 81% of FD's cited that their highest priority is the accuracy of revenue and earnings forecasts while 63% complained of inadequate budgeting and forecasting systems .The modern FD is coming under increasing pressure from all sides to produce more robust, meaningful and accurate financial information.
Unwanted Files
A LOT OF UNWANTED FILES.When you uninstall an item of software, there are generally a number of redundant files left behind to clutter up your hard drive.
Groupware Finds Home in American Business: Collaboration Tool Analysis
What is Groupware?Have you ever had to manage document collaboration in a hurry? No need to be ashamed if you said "yes." Virtually every American business has experienced moments of ad hoc team collaboration.
Great Plains Dexterity Customization Options - Overview For Developers
Looks like Microsoft Great Plains becomes more and more popular, partly because of Microsoft muscles behind it. Now it is targeted to the whole spectrum of horizontal and vertical market clientele.
Microsoft Great Plains Furniture & Fixtures - Implementation & Customization Highlights
Microsoft Great Plains, former Great Plains Software Dynamics / eEnterprise was introduced in 1993 as first Microsoft Windows and Macintosh based graphical accounting/ERP application for Mid-Size businesses. Considering the history of furniture retailer and custom assembly lines - they showed up on the market about five decades ago and they have automated their business operations with Unix-based businesses in the late 1960th and earlier 1970th.
Spyware Statistics -- Whats New in May 2005?
Although statistics often is blamed for various deadly sins -- from being biased to being inaccurate -- there is nothing left to those who are anyhow connected with IT but to keep up with fresh data. Since spyware is literally ubiquitous, nobody who owns or uses a PC can say that it is none of his business.
Professional XP Style Icons in Software and Website Development
Using professional icons in your application or website can bring a modern and aesthetically pleasing appearance to your product or service. This will not only help you to attract potential customers but also give you that "edge" you need to stand out from your competitors.
40/sec to 500/sec
IntroductionSurprised, by the title? well, this is a tour of how we cracked the scalability jinx from handling a meagre 40 records per second to 500 records per second. Beware, most of the problems we faced were straight forward, so experienced people might find this superfluous.
.Net Charts and Graphs Interact with Businesses and Customers
Bar charts, bar graphs, and any other chart or graph used in financial statements, inventory reports, sales reports, and a slew of other types of reports have typically been paper reports or online reports depicting various levels of complex information for tracking, investing, planning, and buying. However, until the .
Are You Waiting for Microsoft Longhorn Operating System
I love new technology. I am still ready to wait long for Longhorn.
Subscribe to:
Posts (Atom)
