Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
$Id: GradebookArchive.java 105077 2012-02-24 22:54:29Z ottenhoff@longsight.com $ Copyright (c) 2005, 2006, 2008 The Sakai Foundation, The MIT Corporation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 
 package org.sakaiproject.tool.gradebook;
 
Models a gradebook and all of its dependent objects, which can all be serialized as xml for archiving.

Author(s):
Josh Holtzman
 
 public class GradebookArchive {
     private static Log log = LogFactory.getLog(GradebookArchive.class);
 
     private Gradebook gradebook;
     private Collection gradeMappings;
     private CourseGrade courseGrade;
     private Collection assignments;
 
     public GradebookArchive() {
         // Allows for creating the archive, then populating it via readArchive()
     }

Parameters:
gradebook
selectedGradeMapping
gradeMappings
courseGrade
assignments
 
 	public GradebookArchive(Gradebook gradebook,
 			GradeMapping selectedGradeMappingCollection gradeMappings,
 			CourseGrade courseGradeCollection assignments) {
 		super();
 		this. = gradebook;
 		this. = selectedGradeMapping;
 		this. = gradeMappings;
 		this. = courseGrade;
 		this. = assignments;
 	}

    
Serializes this gradebook archive into an xml document
 
     public String archive() {
         if(.isDebugEnabled()) .debug("GradebookArchive.archive() called");
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(baos));
         encoder.writeObject(this);
         encoder.flush();
         String xml = baos.toString();
         if(.isDebugEnabled()) .debug("GradebookArchive.archive() finished");
         return xml;
     }

    
Read a gradebook archive from an xml input stream.

Parameters:
xml The input stream containing the serialized gradebook archive
Returns:
A gradebook archive object modeling the data in the xml stream
 
     public void readArchive(String xml) {
         ByteArrayInputStream in = new ByteArrayInputStream(xml.getBytes());
         XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(in));
         GradebookArchive archive = (GradebookArchive)decoder.readObject();
         decoder.close();
         this. = archive.getGradebook();
         this. = archive.getCourseGrade();
         this. = archive.getAssignments();
    }
    public Collection getAssignments() {
		return ;
	}
	public void setAssignments(Collection assignments) {
		this. = assignments;
	}
		return ;
	}
	public void setCourseGrade(CourseGrade courseGrade) {
		this. = courseGrade;
	}
	public Gradebook getGradebook() {
		return ;
	}
	public void setGradebook(Gradebook gradebook) {
		this. = gradebook;
	}
	}
	public void setGradeMappings(Collection gradeMappings) {
		this. = gradeMappings;
	}
	}
	public void setSelectedGradeMapping(GradeMapping selectedGradeMapping) {
		this. = selectedGradeMapping;
	}
New to GrepCode? Check out our FAQ X