implemented containsMacro() function
This commit is contained in:
parent
6e65ecd242
commit
abed17f2e9
1 changed files with 28 additions and 0 deletions
|
@ -37,6 +37,9 @@ public class Skin {
|
||||||
parse (content);
|
parse (content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a skin object from source text
|
||||||
|
*/
|
||||||
public void parse (String content) {
|
public void parse (String content) {
|
||||||
|
|
||||||
this.source = content;
|
this.source = content;
|
||||||
|
@ -68,10 +71,16 @@ public class Skin {
|
||||||
parts = partBuffer.toArray ();
|
parts = partBuffer.toArray ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the raw source text this skin was parsed from
|
||||||
|
*/
|
||||||
public String getSource () {
|
public String getSource () {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render this skin
|
||||||
|
*/
|
||||||
public void render (RequestEvaluator reval, ESObject thisObject, ESObject paramObject) throws RedirectException {
|
public void render (RequestEvaluator reval, ESObject thisObject, ESObject paramObject) throws RedirectException {
|
||||||
|
|
||||||
if (parts == null)
|
if (parts == null)
|
||||||
|
@ -95,6 +104,25 @@ public class Skin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a certain macro is present in this skin. The macro name is in handler.name notation
|
||||||
|
*/
|
||||||
|
public boolean containsMacro (String macroname) {
|
||||||
|
for (int i=0; i<parts.length; i++) {
|
||||||
|
if (parts[i] instanceof Macro) {
|
||||||
|
Macro m = (Macro) parts[i];
|
||||||
|
String mname = null;
|
||||||
|
if (m.handler == null)
|
||||||
|
mname = m.name;
|
||||||
|
else
|
||||||
|
mname = m.handler+"."+m.name;
|
||||||
|
if (macroname.equals (mname))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static final int HANDLER = 0;
|
static final int HANDLER = 0;
|
||||||
static final int MACRO = 1;
|
static final int MACRO = 1;
|
||||||
static final int PARAMNAME = 2;
|
static final int PARAMNAME = 2;
|
||||||
|
|
Loading…
Add table
Reference in a new issue