A complete standalone example of ASTParser

This example belongs to Eclipse JDT Tutorial Series. Normally, Eclipse JDT is used in a plug-in environment. This is the normal situation in which we deal with each project in the workspace. However, if we want to parse a large amount of java file, this approach may not be good, since it is not easy … Read more

Regular Expression: exclude a word/string

If you want to exclude a certain word/string in a search pattern, a good way to do this is regular expression assertion function. It is indispensable if you want to match something not followed by something else. A Simple Example String str = "programcreek"; Pattern p = Pattern.compile(".*program(?=creek).*"); Matcher m = p.matcher(str);   if(m.matches()){ System.out.println("Match!"); … Read more

Lisp Code: Add two list

Can we have a function that can add two list to one, such as (add ‘(1 2 3) ‘(4 5 6)) = (5 7 9)

(defun add-two-list (l r)
; e.g. (1 2 3) (2 3 4)
; returns (3 5 7)
  (setf return-value '())
  (loop for i from 0 to (- (length l) 1)
        do (setf return-value (cons (+ (nth i l) (nth i r)) return-value))
)
 (reverse return-value)
)

Read more

Put a Table/Figure/Equation at the right position

Just add h after begin tag. As simple as it is. H here means Place the float here, i.e., at the same point it occurs in the source text. begin{table}[h] center begin{tabular}{|l|l|}   hline multicolumn{2}{|c|}{Schedule of This Week} hline Monday & SigNEW Tuesday & Artificial Intelligence, Compiler Wednesday & Research Meeting Thursday & Artificial Intelligence, … Read more

Add A File Chooser/Selector for Eclipse RCP Development

File chooser or Directory choose is a common module when file processing is involved in a GUI application. This article use an example to illustrate how to use file chooser/directory chooser under Eclipse RCP, and gives the source code which can be used directly. Under Eclipse RCP, the implementation is simple and the usage is … Read more

Sort content in a txt file

If you have a file with come words or terms on each line, you may want to sort it. Java Arrays.sort is common nice function to do this. Collections.sort() is another nice say. Here is an example and code.
E.G. in a file, you have the following txt.

dog 
cat
--windows
--kankan
pps
game
--annot be guaranteed 
as it is, generally speaking, 
--impossible to make any hard gu
arantees in the p
--resence of unsynchr

Read more

A raw idea of making good reseach in Software Engineering area

Software Maintenance is an important subarea of Software Engineering. Researches in this area have produced a lot of amazing discoveries which are being used in software industry. Not just in the software industry, but many web applications that are SEO-optimised (through vendors like spamzilla.io) make use of this area of software engineering. Why the maintenance part is so important and so hard? There may be a bunch of answers for this question, such as requirement analysis problem, design problem, each programmer’s programming style, etc.

Read more

Plug-in Mechanism of Eclipse

Eclipse platform is built on OSGi framework. Eclipse Plugin framework is pretty complex. However, the general ideas behind is very simple. In this post, the simple idea of how a plugin works is explained by using a diagram. Then a simple Eclipse Plugin is created to explain how to add a menu item to menu … Read more

Eclipse: java.lang.UnsupportedClassVersionError: Bad version number in .class file

While programming for a small project under Eclipse IDE, I got the following error message: java.lang.UnsupportedClassVersionError: Bad version number in .class file The problem is the compilation JRE and running JRE are not the same. So we need to make them the same version, e.g. 1.6. There also might be the JRE library in your … Read more