List of usage examples for org.dom4j Element attribute
Attribute attribute(QName qName);
From source file:net.unicon.academus.apps.SsoEntrySimple.java
License:Open Source License
public static SsoEntry parse(Element e) { // Assertions. if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); }//from w ww .j a v a2s .c o m if (!e.getName().equals("sso-entry")) { String msg = "Argument 'e [Element]' must be an <sso-entry> " + "element."; throw new IllegalArgumentException(msg); } // Handle. Attribute h = e.attribute("handle"); if (h == null) { String msg = "Element <sso-entry> is missing required attribute 'handle'."; throw new IllegalArgumentException(msg); } String handle = h.getValue(); // Label. Element b = (Element) e.selectSingleNode("label"); if (b == null) { String msg = "Element <sso-entry> is missing required child element <label>."; throw new IllegalArgumentException(msg); } String label = b.getText(); // Description. Element d = (Element) e.selectSingleNode("description"); if (d == null) { String msg = "Element <sso-entry> is missing required child element <description>."; throw new IllegalArgumentException(msg); } String description = d.getText(); // Window. Element w = (Element) e.selectSingleNode("window"); if (w == null) { String msg = "Element <sso-entry> is missing required child element <window>."; throw new IllegalArgumentException(msg); } String window = w.asXML(); // UIClass. Attribute c = e.attribute("class"); if (c == null) { String msg = "Element <target> is missing required attribute 'class'."; throw new IllegalArgumentException(msg); } String uiClass = c.getValue(); // Authentication. Element a = (Element) e.selectSingleNode("authentication"); SsoAuthentication authentication = null; if (a != null) { authentication = SsoAuthentication.parse(a); } // map of all targets Map targets = new HashMap(); for (Iterator it = e.selectNodes("target").iterator(); it.hasNext();) { SsoTarget r = SsoTarget.parse((Element) it.next()); targets.put(r.getHandle(), r); } // Sequences Map sequences = new HashMap(); for (Iterator it = e.selectNodes("sequence").iterator(); it.hasNext();) { Element s = (Element) it.next(); SsoSequence seq = SsoSequence.parse(s); sequences.put(seq.getType(), seq); } return new SsoEntrySimple(handle, label, description, window, uiClass, authentication, targets, sequences); }
From source file:net.unicon.academus.apps.SsoSequenceLegacy.java
License:Open Source License
public static SsoSequence parse(Element e) { // Assertions. if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); }/*from w w w .j a va 2s . c o m*/ if (!e.getName().equals("sequence")) { String msg = "Argument 'e [Element]' must be a <sequence> element."; throw new IllegalArgumentException(msg); } // Type. Attribute y = e.attribute("type"); if (y == null) { String msg = "Element <sequence> is missing required attribute 'type'."; throw new IllegalArgumentException(msg); } String type = y.getValue(); // ButtonXml. String buttonXml = ""; Element b = (Element) e.selectSingleNode("sequence-start-trigger"); if (b != null) { buttonXml = b.asXML(); } // TargetIds. List list = e.selectNodes("target"); String[] targetIds = new String[list.size()]; for (int i = 0; i < list.size(); i++) { Element r = (Element) list.get(i); Attribute h = r.attribute("handle"); if (h == null) { String msg = "Element <target> is missing required attribute 'handle'."; throw new IllegalArgumentException(msg); } targetIds[i] = h.getValue(); } return new SsoSequenceLegacy(type, targetIds, buttonXml); }
From source file:net.unicon.academus.apps.SsoTargetSimple.java
License:Open Source License
public static SsoTarget parse(Element e) { // Assertions. if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); }/* w w w. j a v a 2 s. c om*/ if (!e.getName().equals("target")) { String msg = "Argument 'e [Element]' must be a <target> element."; throw new IllegalArgumentException(msg); } // Handle. Attribute h = e.attribute("handle"); if (h == null) { String msg = "Element <target> is missing required attribute 'handle'."; throw new IllegalArgumentException(msg); } String handle = h.getValue(); // Method. Element m = (Element) e.selectSingleNode("method"); if (m == null) { String msg = "Element <target> is missing required child element <method>."; throw new IllegalArgumentException(msg); } String method = m.getText(); // Url. Element u = (Element) e.selectSingleNode("url"); if (u == null) { String msg = "Element <target> is missing required child element <url>."; throw new IllegalArgumentException(msg); } String url = u.getText(); // Parameters & Evaluators. Map params = new HashMap(); Map evaluators = new HashMap(); for (Iterator it = e.selectNodes("parameter").iterator(); it.hasNext();) { Element p = (Element) it.next(); String key = p.attribute("name").getValue(); String val = null; if (p.element("evaluate") != null) { try { String evauluatorImpl = p.element("evaluate").attributeValue("evauluatorImpl"); //map evaluator to parameter key evaluators.put(key, evauluatorImpl); //get parameter value val = p.selectSingleNode("evaluate").getStringValue(); } catch (Exception ex) { throw new RuntimeException("Problem instantiating IAttributeEvaluator for " + p.selectSingleNode("evaluate").getStringValue(), ex); } } else { val = p.selectSingleNode("value").getText(); } params.put(key, val); } // Evaluators. return new SsoTargetSimple(handle, method, url, params, evaluators); }
From source file:net.unicon.academus.civisselector.AddToSelBasketAction.java
License:Open Source License
public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException { // Assertions. if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); }// w w w . j a va 2 s.c o m if (!e.getName().equals("action")) { String msg = "Argument 'e [Element]' must be an <action> element."; throw new IllegalArgumentException(msg); } if (owner == null) { String msg = "Argument 'owner+' cannot be null."; throw new IllegalArgumentException(msg); } // Handle. Attribute h = e.attribute("handle"); if (h == null) { String msg = "Element <action> is missing required attribute " + "'handle'."; throw new XmlFormatException(msg); } Handle handle = Handle.create(h.getValue()); // ToScreen. Attribute s = e.attribute("to-screen"); if (s == null) { String msg = "Element <action> is missing required attribute " + "'to-screen'."; throw new XmlFormatException(msg); } String toScreen = s.getValue(); // Choices. String[] choices = new String[0]; Attribute p = e.attribute("inpt"); if (p != null) { StringTokenizer tokens = new StringTokenizer(p.getValue(), ","); choices = new String[tokens.countTokens()]; for (int i = 0; tokens.hasMoreTokens(); i++) { choices[i] = tokens.nextToken(); } } return new AddToSelBasketAction(owner, handle, choices, toScreen); }
From source file:net.unicon.academus.civisselector.CancelBasketAction.java
License:Open Source License
public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException { // Assertions. if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); }/*from w ww. j av a 2 s . c o m*/ if (!e.getName().equals("action")) { String msg = "Argument 'e [Element]' must be an <action> element."; throw new IllegalArgumentException(msg); } if (owner == null) { String msg = "Argument 'owner+' cannot be null."; throw new IllegalArgumentException(msg); } // Handle. Attribute h = e.attribute("handle"); if (h == null) { String msg = "Element <action> is missing required attribute " + "'handle'."; throw new XmlFormatException(msg); } Handle handle = Handle.create(h.getValue()); // Choices. String[] choices = new String[0]; Attribute p = e.attribute("inpt"); if (p != null) { StringTokenizer tokens = new StringTokenizer(p.getValue(), ","); choices = new String[tokens.countTokens()]; for (int i = 0; tokens.hasMoreTokens(); i++) { choices[i] = tokens.nextToken(); } } return new CancelBasketAction(owner, handle, choices); }
From source file:net.unicon.academus.civisselector.CloseSearchResults.java
License:Open Source License
public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException { // Assertions. if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); }//from w ww . ja v a2 s . c om if (!e.getName().equals("action")) { String msg = "Argument 'e [Element]' must be an <action> element."; throw new IllegalArgumentException(msg); } if (owner == null) { String msg = "Argument 'owner+' cannot be null."; throw new IllegalArgumentException(msg); } // Handle. Attribute h = e.attribute("handle"); if (h == null) { String msg = "Element <action> is missing required attribute " + "'handle'."; throw new XmlFormatException(msg); } Handle handle = Handle.create(h.getValue()); // Choices. String[] choices = new String[0]; Attribute p = e.attribute("inpt"); if (p != null) { StringTokenizer tokens = new StringTokenizer(p.getValue(), ","); choices = new String[tokens.countTokens()]; for (int i = 0; tokens.hasMoreTokens(); i++) { choices[i] = tokens.nextToken(); } } return new CloseSearchResults(owner, handle, choices); }
From source file:net.unicon.academus.civisselector.CloseSelBasketAction.java
License:Open Source License
public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException { // Assertions. if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); }/* w w w . ja va 2 s .co m*/ if (!e.getName().equals("action")) { String msg = "Argument 'e [Element]' must be an <action> element."; throw new IllegalArgumentException(msg); } if (owner == null) { String msg = "Argument 'owner+' cannot be null."; throw new IllegalArgumentException(msg); } // Handle. Attribute h = e.attribute("handle"); if (h == null) { String msg = "Element <action> is missing required attribute " + "'handle'."; throw new XmlFormatException(msg); } Handle handle = Handle.create(h.getValue()); // Choices. String[] choices = new String[0]; Attribute p = e.attribute("inpt"); if (p != null) { StringTokenizer tokens = new StringTokenizer(p.getValue(), ","); choices = new String[tokens.countTokens()]; for (int i = 0; tokens.hasMoreTokens(); i++) { choices[i] = tokens.nextToken(); } } return new CloseSelBasketAction(owner, handle, choices); }
From source file:net.unicon.academus.civisselector.GoToGroupAction.java
License:Open Source License
public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException { // Assertions. if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); }//from w w w .j a v a 2 s.co m if (!e.getName().equals("action")) { String msg = "Argument 'e [Element]' must be an <action> element."; throw new IllegalArgumentException(msg); } if (owner == null) { String msg = "Argument 'owner+' cannot be null."; throw new IllegalArgumentException(msg); } // Handle. Attribute h = e.attribute("handle"); if (h == null) { String msg = "Element <action> is missing required attribute " + "'handle'."; throw new XmlFormatException(msg); } Handle handle = Handle.create(h.getValue()); // Choices. String[] choices = new String[0]; Attribute p = e.attribute("inpt"); if (p != null) { StringTokenizer tokens = new StringTokenizer(p.getValue(), ","); choices = new String[tokens.countTokens()]; for (int i = 0; tokens.hasMoreTokens(); i++) { choices[i] = tokens.nextToken(); } } return new GoToGroupAction(owner, handle, choices); }
From source file:net.unicon.academus.civisselector.GoUpGroupAction.java
License:Open Source License
public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException { // Assertions. if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); }//from ww w . j a v a2 s . c o m if (!e.getName().equals("action")) { String msg = "Argument 'e [Element]' must be an <action> element."; throw new IllegalArgumentException(msg); } if (owner == null) { String msg = "Argument 'owner+' cannot be null."; throw new IllegalArgumentException(msg); } // Handle. Attribute h = e.attribute("handle"); if (h == null) { String msg = "Element <action> is missing required attribute " + "'handle'."; throw new XmlFormatException(msg); } Handle handle = Handle.create(h.getValue()); // Choices. String[] choices = new String[0]; Attribute p = e.attribute("inpt"); if (p != null) { StringTokenizer tokens = new StringTokenizer(p.getValue(), ","); choices = new String[tokens.countTokens()]; for (int i = 0; tokens.hasMoreTokens(); i++) { choices[i] = tokens.nextToken(); } } return new GoUpGroupAction(owner, handle, choices); }
From source file:net.unicon.academus.civisselector.RemoveFromSelBasketAction.java
License:Open Source License
public static IAction parse(Element e, IWarlockFactory owner) throws WarlockException { // Assertions. if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); }//w w w . ja va 2 s. c o m if (!e.getName().equals("action")) { String msg = "Argument 'e [Element]' must be an <action> element."; throw new IllegalArgumentException(msg); } if (owner == null) { String msg = "Argument 'owner+' cannot be null."; throw new IllegalArgumentException(msg); } // Handle. Attribute h = e.attribute("handle"); if (h == null) { String msg = "Element <action> is missing required attribute " + "'handle'."; throw new XmlFormatException(msg); } Handle handle = Handle.create(h.getValue()); // ToScreen. Attribute s = e.attribute("to-screen"); if (s == null) { String msg = "Element <action> is missing required attribute " + "'to-screen'."; throw new XmlFormatException(msg); } String toScreen = s.getValue(); // Choices. String[] choices = new String[0]; Attribute p = e.attribute("inpt"); if (p != null) { StringTokenizer tokens = new StringTokenizer(p.getValue(), ","); choices = new String[tokens.countTokens()]; for (int i = 0; tokens.hasMoreTokens(); i++) { choices[i] = tokens.nextToken(); } } return new RemoveFromSelBasketAction(owner, handle, choices, toScreen); }