svn-gvsig-desktop / trunk / libraries / libGDBMS / src / com / hardcode / gdbms / engine / instruction / LikeClauseAdapter.java @ 466
History | View | Annotate | Download (1.06 KB)
1 |
/*
|
---|---|
2 |
* Created on 12-oct-2004
|
3 |
*/
|
4 |
package com.hardcode.gdbms.engine.instruction; |
5 |
|
6 |
import com.hardcode.gdbms.parser.Node; |
7 |
|
8 |
|
9 |
/**
|
10 |
* Adaptador
|
11 |
*
|
12 |
* @author Fernando Gonz?lez Cort?s
|
13 |
*/
|
14 |
public class LikeClauseAdapter extends Adapter { |
15 |
private String pattern; |
16 |
private boolean negated = false; |
17 |
|
18 |
/**
|
19 |
* Obtiene el patron del like
|
20 |
*
|
21 |
* @return String
|
22 |
*/
|
23 |
public String getPattern() { |
24 |
return pattern;
|
25 |
} |
26 |
|
27 |
/**
|
28 |
* Obtiene si es LIKE o NOT LIKE
|
29 |
*
|
30 |
* @return si se usa NOT devuelve true, false en caso contrario
|
31 |
*/
|
32 |
public boolean isNegated() { |
33 |
return negated;
|
34 |
} |
35 |
|
36 |
/**
|
37 |
* @see com.hardcode.gdbms.engine.instruction.Adapter#setEntity(com.hardcode.gdbms.parser.Node)
|
38 |
*/
|
39 |
public void setEntity(Node o) { |
40 |
super.setEntity(o);
|
41 |
|
42 |
String text = Utilities.getText(getEntity()); |
43 |
pattern = text.substring(0, text.lastIndexOf("'")); |
44 |
pattern = pattern.substring(pattern.lastIndexOf("'") + 1); |
45 |
|
46 |
if (text.trim().startsWith("not")) { |
47 |
negated = true;
|
48 |
} |
49 |
} |
50 |
} |