/** * Calls {@link #getText(Element)} on the first child element that matches * the given local name and namespace. * * @param parent * @param childLocalName * @param childNamespaceURI * @return text contained in the first child that matches the given local name * and namespace or <code>null</code>. * @see #getText(Element) */ public static String getChildText(Element parent, String childLocalName, String childNamespaceURI) { Element child = getChildElement(parent, childLocalName, childNamespaceURI); return (child == null) ? null : getText(child); }
private static void parseColumnElement(Element columnElement, List<String> columnNames, List<String> selectorNames, List<Value> values, ValueFactory valueFactory) throws ValueFormatException, RepositoryException { if (!XML_QUERY_RESULT_COLUMN.equals(columnElement.getLocalName()) && NS_URI.equals(columnElement.getNamespaceURI())) { // dcr:column element expected within search result -> can't parse return; } columnNames.add(XMLUtil.getChildText(columnElement, JCR_NAME_LN, NS_URI)); selectorNames.add(XMLUtil.getChildText(columnElement, JCR_SELECTOR_NAME_LN, NS_URI)); Value jcrValue = null; Element valueElement = XMLUtil.getChildElement(columnElement, JCR_VALUE_LN, NS_URI); if (valueElement != null) { String text = XMLUtil.getText(valueElement); if (text != null) { String typeStr = XMLUtil.getAttribute(valueElement, ATTR_VALUE_TYPE, NS_URI); jcrValue = ValueHelper.deserialize( text, PropertyType.valueFromName(typeStr), true, valueFactory); } } values.add(jcrValue); } }
/** * * @param valueElement * @param defaultType * @return * @throws javax.jcr.ValueFormatException * @throws javax.jcr.RepositoryException */ private static Value getJcrValue(Element valueElement, int defaultType, ValueFactory valueFactory) throws ValueFormatException, RepositoryException { if (valueElement == null) { return null; } // make sure the value is never 'null' String value = XMLUtil.getText(valueElement, ""); String typeStr = XMLUtil.getAttribute(valueElement, JcrRemotingConstants.ATTR_VALUE_TYPE, JcrRemotingConstants.NS_URI); int type = (typeStr == null) ? defaultType : PropertyType.valueFromName(typeStr); // deserialize value ->> see #valueToXml where values are serialized return ValueHelper.deserialize(value, type, true, valueFactory); }
/** * Same as {@link #getText(Element)} except that 'defaultValue' is returned * instead of <code>null</code>, if the element does not contain any text. * * @param element * @param defaultValue * @return the text contained in the specified element or * <code>defaultValue</code> if the element does not contain any text. */ public static String getText(Element element, String defaultValue) { String txt = getText(element); return (txt == null) ? defaultValue : txt; }
private static Set<String> retrieveNodeTypeNames(List<?> elementList) { Set<String> nodetypeNames = new HashSet<String>(); for (Object content : elementList) { if (!(content instanceof Element)) { continue; } Element el = (Element) content; if (XML_NODETYPE.equals(el.getLocalName()) && JcrRemotingConstants.NS_URI.equals(el.getNamespaceURI())) { String nodetypeName = XMLUtil.getChildText(el, XML_NODETYPENAME, JcrRemotingConstants.NS_URI); if (nodetypeName != null && !"".equals(nodetypeName)) { nodetypeNames.add(nodetypeName); } } // else: 'dcr:nodetype' element expected -> ignoring element } return nodetypeNames; } }
/** * Concatenates the values of all child nodes of type 'Text' or 'CDATA'/ * * @param element * @return String representing the value of all Text and CDATA child nodes or * <code>null</code> if the length of the resulting String is 0. * @see #isText(org.w3c.dom.Node) */ public static String getText(Element element) { StringBuilder content = new StringBuilder(); if (element != null) { NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node child = nodes.item(i); if (isText(child)) { // cast to super class that contains Text and CData content.append(((CharacterData) child).getData()); } } } return (content.length()==0) ? null : content.toString(); }
private static void parseColumnElement(Element columnElement, List<String> columnNames, List<String> selectorNames, List<Value> values, ValueFactory valueFactory) throws ValueFormatException, RepositoryException { if (!XML_QUERY_RESULT_COLUMN.equals(columnElement.getLocalName()) && NS_URI.equals(columnElement.getNamespaceURI())) { // dcr:column element expected within search result -> can't parse return; } columnNames.add(XMLUtil.getChildText(columnElement, JCR_NAME_LN, NS_URI)); selectorNames.add(XMLUtil.getChildText(columnElement, JCR_SELECTOR_NAME_LN, NS_URI)); Value jcrValue = null; Element valueElement = XMLUtil.getChildElement(columnElement, JCR_VALUE_LN, NS_URI); if (valueElement != null) { String text = XMLUtil.getText(valueElement); if (text != null) { String typeStr = XMLUtil.getAttribute(valueElement, ATTR_VALUE_TYPE, NS_URI); jcrValue = ValueHelper.deserialize( text, PropertyType.valueFromName(typeStr), true, valueFactory); } } values.add(jcrValue); } }
/** * * @param valueElement * @param defaultType * @return * @throws javax.jcr.ValueFormatException * @throws javax.jcr.RepositoryException */ private static Value getJcrValue(Element valueElement, int defaultType, ValueFactory valueFactory) throws ValueFormatException, RepositoryException { if (valueElement == null) { return null; } // make sure the value is never 'null' String value = XMLUtil.getText(valueElement, ""); String typeStr = XMLUtil.getAttribute(valueElement, JcrRemotingConstants.ATTR_VALUE_TYPE, JcrRemotingConstants.NS_URI); int type = (typeStr == null) ? defaultType : PropertyType.valueFromName(typeStr); // deserialize value ->> see #valueToXml where values are serialized return ValueHelper.deserialize(value, type, true, valueFactory); }
/** * Same as {@link #getText(Element)} except that 'defaultValue' is returned * instead of <code>null</code>, if the element does not contain any text. * * @param element * @param defaultValue * @return the text contained in the specified element or * <code>defaultValue</code> if the element does not contain any text. */ public static String getText(Element element, String defaultValue) { String txt = getText(element); return (txt == null) ? defaultValue : txt; }
private static Set<String> retrieveNodeTypeNames(List<?> elementList) { Set<String> nodetypeNames = new HashSet<String>(); for (Object content : elementList) { if (!(content instanceof Element)) { continue; } Element el = (Element) content; if (XML_NODETYPE.equals(el.getLocalName()) && JcrRemotingConstants.NS_URI.equals(el.getNamespaceURI())) { String nodetypeName = XMLUtil.getChildText(el, XML_NODETYPENAME, JcrRemotingConstants.NS_URI); if (nodetypeName != null && !"".equals(nodetypeName)) { nodetypeNames.add(nodetypeName); } } // else: 'dcr:nodetype' element expected -> ignoring element } return nodetypeNames; } }
/** * Concatenates the values of all child nodes of type 'Text' or 'CDATA'/ * * @param element * @return String representing the value of all Text and CDATA child nodes or * <code>null</code> if the length of the resulting String is 0. * @see #isText(org.w3c.dom.Node) */ public static String getText(Element element) { StringBuilder content = new StringBuilder(); if (element != null) { NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node child = nodes.item(i); if (isText(child)) { // cast to super class that contains Text and CData content.append(((CharacterData) child).getData()); } } } return (content.length()==0) ? null : content.toString(); }
private static void parseColumnElement(Element columnElement, List<String> columnNames, List<String> selectorNames, List<Value> values, ValueFactory valueFactory) throws ValueFormatException, RepositoryException { if (!XML_QUERY_RESULT_COLUMN.equals(columnElement.getLocalName()) && NS_URI.equals(columnElement.getNamespaceURI())) { // dcr:column element expected within search result -> can't parse return; } columnNames.add(XMLUtil.getChildText(columnElement, JCR_NAME_LN, NS_URI)); selectorNames.add(XMLUtil.getChildText(columnElement, JCR_SELECTOR_NAME_LN, NS_URI)); Value jcrValue = null; Element valueElement = XMLUtil.getChildElement(columnElement, JCR_VALUE_LN, NS_URI); if (valueElement != null) { String text = XMLUtil.getText(valueElement); if (text != null) { String typeStr = XMLUtil.getAttribute(valueElement, ATTR_VALUE_TYPE, NS_URI); jcrValue = ValueHelper.deserialize( text, PropertyType.valueFromName(typeStr), true, valueFactory); } } values.add(jcrValue); } }
/** * Calls {@link #getText(Element)} on the first child element that matches * the given local name and namespace. * * @param parent * @param childLocalName * @param childNamespaceURI * @return text contained in the first child that matches the given local name * and namespace or <code>null</code>. * @see #getText(Element) */ public static String getChildText(Element parent, String childLocalName, String childNamespaceURI) { Element child = getChildElement(parent, childLocalName, childNamespaceURI); return (child == null) ? null : getText(child); }
/** * * @param valueElement * @param defaultType * @return * @throws javax.jcr.ValueFormatException * @throws javax.jcr.RepositoryException */ private static Value getJcrValue(Element valueElement, int defaultType, ValueFactory valueFactory) throws ValueFormatException, RepositoryException { if (valueElement == null) { return null; } // make sure the value is never 'null' String value = XMLUtil.getText(valueElement, ""); String typeStr = XMLUtil.getAttribute(valueElement, JcrRemotingConstants.ATTR_VALUE_TYPE, JcrRemotingConstants.NS_URI); int type = (typeStr == null) ? defaultType : PropertyType.valueFromName(typeStr); // deserialize value ->> see #valueToXml where values are serialized return ValueHelper.deserialize(value, type, true, valueFactory); }
/** * Same as {@link #getText(Element)} except that 'defaultValue' is returned * instead of <code>null</code>, if the element does not contain any text. * * @param element * @param defaultValue * @return the text contained in the specified element or * <code>defaultValue</code> if the element does not contain any text. */ public static String getText(Element element, String defaultValue) { String txt = getText(element); return (txt == null) ? defaultValue : txt; }
private static Set<String> retrieveNodeTypeNames(List<?> elementList) { Set<String> nodetypeNames = new HashSet<String>(); for (Object content : elementList) { if (!(content instanceof Element)) { continue; } Element el = (Element) content; if (XML_NODETYPE.equals(el.getLocalName()) && JcrRemotingConstants.NS_URI.equals(el.getNamespaceURI())) { String nodetypeName = XMLUtil.getChildText(el, XML_NODETYPENAME, JcrRemotingConstants.NS_URI); if (nodetypeName != null && !"".equals(nodetypeName)) { nodetypeNames.add(nodetypeName); } } // else: 'dcr:nodetype' element expected -> ignoring element } return nodetypeNames; } }
/** * Concatenates the values of all child nodes of type 'Text' or 'CDATA'/ * * @param element * @return String representing the value of all Text and CDATA child nodes or * <code>null</code> if the length of the resulting String is 0. * @see #isText(org.w3c.dom.Node) */ public static String getText(Element element) { StringBuilder content = new StringBuilder(); if (element != null) { NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node child = nodes.item(i); if (isText(child)) { // cast to super class that contains Text and CData content.append(((CharacterData) child).getData()); } } } return (content.length()==0) ? null : content.toString(); }
/** * Calls {@link #getText(Element)} on the first child element that matches * the given local name and namespace. * * @param parent * @param childLocalName * @param childNamespaceURI * @return text contained in the first child that matches the given local name * and namespace or <code>null</code>. * @see #getText(Element) */ public static String getChildText(Element parent, String childLocalName, String childNamespaceURI) { Element child = getChildElement(parent, childLocalName, childNamespaceURI); return (child == null) ? null : getText(child); }
int i = 0; for (Element element : lengthElements) { lengths[i] = Long.parseLong(XMLUtil.getText(element, "0")); i++;
int i = 0; for (Element element : lengthElements) { lengths[i] = Long.parseLong(XMLUtil.getText(element, "0")); i++;