[927] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
[922] | 15 | package de.ugoe.cs.autoquest.commands.misc;
|
---|
[88] | 16 |
|
---|
| 17 | import java.io.FileInputStream;
|
---|
| 18 | import java.io.IOException;
|
---|
| 19 | import java.io.ObjectInputStream;
|
---|
| 20 | import java.util.List;
|
---|
| 21 |
|
---|
| 22 | import de.ugoe.cs.util.console.Command;
|
---|
| 23 | import de.ugoe.cs.util.console.Console;
|
---|
[667] | 24 | import de.ugoe.cs.util.console.GlobalDataContainer;
|
---|
[88] | 25 |
|
---|
[171] | 26 | /**
|
---|
| 27 | * <p>
|
---|
| 28 | * Command that loads a previously serialized {@link GlobalDataContainer}.
|
---|
| 29 | * </p>
|
---|
| 30 | *
|
---|
| 31 | * @author Steffen Herbold
|
---|
| 32 | * @version 1.0
|
---|
| 33 | */
|
---|
[88] | 34 | public class CMDload implements Command {
|
---|
| 35 |
|
---|
[171] | 36 | /*
|
---|
| 37 | * (non-Javadoc)
|
---|
| 38 | *
|
---|
| 39 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 40 | */
|
---|
[88] | 41 | @Override
|
---|
| 42 | public void run(List<Object> parameters) {
|
---|
| 43 | String filename;
|
---|
| 44 | try {
|
---|
| 45 | filename = (String) parameters.get(0);
|
---|
| 46 | } catch (Exception e) {
|
---|
[766] | 47 | throw new IllegalArgumentException();
|
---|
[88] | 48 | }
|
---|
| 49 |
|
---|
| 50 | FileInputStream fis = null;
|
---|
| 51 | ObjectInputStream in = null;
|
---|
| 52 | try {
|
---|
| 53 | fis = new FileInputStream(filename);
|
---|
| 54 | in = new ObjectInputStream(fis);
|
---|
[89] | 55 | in.readObject();
|
---|
[88] | 56 | in.close();
|
---|
| 57 | } catch (IOException ex) {
|
---|
[211] | 58 | Console.logException(ex);
|
---|
[88] | 59 | } catch (ClassNotFoundException ex) {
|
---|
[211] | 60 | Console.logException(ex);
|
---|
[88] | 61 | }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
[171] | 64 | /*
|
---|
| 65 | * (non-Javadoc)
|
---|
| 66 | *
|
---|
| 67 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 68 | */
|
---|
[88] | 69 | @Override
|
---|
[664] | 70 | public String help() {
|
---|
| 71 | return "load <filename>";
|
---|
[88] | 72 | }
|
---|
[171] | 73 |
|
---|
[88] | 74 | }
|
---|