1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.calculator2; 18 19 import java.io.DataInput; 20 import java.io.DataOutput; 21 import java.io.IOException; 22 23 class HistoryEntry { 24 private static final int VERSION_1 = 1; 25 private String mBase; 26 private String mEdited; 27 HistoryEntry(String str)28 HistoryEntry(String str) { 29 mBase = str; 30 clearEdited(); 31 } 32 HistoryEntry(int version, DataInput in)33 HistoryEntry(int version, DataInput in) throws IOException { 34 if (version >= VERSION_1) { 35 mBase = in.readUTF(); 36 mEdited = in.readUTF(); 37 //Calculator.log("load " + mEdited); 38 } else { 39 throw new IOException("invalid version " + version); 40 } 41 } 42 write(DataOutput out)43 void write(DataOutput out) throws IOException { 44 out.writeUTF(mBase); 45 out.writeUTF(mEdited); 46 //Calculator.log("save " + mEdited); 47 } 48 49 @Override toString()50 public String toString() { 51 return mBase; 52 } 53 clearEdited()54 void clearEdited() { 55 mEdited = mBase; 56 } 57 getEdited()58 String getEdited() { 59 return mEdited; 60 } 61 setEdited(String edited)62 void setEdited(String edited) { 63 mEdited = edited; 64 } 65 getBase()66 String getBase() { 67 return mBase; 68 } 69 } 70