Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.safehaus.chop.api;
  
  
  
  import org.slf4j.Logger;
  
A Jackson JSON Deserializer for Project.
 
 public class ProjectDeserializer extends JsonDeserializer<Project> {
     private static final Logger LOG = LoggerFactory.getLoggerProjectDeserializer.class );
 
 
     @Override
     public Project deserializefinal JsonParser jpfinal DeserializationContext ctxt ) throws IOException {
         ProjectBuilder builder = new ProjectBuilder();
 
         String tmp = jp.getText();
         validatejptmp"{" );
         .debug"First token is {}"tmp );
 
         jp.nextToken();
         tmp = jp.getText();
         .debug"Second token is {}"tmp );
 
         whilejp.hasCurrentToken() ) {
 
             tmp = jp.getText();
             .debug"Current token text = {}"tmp );
 
             if ( tmp.equals"testPackageBase" ) ) {
                 jp.nextToken();
                 builder.setTestPackageBasejp.getText() );
             }
             else if ( tmp.equals"chopVersion" ) ) {
                 jp.nextToken();
                 builder.setChopVersionjp.getText() );
             }
             else if ( tmp.equals"createTimestamp" ) ) {
                 jp.nextToken();
                 builder.setCreateTimestampjp.getText() );
             }
             else if ( tmp.equals"vcsVersion" ) ) {
                 jp.nextToken();
                 builder.setVcsVersionjp.getText() );
             }
             else if ( tmp.equals"vcsRepoUrl" ) ) {
                 jp.nextToken();
                 builder.setVcsRepoUrljp.getText() );
             }
             else if ( tmp.equals"groupId" ) ) {
                 jp.nextToken();
                 builder.setGroupIdjp.getText() );
             }
             else if ( tmp.equals"artifactId" ) ) {
                 jp.nextToken();
                 builder.setArtifactIdjp.getText() );
             }
             else if ( tmp.equals"projectVersion" ) ) {
                 jp.nextToken();
                 builder.setProjectVersionjp.getText() );
             }
             else if ( tmp.equals"warMd5" ) ) {
                 jp.nextToken();
                 builder.setWarMd5jp.getText() );
             }
             else if ( tmp.equals"loadKey" ) ) {
                 jp.nextToken();
                 builder.setLoadKeyjp.getText() );
             }
             else if ( tmp.equals"loadTime" ) ) {
                 jp.nextToken();
                 builder.setLoadTimejp.getText() );
             }
 
             jp.nextToken();
 
             if ( jp.getText().equals"}" ) ) {
                 break;
             }
         }
 
         return builder.getProject();
     }
 
 
     private void validateJsonParser jsonParserString inputString expected ) throws JsonProcessingException {
         if ( ! input.equalsexpected ) ) {
             throw new JsonParseException"Unexpected token: " + inputjsonParser.getTokenLocation() );
         }
    }
New to GrepCode? Check out our FAQ X