// // DataObject.java // // WELD Java Client Persistent Object Management Package // Copyright Francis Chan (fchan@ic.eecs.berkeley.edu), 1997 // University of California, Berkeley // // // This program is in the public domain. // Permission to use, copy, modify, and distribute this software // and its documentation for NON-COMMERCIAL purposes and // without fee is hereby granted, as long as credit is given. import java.util.Vector; import java.io.StreamTokenizer; /** * * DataObject Class * * This is a class which allows data or files that can be translated to * a string representation to be saved to and retrived from a remote * network data server * * @version 1.0 February 1997 * @author Francis Chan */ public class DataObject extends PersistentObject{ private String name; private String content; // for persistent object public static final String objectClassName = "DataObject"; public static final int numField = 2; public static final int numObjField = 0; /** * Constructor for DataObject * * @param name The name of the object to be stored * @param content The content of the object */ public DataObject(String name, String content){ this.name = name; this.content = content; netObjSetup(numField, numObjField, objectClassName); } public String getContent(){ return content; } // just for testing public void setContent(String ct){ content = ct; return; } /*----------------------------------------------------------- * The code below is required for extending PersistentObject * (should not be called) *-----------------------------------------------------------*/ /** * * The DataObject construction should be followed by * a load so that the corresponding object fields will be set * */ public DataObject() { netObjSetup(numField, numObjField, objectClassName); } /** * Loads the object from a network (persistent object storage) database * backend(and sets it's fields) */ public boolean load(String strId) { if (loadObject(strId, 0, null) == false) { System.out.println("Couldn't load object " + objectClassName + " with strId " + strId); return false; } getObjFields(); return successfulTransmit; } protected void setObjFields() { setField(0, this.name, PO.STRING); setField(1, this.content, PO.STRING); } protected void getObjFields() { this.name = getField(0, PO.STRING_INDICATOR); this.content = getField(1, PO.STRING_INDICATOR); } }