/** * Returns the number of child elements present on this element. * @return number of elements. */ public int getElementCount() { int elementCount = 0; if (state.elements != null) { for (Object elementValue : state.elements.values()) { if (elementValue instanceof Collection) { elementCount += (castElementCollection(elementValue)).size(); } else { elementCount++; } } } return elementCount; }
/** * Returns the number of child elements present on this element. * @return number of elements. */ public int getElementCount() { int elementCount = 0; if (state.elements != null) { for (Object elementValue : state.elements.values()) { if (elementValue instanceof Collection) { elementCount += (castElementCollection(elementValue)).size(); } else { elementCount++; } } } return elementCount; }
/** * Returns the number of child elements present on this element. * @return number of elements. */ public int getElementCount() { int elementCount = 0; if (state.elements != null) { for (Object elementValue : state.elements.values()) { if (elementValue instanceof Collection) { elementCount += (castElementCollection(elementValue)).size(); } else { elementCount++; } } } return elementCount; }
/** * Returns an immutable list of elements matching the given id. */ public List<Element> getElements(QName id) { // children, and if so add all of the wrapper junk we deal with in Multimap. ImmutableList.Builder<Element> builder = ImmutableList.builder(); Object obj = getElementObject(id); if (obj != null) { if (obj instanceof Element) { builder.add((Element) obj); } else { for (Element e : castElementCollection(obj)) { builder.add(e); } } } return builder.build(); }
/** * Get child elements matching the specified id. This set cannot be used * to add new child elements, instead the {@link #addElement(Element)} method * should be used. */ public Set<Element> getElementSet(QName id) { // children, and if so add all of the wrapper junk we deal with in Multimap. ImmutableSet.Builder<Element> builder = ImmutableSet.builder(); Object obj = getElementObject(id); if (obj != null) { if (obj instanceof Element) { builder.add((Element) obj); } else { for (Element e : castElementCollection(obj)) { builder.add(e); } } } return builder.build(); }
/** * Returns an immutable list of elements matching the given id. */ public List<Element> getElements(QName id) { // children, and if so add all of the wrapper junk we deal with in Multimap. ImmutableList.Builder<Element> builder = ImmutableList.builder(); Object obj = getElementObject(id); if (obj != null) { if (obj instanceof Element) { builder.add((Element) obj); } else { for (Element e : castElementCollection(obj)) { builder.add(e); } } } return builder.build(); }
/** * Returns an immutable list of elements matching the given id. */ public List<Element> getElements(QName id) { // children, and if so add all of the wrapper junk we deal with in Multimap. ImmutableList.Builder<Element> builder = ImmutableList.builder(); Object obj = getElementObject(id); if (obj != null) { if (obj instanceof Element) { builder.add((Element) obj); } else { for (Element e : castElementCollection(obj)) { builder.add(e); } } } return builder.build(); }
/** * Get child elements matching the specified id. This set cannot be used * to add new child elements, instead the {@link #addElement(Element)} method * should be used. */ public Set<Element> getElementSet(QName id) { // children, and if so add all of the wrapper junk we deal with in Multimap. ImmutableSet.Builder<Element> builder = ImmutableSet.builder(); Object obj = getElementObject(id); if (obj != null) { if (obj instanceof Element) { builder.add((Element) obj); } else { for (Element e : castElementCollection(obj)) { builder.add(e); } } } return builder.build(); }
/** * Get child elements matching the specified id. This set cannot be used * to add new child elements, instead the {@link #addElement(Element)} method * should be used. */ public Set<Element> getElementSet(QName id) { // children, and if so add all of the wrapper junk we deal with in Multimap. ImmutableSet.Builder<Element> builder = ImmutableSet.builder(); Object obj = getElementObject(id); if (obj != null) { if (obj instanceof Element) { builder.add((Element) obj); } else { for (Element e : castElementCollection(obj)) { builder.add(e); } } } return builder.build(); }
for (Element e : castElementCollection(obj)) { if (childType.isInstance(e)) { builder.add(childType.cast(e));
for (Element e : castElementCollection(obj)) { if (childType.isInstance(e)) { builder.add(childType.cast(e));
for (Element e : castElementCollection(obj)) { if (childType.isInstance(e)) { builder.add(childType.cast(e));
for (Element e : castElementCollection(obj)) { if (childType.isInstance(e)) { builder.add(childType.cast(e));
/** * This method just returns the bare object stored in the map, or null if * either the map didn't contain the object or the map is null. */ private Object getElementObject(QName id) { if (state.elements == null) { return null; } if ("*".equals(id.getLocalName())) { XmlNamespace ns = id.getNs(); if (ns != null) { String uri = ns.getUri(); ImmutableList.Builder<Element> builder = ImmutableList.builder(); for (Map.Entry<QName, Object> entry : state.elements.entrySet()) { QName key = entry.getKey(); XmlNamespace keyNs = key.getNs(); if (keyNs != null && uri.equals(keyNs.getUri())) { Object value = entry.getValue(); if (value instanceof Element) { builder.add((Element) value); } else { builder.addAll(castElementCollection(value)); } } } return builder.build(); } } return state.elements.get(id); }
/** * This method just returns the bare object stored in the map, or null if * either the map didn't contain the object or the map is null. */ private Object getElementObject(QName id) { if (state.elements == null) { return null; } if ("*".equals(id.getLocalName())) { XmlNamespace ns = id.getNs(); if (ns != null) { String uri = ns.getUri(); ImmutableList.Builder<Element> builder = ImmutableList.builder(); for (Map.Entry<QName, Object> entry : state.elements.entrySet()) { QName key = entry.getKey(); XmlNamespace keyNs = key.getNs(); if (keyNs != null && uri.equals(keyNs.getUri())) { Object value = entry.getValue(); if (value instanceof Element) { builder.add((Element) value); } else { builder.addAll(castElementCollection(value)); } } } return builder.build(); } } return state.elements.get(id); }
/** * This method just returns the bare object stored in the map, or null if * either the map didn't contain the object or the map is null. */ private Object getElementObject(QName id) { if (state.elements == null) { return null; } if ("*".equals(id.getLocalName())) { XmlNamespace ns = id.getNs(); if (ns != null) { String uri = ns.getUri(); ImmutableList.Builder<Element> builder = ImmutableList.builder(); for (Map.Entry<QName, Object> entry : state.elements.entrySet()) { QName key = entry.getKey(); XmlNamespace keyNs = key.getNs(); if (keyNs != null && uri.equals(keyNs.getUri())) { Object value = entry.getValue(); if (value instanceof Element) { builder.add((Element) value); } else { builder.addAll(castElementCollection(value)); } } } return builder.build(); } } return state.elements.get(id); }
/** * Locks this element. A locked element cannot have any changes made to its * content or its attributes or child elements. This will also lock all * attributes and child elements as well. Once this method has been called, * this element can be safely published to other threads. */ public Element lock() { state.locked = true; if (state.attributes != null) { for (Attribute att : state.attributes.values()) { att.lock(); } } if (state.elements != null) { for (Object childObj : state.elements.values()) { if (childObj instanceof Element) { ((Element) childObj).lock(); } else { for (Element child : castElementCollection(childObj)) { child.lock(); } } } } return this; }
/** * Locks this element. A locked element cannot have any changes made to its * content or its attributes or child elements. This will also lock all * attributes and child elements as well. Once this method has been called, * this element can be safely published to other threads. */ public Element lock() { state.locked = true; if (state.attributes != null) { for (Attribute att : state.attributes.values()) { att.lock(); } } if (state.elements != null) { for (Object childObj : state.elements.values()) { if (childObj instanceof Element) { ((Element) childObj).lock(); } else { for (Element child : castElementCollection(childObj)) { child.lock(); } } } } return this; }
/** * Locks this element. A locked element cannot have any changes made to its * content or its attributes or child elements. This will also lock all * attributes and child elements as well. Once this method has been called, * this element can be safely published to other threads. */ public Element lock() { state.locked = true; if (state.attributes != null) { for (Attribute att : state.attributes.values()) { att.lock(); } } if (state.elements != null) { for (Object childObj : state.elements.values()) { if (childObj instanceof Element) { ((Element) childObj).lock(); } else { for (Element child : castElementCollection(childObj)) { child.lock(); } } } } return this; }
Object obj = getElementObject(childKey); if (obj instanceof Collection<?>) { Collection<Element> collect = castElementCollection(obj); Iterator<Element> iter = collect.iterator(); while (iter.hasNext()) {