Monday, October 14, 2013

Using eclipse shorcut!



Why do we often use shortcut key during programming?
It maybe reduce the time of coding and reduce mistake.

It is not necessary to make use of shortcut, but we have to know essential shortcut.

Blue are often used.  

단축키
설명
F3 Open Declaration: Jump to Declaration of selected class, method, or parameter
[Ctrl + Mouse Click is the same]
F4 Open Type Hierarchy window for selected item
F5 Step Into function in debug
F6 Next step (line by line) in debug
F7 Step out in debug
F8 Skip to next Breakpoint in debug
F11 Debug 
F12 Jump to Editor Window
Ctrl + 1 Open Quick Fix and Quick Assist
Ctrl + 7 Comment / uncomment line or selection ( adds '//' )
Ctrl + . (next)
Ctrl + , (previous)
Jump to next / jump to previous compiler syntax warning or error
Ctrl + Space Opens Content Assist (e.g. show available methods or field names)
Ctrl + T Show / open Quick Type Hierarchy for selected item
Ctrl + O Show code outline / structure
Ctrl + L Jump to Line Number. To hide/show line numbers, press ctrl+F10 and select 'Show Line Numbers'
Ctrl + F Open find and replace dialog
Ctrl + J
Ctrl + Shift + J
Incremental search forward / backward. Type search term after pressing ctrl+j, there is now search window
Ctrl + K
Ctrl + Shift + K
Find previous / find next occurrence of search term (close find window first)
Ctrl + H Search Workspace (Java Search, Task Search, and File Search)
Ctrl + F6 Show list of open Editors. Similar to ctrl+e but switches immediately upon release of ctrl
Ctrl + F7
Ctrl + Shift + F7
Switch forward / backward between views (panels). Useful for switching back and forth between Package Explorer and Editor.
Ctrl + F8
Ctrl + Shift + F8
Switch forward / backward between perspectives
Ctrl + F11 Save and launch application (run)
Ctrl + Shft + F Autoformat all code in Editor using code formatter
Ctrl + Shift + O Remove unnecessary import declare
Ctrl + Alt + H Open Call Hierarchy
Alt + Enter Show and access file properties
Alt + Arrow Left
Alt + Arrow Right
Go to previous / go to next Editor Window
Alt + Shift + R Rename selected element and all references
Alt + Shift + M Extract selection to method

Sunday, October 6, 2013

The Code that remove HTML tag using regular expression



I need some source code that extract text from HTML.
Using regular expression it is very simple.

It removes scripts, style, tags, entities, and whitespace.

 private String getText(String content) {  
      Pattern SCRIPTS = Pattern.compile("<(no)?script[^>]*>.*?</(no)?script>",Pattern.DOTALL);  
      Pattern STYLE = Pattern.compile("<style[^>]*>.*</style>",Pattern.DOTALL);  
      Pattern TAGS = Pattern.compile("<(\"[^\"]*\"|\'[^\']*\'|[^\'\">])*>");  
      Pattern nTAGS = Pattern.compile("<\\w+\\s+[^<]*\\s*>");  
      Pattern ENTITY_REFS = Pattern.compile("&[^;]+;");  
      Pattern WHITESPACE = Pattern.compile("\\s\\s+");  
        
      Matcher m;  
        
      m = SCRIPTS.matcher(content);  
      content = m.replaceAll("");  
      m = STYLE.matcher(content);  
      content = m.replaceAll("");  
      m = TAGS.matcher(content);  
      content = m.replaceAll("");  
      m = ENTITY_REFS.matcher(content);  
      content = m.replaceAll("");  
      m = WHITESPACE.matcher(content);  
      content = m.replaceAll(" ");             
        
      return content;  
 }  

If you are interested, please try to test it.