See also: LiveTemplate, LiveTemplateWritingTips
== Surround With Live Template.==>
1°/ select the text between [ and ], or place the cursor at the | (to select the whole line).
2°/ Press [Ctlr-Alt-J]
before:
File file = ...
[msg += file.toString() ;]
after:
File file = ...
if (null != file){
msg += file.toString() ;
}
To install : insert this snippet into your user.xml.
-- AlainRavet (top)
Before:
Titi|
After:
Titi titi = new Titi()|;
Note:
If the class Titi does not exist yet : press [Alt-Enter].
To use : Press [Alt-Ctrl-J]
To install : insert this snippet into your user.xml.
-- AlainRavet (top)
Before:
String str = cast|
After:
String str = (String) |
To install, simply create template ($TYPE$) $END$, and Edit Variables, specifying the expression expectedValue() for the variable TYPE
I suggest binding this to the Space key, so you type String str = cast value;, which makes sense, since you want value to be casted.
-- KeithLea (top)
A very simple way to know the time spent in some chosen parts of your code.
Accuracy is as good as System.currentTimeMillis() can get.
-- AlainRavet (top)
This is just a simple template to get the page started. It is a simple generic for loop, as opposed to the "built-in" templates which iterate over a given collection or array of objects.
for (int $var$=0; $var$ < $limit$; $var$++)
{
$END$
}
Template code: JonasKvarnstrom-for.xml: Simple for loop template
-- JonasKvarnstrom - 01 Jun 2002 (top)
This iterates through a DOM NodeList, for use when dealing with XML-formatted documents. Make sure to use the XML snippet or set up the variable options appropriately!
for (int $INDEX$ = 0; $INDEX$ < $NODE_LIST$.getLength(); $INDEX$++) {
$ELEMENT_TYPE$ $VAR$ = ($ELEMENT_TYPE$)$NODE_LIST$.item($INDEX$);
$END$
}
Template snippet: WalterMundt-itnl.xml
-- WalterMundt - 11 Jun 2002
An addendum to the above: if you are iterating through the children of a DOM Node, you might be tempted to call node.getChildNodes() to get a NodeList and iterate as above. This is rather inefficient in most DOM implementations; first you pay the cost to create the list, and then you are locked into calling nodeList.item(), which means the whole operation could take you as much as O(n*n). Instead, use the first child and next sibling accessors like so:
for (Node $NODEVAR$ = $PARENTNODE$.getFirstChild(); $NODEVAR$ != null; $NODEVAR$ = $NODEVAR$.getNextSibling()) {
$END$
}
-- OliverS - 19 Mar 2003
before :
String s = "one[two]three" ;
after :
String s = "one"+"two"+"three" ;
| Template text | "+"$SELECTION$$END$"+" |
| Context | Java String |
-- AlainRavet (top)
NOTE: As of build 635, this is now handled internally by IDEA.
before:
String s = "select field1, field2, field3 |from table";
keystroke:
/[Enter]
after:
String s = "select field1, field2, field3 " +
"|from table";
| Template text | " + "$END$ |
| Context | Java String |
| Expand with | Enter |
| Abbreviation | / |
-- BryanYoung (top)
before:
String s = "hello, +|, come in!";
keystroke:
Tab (the '+' activates the template)
after:
String s = "hello," + | + ", come in!";
| Template text | " + $END$ + " |
| Context | Java String |
| Expand with | Tab |
| Abbreviation | + |
-- BenPickering? (top)
See also TestPractices.
public void test_newTestToImplement () {
fail ( "implemente me: test_newTestToImplement " );
}
Template text:
public void test$expr$ () throws Exception {
fail ("implemente me: test$expr$") ;
}
| Context | Java Code |
| Options | Reformat & Shorten |
-- AlainRavet (top)
public static Test suite() {
TestSuite suite= new TestSuite();
add tests to suite here
return suite;
}
Template text:
public static Test suite() {
TestSuite suite= new TestSuite();
$END$
return suite;
}
| Context | Java Code |
| Options | Reformat & Shorten |
-- AlexeyEpishkin (top)
suite.addTest(new MoneyTest("testEquals"));
Template text:
$SUITE$.addTest(new $TEST_CASE$("test$END$"));
| Name | Expression |
| $SUITE$ | variableOfType("junit.framework.TestSuite") |
| $TEST_CASE$ | className() |
| Context | Java Code |
| Options | Reformat & Shorten |
-- AlexeyEpishkin (top)
After creating a class that extends a junit TestCase, use this template, to create the constructor, a static suite method and a static main method. Insert the following xml into your user.xml file.
To install : insert this snippet into your user.xml.
-- BrianMajewski - 10 Jun 2002 (top)
See Also: CanonicizerDoclet
Insert this code snippet in your object and you get "canonical" behavior.
Note that the equals method is not reflexive if used with polymorphic
classes (Joshua Bloch mentioned that in his book)
Feel free to comment
public String toString() {
try {
StringBuffer sb = new StringBuffer(super.toString());
Field[] fields = this.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
sb.append("").append(fields[i].getName()).append("=").append(fields[i].get(this)).append(";");
}
return sb.toString();
} catch (Exception e) {
throw new RuntimeException(e.toString());
}
}
public int hashCode() {
int h = super.hashCode();
try {
Field[] fields = this.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
h = h*37 + fields[i].get(this).hashCode();
}
} catch (Exception e) {
throw new RuntimeException(e.toString());
}
return h;
}
public boolean equals(Object obj) {
if (!super.equals(obj)) return false;
if (!this.getClass().isAssignableFrom(obj.getClass())) return false;
try {
Field[] fields = this.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
if (field.get(this).equals(field.get(obj))) return false;
}
return true;
} catch (Exception e) {
throw new RuntimeException(e.toString());
}
}
-- DimiterD - 03 Jun 2002 (top)
Creation of an EJB remote Home object
This is a one-line LiveTemplate I use to instantiate remote EJB Home objects created by XDoclet (see the XDoclet home page) so I only have to type the type name once.
$TYPE$ $VAR$ = ($TYPE$)PortableRemoteObject.narrow($CONTEXT$.lookup($TYPE$.COMP_NAME), $TYPE$.class);
Options:
- VAR - suggestVariableName()
- TYPE - defaults to "Home"
- CONTEXT - variableOfType("InitialContext"), defaults to "(new InitialContext())"
-- WalterMundt - 03 Jun 2002 (top)
Boilerplate code for a Singleton. The ClassName is derived from the context.
private static ClassName instance = new ClassName();
private ClassName() {
}
public static ClassName getInstance() {
return instance;
}
To install : insert this snippet into your user.xml.
-- BrianMajewski - 10 Jun 2002 (top)
Create add-, remove- and get methods for private Collections.
To install : insert this snippet into your user.xml.
--by JuergenRichtsfeld
Setups an implementation of the listener pattern given an user-defined listener-interface
private List<$ListenerClass$> $listenerClass$s = new ArrayList<$ListenerClass$>();
/** Adds a new listener. */
public void add$ListenerClass$($ListenerClass$ l) {
if (l == null) {
return;
}
$listenerClass$s.add(l);
}
/** Removes a listener. */
public void remove$ListenerClass$($ListenerClass$ l) {
if (l == null) {
return;
}
$listenerClass$s.remove(l);
}
To install : insert this snippet into your user.xml.
--by Watzlaw Wutz
Boilerplate code for a Type-safe Enumeration as an inner class. The Variables are all user-entered.
/**
* This implements a type-safe enum pattern.
* @author <a hr3f="$AUTHOR_EMAIL$">$AUTHOR_NAME$</a>
*/
public static final class $ENUM_NAME$ implements Serializable, Comparable {
private static int nextOrdinal = 0;
private static List TEMP_VALUES = new ArrayList();
// Add all of your enum values here
public static final $ENUM_NAME$ $EXAMPLE1$ = new $ENUM_NAME$("$EXAMPLE1$");
public static final $ENUM_NAME$ $EXAMPLE2$ = new $ENUM_NAME$("$EXAMPLE2$");
public static final $ENUM_NAME$ $EXAMPLE3$ = new $ENUM_NAME$("$EXAMPLE3$");
public static final $ENUM_NAME$ $EXAMPLE4$ = new $ENUM_NAME$("$EXAMPLE4$");
public static final $ENUM_NAME$ $EXAMPLE5$ = new $ENUM_NAME$("$EXAMPLE5$");
// VALUES must be located after all of the enum value declarations
// otherwise the values will only be added to TEMP_VALUES
public static final List VALUES = Collections.unmodifiableList(TEMP_VALUES);
private transient final String name;
public final int ordinal = nextOrdinal++;
/**
* Private contructor for type-safe enumeration
* @param name
*/
private $ENUM_NAME$(String name) {
this.name = name;
TEMP_VALUES.add(this);
}
public String toString() {
return this.name;
}
public int compareTo(Object obj) {
return this.ordinal - (($ENUM_NAME$) obj).ordinal;
}
private static final long serialVersionUID = 0l;
private Object readResolve() throws ObjectStreamException {
return VALUES.get(ordinal);
}
public int getOrdinal(){
return this.ordinal;
}
}
To install : insert this snippet into your user.xml.
-- BrianJackson - 19 Feb 2004 (top)
JSP
This Helper make aesy use of request.getParameter for WEB development
String $NAME$ = request.getParameter("$PARAMETER_NAME$");
$END$
NAME = suggestVariableName()
PARAMETER_NAME = NAME
This Helper make aesy use of request.getParameterValues for WEB development
String[] $NAME$ = request.getParameterValues("$PARAMETER_NAME$");
$END$
NAME = suggestVariableName()
PARAMETER_NAME = NAME
-- AlexeyEfimov - 23 Aug 2002
LOGGING
These helpers make adding a wrapped logging statement easier.
Example for debug:
if($VAR$.isDebugEnabled()) {
$VAR$.debug("");
}
VAR = varableOfType(""), defaults to "log"
-- BrianKrisler - 02 Nov 2002
black jack
internet black jack
online black jack
jack black
free black jack
black jack online
casino poker
online casino poker
bingo casino gambling online poker
casino poker chips
internet casino poker
poker casino game
free poker
free online poker
free poker game
free strip poker
free video poker
free texas holdem poker
full poker tilt
bonus code full poker tilt
freeroll full poker tilt
.net full poker tilt
full poker review tilt
internet poker
internet poker game
internet casino poker
internet poker software
internet poker site
free internet poker
online casino
online casino gambling
best online casino
free online casino
best online casino gambling
online casino review
online casino game
online poker
free online poker
online poker game
online poker rooms
play online poker
online video poker
online poker tournament
pacific poker
888 pacific poker
pacific poker download
pacific poker .com
pacific poker bonus code
pacific poker bonus
paradise poker
paradise poker scam
paradise poker bonus code
paradise poker net
paradise poker .net
paradise poker bonus
party poker
party poker bonus
party poker bonus code
party poker cheat
free party poker
poker party supply
play poker
play online poker
play free poker
play free poker online
learn how to play poker
play video poker
chip poker
chip poker set
chip clay poker
chip custom poker
chip poker trick
casino chip poker
chip poker
chip poker set
chip clay poker
chip custom poker
chip poker trick
casino chip poker
poker hands
winning poker hands
rank poker hands
best poker hands
ranking of poker hands
texas holdem poker hands
poker room
online poker rooms
online poker room review
poker room review
free poker rooms
poker rule
holdem poker rule texas
game poker rule
poker rule tournament
em hold poker rule texas
poker software
party poker cheat software
free poker software
online poker software
internet poker software
poker room software
poker star
poker star net
poker star .net
poker star .com
poker star cheat
poker star download
poker super star
poker table
poker table supply
poker table top
how to build a poker table
poker table plan
poker table for sale
folding poker table
poker tournament
online poker tournament
free poker tournament
free online poker tournament
las vegas poker tournament
poker tournament rule
strip poker
free strip poker
video strip poker
online strip poker
strip poker game
free online strip poker
holdem poker texas
free holdem poker texas
holdem online poker texas
holdem poker rule texas
game holdem poker texas
free game holdem poker texas
video poker
online video poker
free video poker
video strip poker
poker video
video poker game
poker series world
2005 poker series world
2005 poker result series world
game poker series video world
machine slot
free machine slot
free game machine slot
free machine play slot
download machine slot
game machine slot
online slot machine
buy slot machine
buy home slot machine
buy video slot machine
buy used slot machine
buy igt slot machine
buy machine slot where
buy casino slot machine
free machine online slot
free game machine online slot
free machine online play slot
casino free machine online slot
free machine online realistic slot
free machine online slot video
best free machine online slot
free slot machine
free slot machine game
play free slot machine
free casino slot machine game
free online slot machine
free online slot machine game
online slot machine
free online slot machine
play free slot machine
play slot machine
play free slot machine online
play free slot machine game
play slot machine online
best slot machine to play
slot machine for sale
casino slot machine for sale
video slot machine for sale
used slot machine for sale
wheel of fortune slot machine for sale
antique slot machine for sale
casino bonus
online casino bonus
no deposit casino bonus
playtech casino bonus
microgaming casino bonus
free casino game
casino game
free online casino game
online casino game
casino game online
casino gambling
online casino gambling
casino gambling internet online
best casino gambling online
casino gambling internet
sports gambling
sports hueyspicks gambling football
online betting sports gambling
online sports gambling
free gambling
free gambling tip
free gambling money for online casino
free online gambling
gambling online free game
internet gambling
internet casino gambling online
internet casino gambling
internet casion gambling
internet gambling poker
online gambling
online casino gambling
internet casino gambling online
best online casino gambling
online gambling directory
aladdin casino
aladdin hotel and casino
aladdin resort and casino
aladdin hotel and casino las vegas
aladdin casino las vegas
argosy casino
argosy casino indiana
argosy casino kansas city
argosy casino and hotel
argosy casino lawrenceburg indiana
casino foxwoods
casino foxwoods resort
casino ct foxwoods
casino foxwoods hotel
casino foxwoods hotel near
free online casino game
play free casino game online
free online casino slot game
free online casino game craps
casino free gambling game online
mohegan sun casino
mohegan sun casino resort
mohegan sun casino ct
mohegan sun hotel and casino
mohegan sun casino connecticut
casino morongo
morongo casino resort
morongo indian casino
morongo hotel and casino
casino morongo ca
casino niagara
niagara falls casino
seneca niagara casino
niagara fallsview casino
niagara fallsview casino resort
pala casino
pala resort and casino
pala hotel and casino
pala indian casino
pala casino resort and spa
pala casino san diego
casino royale
james bond casino royale
casino royale las vegas
casino royale hotel
casino royale movie
2006 casino royale
free casino game
free online casino game
free casino slot machine game
free casino slot game
play free casino game online
play free casino game
soaring eagle casino
soaring eagle casino and resort
soaring eagle casino michigan
soaring eagle hotel and casino
soaring eagle casino mt pleasant
soaring eagle casino concert
casino windsor
windsor casino hotel
casino windsor canada
windsor ontario casino
casino in windsor canada
address casino windsor
casino winstar
casino oklahoma winstar
casino ok thackerville winstar
casino in oklahoma winstar
casino ok winstar
casino hotel winstar
pechanga casino
pechanga resort and casino
pechanga casino temecula
pechanga hotel and casino
pechanga casino temecula ca