ServerResponse.java :  » Game » androidrunner » es » sonxurxo » androidrunner » view » xml » response » Android Open Source

Android Open Source » Game » androidrunner 
androidrunner » es » sonxurxo » androidrunner » view » xml » response » ServerResponse.java
/*
 * Android Runner is a multiplayer GPS game fully written by Xurxo Mendez Perez
 * 
 * Copyright (C) 2009 Xurxo Mendez Perez
 *   
 * This file is part of Android Runner.
 * 
 * Android Runner is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Android Runner is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Android Runner.  If not, see <http://www.gnu.org/licenses/>.
 */

package es.sonxurxo.androidrunner.view.xml.response;

import java.util.ArrayList;
import java.util.List;

import org.jdom.Element;

/**
 * 
 * @author "Xurxo Mendez Perez"
 *
 */
public class ServerResponse {
    
    public enum ContentType {
      DATA, EXCEPTION
    }
    
    private ContentType contentType;
    private List<Element> dataElements;
    private Exception exception;
    
    public ServerResponse() {
        this.dataElements = new ArrayList<Element>();
        this.contentType = ContentType.DATA;
    }
    
    public ServerResponse(Element dataElement) {
      this.dataElements = new ArrayList<Element>();
      this.dataElements.add(dataElement);
      this.contentType = ContentType.DATA;
    }

    public ServerResponse(List<Element> dataElements) {
        this.dataElements = dataElements;
        this.contentType = ContentType.DATA;
    }
    
    public ServerResponse(Exception exception) {
        this.exception = exception;
        this.contentType = ContentType.EXCEPTION;
    }
    
    public ContentType getContentType() {
        return this.contentType;
    }
    
    public List<Element> getDataElements() {
        return this.dataElements;
    } 
    
    public Exception getException() {
        return this.exception;
    }
       
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.