20 package net.sf.gridarta.plugin;
30 import nu.xom.Attribute;
31 import nu.xom.Element;
32 import nu.xom.Elements;
33 import nu.xom.ParentNode;
35 import org.apache.log4j.Category;
36 import org.apache.log4j.Logger;
37 import org.jetbrains.annotations.NotNull;
56 private static final String
FILTER =
"filter";
62 private static final String
BASH =
"bash";
93 boolean isAutoBoot =
false;
94 boolean isFilter =
false;
95 boolean isScript =
false;
96 final Elements modeElements = node.getChildElements(
"mode");
97 if (modeElements.size() == 0) {
100 for (
final Element modeChild :
new ElementsIterable(modeElements.get(0).getChildElements())) {
101 final boolean value = Boolean.valueOf(modeChild.getValue());
102 final String
name = modeChild.getLocalName();
105 }
else if (
name.equalsIgnoreCase(
FILTER) && value) {
107 }
else if (
name.equalsIgnoreCase(
BASH) && value) {
115 for (
final Element parameter :
new ElementsIterable(node.getChildElements(
"parameter"))) {
120 LOG.warn(
"Parameter type " + ex.getMessage() +
" in plugin " + pluginModel +
" is unknown");
136 final Element root =
new Element(
"script");
137 final Element
name =
new Element(
"name");
138 final Element code =
new Element(
"code");
139 name.appendChild(plugin.getName());
140 code.appendChild(
new Text(plugin.getCode()));
141 code.addAttribute(
new Attribute(
"xml:space",
"http://www.w3.org/XML/1998/namespace",
"preserve"));
142 root.appendChild(
name);
143 root.appendChild(code);
144 final ParentNode modes =
new Element(
"mode");
146 final Element autoBoot =
new Element(
AUTO_BOOT);
147 autoBoot.appendChild(Boolean.toString(plugin.isAutoBoot()));
148 final Element bash =
new Element(
BASH);
149 bash.appendChild(Boolean.toString(plugin.isScript()));
150 final Element filter =
new Element(
FILTER);
151 filter.appendChild(Boolean.toString(plugin.isFilter()));
152 modes.appendChild(autoBoot);
153 modes.appendChild(bash);
154 modes.appendChild(filter);
156 root.appendChild(modes);
158 root.appendChild(plugin.toXML(pluginParameter));