public class BucketHelper {
public static Bucket fromOM(OMElement bucketElement) throws CEPConfigurationException {
Bucket bucket = new Bucket();
String name =
bucketElement.getAttributeValue(new QName(CEPConstants.CEP_CONF_ATTR_NAME));
bucket.setName(name);
OMElement descriptionElement =
bucketElement.getFirstChildWithName(new QName(CEPConstants.CEP_CONF_NAMESPACE,
CEPConstants.CEP_CONF_ELE_DESCRIPTION));
if (descriptionElement != null) {
bucket.setDescription(descriptionElement.getText());
}
String engineProvider =
bucketElement.getAttributeValue(
new QName(CEPConstants.CEP_CONF_ATTR_ENGINE_PROVIDER));
bucket.setEngineProvider(engineProvider);
OMElement inputOmElement = null;
for (Iterator iter = bucketElement.getChildrenWithName(new QName(CEPConstants.CEP_CONF_NAMESPACE,
CEPConstants.CEP_CONF_ELE_INPUT)); iter.hasNext();) {
inputOmElement = (OMElement) iter.next();
bucket.addInput(InputHelper.fromOM(inputOmElement));
}
OMElement queryOmElement = null;
for (Iterator iterator = bucketElement.getChildrenWithName(new QName(CEPConstants.CEP_CONF_NAMESPACE,
CEPConstants.CEP_CONF_ELE_QUERY)); iterator.hasNext();) {
queryOmElement = (OMElement) iterator.next();
bucket.addQuery(QueryHelper.fromOM(queryOmElement));
}
return bucket;