public String getElementName(Object obj) { Element elem = (Element) obj; return elem.getName(); }
public List operate(Object node, String localName, Namespace namespace) { if (node instanceof Element) { return((Element) node).getChildren(localName, namespace); } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (root != null && root.getName().equals(localName) && root.getNamespaceURI().equals(namespace.getURI())) { return Collections.singletonList(root); } else return Collections.EMPTY_LIST; } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; /* else throw new TemplateModelException("_namedChildren can not be applied on " + node.getClass()); */ } }
public List operate(Object node) { if (node instanceof Element) { Element element = (Element) node; return Collections.singletonList(element.getNamespace().getURI() + element.getName()); } else if (node instanceof Attribute) { Attribute attribute = (Attribute) node; return Collections.singletonList(attribute.getNamespace().getURI() + attribute.getName()); } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_cname can not be applied on " + node.getClass()); } }
if (el.getName().equals(localName) == false) { return JaxenConstants.EMPTY_ITERATOR;
@Override void getChildren(Object node, String localName, String namespaceUri, List result) { if (node instanceof Element) { Element e = (Element) node; if (localName == null) { result.addAll(e.getChildren()); } else { result.addAll(e.getChildren(localName, Namespace.getNamespace("", namespaceUri))); } } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (localName == null || (equal(root.getName(), localName) && equal(root.getNamespaceURI(), namespaceUri))) { result.add(root); } } }
public String peekNextChild() { List list = currentElement.getChildren(); if (null == list || list.isEmpty()) { return null; } return decodeNode(((Element) list.get(0)).getName()); }
public String getNodeName() { return decodeNode(currentElement.getName()); }
public String toString() { return ( "[xmlns:" + jdomNamespace.getPrefix() + "=\"" + jdomNamespace.getURI() + "\", element=" + jdomElement.getName() + "]" ); } }
public List<StoreDefinition> readStoreList(Reader input, boolean verifySchema) { try { SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(input); if(verifySchema) { Validator validator = schema.newValidator(); validator.validate(new JDOMSource(doc)); } Element root = doc.getRootElement(); if(!root.getName().equals(STORES_ELMT)) throw new MappingException("Invalid root element: " + doc.getRootElement().getName()); List<StoreDefinition> stores = new ArrayList<StoreDefinition>(); for(Object store: root.getChildren(STORE_ELMT)) stores.add(readStore((Element) store)); for(Object view: root.getChildren(VIEW_ELMT)) stores.add(readView((Element) view, stores)); return stores; } catch(JDOMException e) { throw new MappingException(e); } catch(SAXException e) { throw new MappingException(e); } catch(IOException e) { throw new MappingException(e); } }
public List operate(Object node) { if (node instanceof Element) return Collections.singletonList(((Element) node).getName()); else if (node instanceof Attribute) return Collections.singletonList(((Attribute) node).getName()); else if (node instanceof EntityRef) return Collections.singletonList(((EntityRef) node).getName()); else if (node instanceof ProcessingInstruction) return Collections.singletonList(((ProcessingInstruction) node).getTarget()); else if (node instanceof DocType) return Collections.singletonList(((DocType) node).getPublicID()); else return null; // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) // throw new TemplateModelException("_name can not be applied on " + node.getClass()); } }
public Object exec(List arguments) { Set names = new HashSet(arguments); List list = new LinkedList(nodes); Iterator it = list.iterator(); while (it.hasNext()) { Object node = it.next(); String name = null; if (node instanceof Element) name = ((Element) node).getName(); else if (node instanceof Attribute) name = ((Attribute) node).getName(); else if (node instanceof ProcessingInstruction) name = ((ProcessingInstruction) node).getTarget(); else if (node instanceof EntityRef) name = ((EntityRef) node).getName(); else if (node instanceof DocType) name = ((DocType) node).getPublicID(); if (name == null || !names.contains(name)) it.remove(); } return createNodeListModel(list, namespaces); } }
@SuppressWarnings("unchecked") public Cluster readCluster(Reader input, boolean verifySchema) { try { SAXBuilder builder = new SAXBuilder(false); Document doc = builder.build(input); if(verifySchema) { Validator validator = this.schema.newValidator(); validator.validate(new JDOMSource(doc)); } Element root = doc.getRootElement(); if(!root.getName().equals(CLUSTER_ELMT)) throw new MappingException("Invalid root element: " + doc.getRootElement().getName()); String name = root.getChildText(CLUSTER_NAME_ELMT); List<Zone> zones = new ArrayList<Zone>(); for(Element node: (List<Element>) root.getChildren(ZONE_ELMT)) zones.add(readZone(node)); List<Node> servers = new ArrayList<Node>(); for(Element node: (List<Element>) root.getChildren(SERVER_ELMT)) servers.add(readServer(node)); return new Cluster(name, servers, zones); } catch(JDOMException e) { throw new MappingException(e); } catch(SAXException e) { throw new MappingException(e); } catch(IOException e) { throw new MappingException(e); } }
/** * Loads {@link UserTemplate} objects from the {@link Element}. * * @param element source * @return {@link UserTemplate} list */ @NotNull public static List<UserTemplate> loadTemplates(@NotNull Element element) { final String key = KEY.USER_TEMPLATES.toString(); final List<UserTemplate> list = ContainerUtil.newArrayList(); if (!key.equals(element.getName())) { element = element.getChild(key); } for (Element template : element.getChildren()) { list.add(new UserTemplate( template.getAttributeValue(KEY.USER_TEMPLATES_NAME.toString()), template.getText() )); } return list; }
private void readRequiredEmployeeSizes(NurseRoster nurseRoster, Element coverRequirementsElement) { List<Element> coverRequirementElementList = (List<Element>) coverRequirementsElement.getChildren(); for (Element element : coverRequirementElementList) { if (element.getName().equals("DayOfWeekCover")) { Element dayOfWeekElement = element.getChild("Day"); DayOfWeek dayOfWeek = null; } else if (element.getName().equals("DateSpecificCover")) { Element dateElement = element.getChild("Date"); List<Element> coverElementList = (List<Element>) element.getChildren("Cover"); throw new IllegalArgumentException("Unknown cover entity (" + element.getName() + ").");
@Override String getLocalName(Object node) { if (node instanceof Element) { return ((Element) node).getName(); } if (node instanceof Attribute) { return ((Attribute) node).getName(); } if (node instanceof EntityRef) { return ((EntityRef) node).getName(); } if (node instanceof ProcessingInstruction) { return ((ProcessingInstruction) node).getTarget(); } if (node instanceof DocType) { return ((DocType) node).getElementName(); } return null; }
private void extractPropertyNames(final Element element, final List<String> propertyNames) { if (!"property".equals(element.getName())) { return; } final String value = element.getAttributeValue("value"); if (value == null) { return; } final int propertyStart = value.indexOf("${"); final int propertyEnd = value.indexOf('}'); if (propertyStart >= 0 && propertyEnd >= 0) { final String propertyName = value.substring( propertyStart + 2, propertyEnd); propertyNames.add(propertyName); } }
String[] childrenNames = new String[childCount]; for (int i = 0; i < childCount; i++) { childrenNames[i] = ((Element) children.get(i)).getName();
private void checkActionNode(NodeDef node) throws WorkflowException { try { Element action = XmlUtils.parseXml(node.getConf()); ActionService actionService = Services.get().get(ActionService.class); boolean supportedAction = actionService.hasActionType(action.getName()); if (!supportedAction) { throw new WorkflowException(ErrorCode.E0723, node.getName(), action.getName()); } } catch (JDOMException ex) { throw new WorkflowException(ErrorCode.E0700, "JDOMException: " + ex.getMessage()); } }