public static Map<String, ResourceProperties> parseListing(String base, InputStream is) throws Exception {
        Map<String, ResourceProperties> res = new HashMap<String, ResourceProperties>();
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        DocumentBuilder parser = factory.newDocumentBuilder();
        Document doc = parser.parse(is);
        NodeList nl = doc.getElementsByTagNameNS(DAV_NS, "response"); //$NON-NLS-1$
        for (int i = 0; i < nl.getLength(); i++) {
            Element oneElem = (Element)nl.item(i);
            NodeList resName = oneElem.getElementsByTagNameNS(DAV_NS, "href"); //$NON-NLS-1$
            assert(resName.getLength() == 1);
            String bareName = extractOverlap(base, URLDecoder.decode(resName.item(0).getTextContent(), "UTF-8"));
            if (bareName.trim().length() > 0) {
                ResourceProperties props = new ResourceProperties();
                NodeList propList = oneElem.getElementsByTagNameNS(DAV_NS, "resourcetype"); //$NON-NLS-1$
                assert(propList.getLength() == 1);
                NodeList resTypeList = ((Element)propList.item(0)).getElementsByTagNameNS(DAV_NS, "collection"); //$NON-NLS-1$
                assert(resTypeList.getLength() < 2);
                if (resTypeList.getLength() == 1) {
                    props.setDirectory(true);
                }
                propList = oneElem.getElementsByTagNameNS(DAV_NS, "creationdate"); //$NON-NLS-1$
                if (propList.getLength() > 0) {
                    props.setCreationDate(propList.item(0).getTextContent());
                }
                propList = oneElem.getElementsByTagNameNS(DAV_NS, "getlastmodified"); //$NON-NLS-1$
                if (propList.getLength() > 0) {
                    props.setLastModifiedDate(propList.item(0).getTextContent());
                }
                String normBase = base.trim().endsWith("/")?base.trim():base.trim() + "/"; //$NON-NLS-1$ //$NON-NLS-2$
                props.setBase(normBase);
                res.put(bareName, props);
            }
        }
        return res;
    }
public static Map < String , ResourceProperties > parseListing ( String base , InputStream is ) throws Exception { Map < String , ResourceProperties > res = new HashMap < String , ResourceProperties > ( ) ; DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; DocumentBuilder parser = factory . newDocumentBuilder ( ) ; Document doc = parser . parse ( is ) ; NodeList nl = doc . getElementsByTagNameNS ( DAV_NS , "response" ) ; for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Element oneElem = ( Element ) nl . item ( i ) ; NodeList resName = oneElem . getElementsByTagNameNS ( DAV_NS , "href" ) ; assert ( resName . getLength ( ) == 1 ) ; String bareName = extractOverlap ( base , URLDecoder . decode ( resName . item ( 0 ) . getTextContent ( ) , "UTF-8" ) ) ; if ( bareName . trim ( ) . length ( ) > 0 ) { ResourceProperties props = new ResourceProperties ( ) ; NodeList propList = oneElem . getElementsByTagNameNS ( DAV_NS , "resourcetype" ) ; assert ( propList . getLength ( ) == 1 ) ; NodeList resTypeList = ( ( Element ) propList . item ( 0 ) ) . getElementsByTagNameNS ( DAV_NS , "collection" ) ; assert ( resTypeList . getLength ( ) < 2 ) ; if ( resTypeList . getLength ( ) == 1 ) { props . setDirectory ( true ) ; } propList = oneElem . getElementsByTagNameNS ( DAV_NS , "creationdate" ) ; if ( propList . getLength ( ) > 0 ) { props . setCreationDate ( propList . item ( 0 ) . getTextContent ( ) ) ; } propList = oneElem . getElementsByTagNameNS ( DAV_NS , "getlastmodified" ) ; if ( propList . getLength ( ) > 0 ) { props . setLastModifiedDate ( propList . item ( 0 ) . getTextContent ( ) ) ; } String normBase = base . trim ( ) . endsWith ( "/" ) ? base . trim ( ) : base . trim ( ) + "/" ; props . setBase ( normBase ) ; res . put ( bareName , props ) ; } } return res ; }
$NON-NLS-1$