Package org.rometools.feed.module.photocast

Examples of org.rometools.feed.module.photocast.PhotocastModuleImpl


    public Parser() {
    }

    public Module parse(Element element) {
        if( element.getName().equals("channel") || element.getName().equals("feed") ){
            return new PhotocastModuleImpl();
        } else if( element.getChild( "metadata", Parser.NS ) == null && element.getChild( "image", Parser.NS ) == null )
            return null;
        PhotocastModule pm = new PhotocastModuleImpl();
        List children = element.getChildren();
        Iterator it = children.iterator();
        while( it.hasNext() ){
            Element e = (Element) it.next();
            if( !e.getNamespace().equals( Parser.NS ) )
                continue;
            if( e.getName().equals("photoDate") ){
                try{
                    pm.setPhotoDate( Parser.PHOTO_DATE_FORMAT.parse( e.getText() ) );
                } catch( Exception ex ){
                    LOG.warning( "Unable to parse photoDate: "+ e.getText() + " "+ ex.toString());
                }
            } else if( e.getName().equals("cropDate") ) {
                try{
                    pm.setCropDate( Parser.CROP_DATE_FORMAT.parse( e.getText() ) );
                } catch( Exception ex ){
                    LOG.warning( "Unable to parse cropDate: "+ e.getText() + " "+ ex.toString());
                }
            } else if( e.getName().equals("thumbnail") ) {
                try{
                    pm.setThumbnailUrl( new URL( e.getText() ) );
                } catch( Exception ex ){
                    LOG.warning( "Unable to parse thumnail: "+ e.getText() + " "+ ex.toString());
                }
            } else if( e.getName().equals("image") ) {
                try{
                    pm.setImageUrl( new URL( e.getText() ) );
                } catch( Exception ex ){
                    LOG.warning( "Unable to parse image: "+ e.getText() + " "+ ex.toString());
                }
            } else if( e.getName().equals("metadata") ) {
                String comments = "";
                PhotoDate photoDate = null;
                if( e.getChildText( "PhotoDate") != null ){
                    try{
                        photoDate = new PhotoDate( Double.parseDouble( e.getChildText("PhotoDate")));
                    } catch( Exception ex ){
                        LOG.warning( "Unable to parse PhotoDate: "+ e.getText() + " "+ ex.toString());
                    }
                }
                if( e.getChildText("Comments") != null ){
                    comments = e.getChildText("Comments");
                }
                pm.setMetadata( new Metadata( photoDate, comments) );
            }
        }
        return pm;
    }
View Full Code Here

TOP

Related Classes of org.rometools.feed.module.photocast.PhotocastModuleImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.