Package org.rometools.feed.module.photocast

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


    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


    }

    public void generate(Module module, Element element) {
        if( !(module instanceof PhotocastModule ) )
            return;
        PhotocastModule pm = (PhotocastModule) module;
        if( element.getName().equals("channel") || element.getName().equals("feed") ){
            element.addContent( generateSimpleElement( "feedVersion", FEED_VERSION) );
            return;
        }
        element.addContent( generateSimpleElement("photoDate", Parser.PHOTO_DATE_FORMAT.format(pm.getPhotoDate())));
        element.addContent( generateSimpleElement("cropDate", Parser.CROP_DATE_FORMAT.format( pm.getCropDate() )));
        element.addContent( generateSimpleElement("thumbnail", pm.getThumbnailUrl().toString() ) );
        element.addContent( generateSimpleElement("image", pm.getImageUrl().toString() ) );
        Element e = new Element( "metadata", NS );
        Element pd = new Element( "PhotoDate", "" );
        pd.addContent( pm.getMetadata().getPhotoDate().toString() );
        e.addContent( pd );
        Element com = new Element("Comments", "");
        com.addContent( pm.getMetadata().getComments() );
        e.addContent( com );
        element.addContent(e);
    }
View Full Code Here

TOP

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

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.