Schemaset and inheritance class

xiaoxiao2021-03-06  21

Public class scheveaset {@field private object elementdata []; private int elementcount; private int at capacityincrement

Public cerors merror; // error message

// @Constructor public SchemaSet (int initialCapacity, int capacityIncrement) {if (initialCapacity <0) {// @@ error handling CError tError = new CError (); tError.moduleName = "SchemaSet"; tError.functionName = "SchemaSet" ; tError.errorMessage = "Illegal Capacity:" initialCapacity; this.mErrors .addOneError (tError);} this.elementData = new Object [initialCapacity]; this.capacityIncrement = capacityIncrement; this.elementCount = 0;

Merrors = new cerars ();

Public Schemaset (INT INITIALCAPACITY) {this (Initialcapacity, 0);

Public Schemaset () {this (10);

// @Method public boolean add (Schema aSchema) {if (aSchema == null) return false; ensureCapacityHelper (elementCount 1); elementData [elementCount] = aSchema; elementCount ; return true;}

Public Boolean Add (SCHEMASET ASET) {if (ASET == Null) Return False; int N = ASET.SIZE (); ENSURECAPACITYHELPER (ELEMENTCANT N); for (int i = 0; i

Public Boolean Remove (Schema Aschema) {IF (Aschema == Null) Return False; for (INT I = 0; I 0) {System.ArrayCopy (ElementData, i 1, ElementData, i, j);} elementcount--; elementdata [elementcount] = null; return} // end of if} // end of for return false;} public boolean removerange (Int begin <= 0 || end> ​​elementcount || begin> End) {Return False;} int n = elementcount - end; if (n> 0) {System.Arraycopy (ElementData, End, ElementData, Begin - 1, ElementCount - end);} int m = end - begin 1; for (int i = 1; i <= m; i ) { INT J = ElementCount - I; ELEMENTDATA [J] = null;} ElementCount - = m; Return True;

Public void clear () {for (int i = 0; i

Public Object getobj (int index) {if (INDEX> ElementCount) {@@ error handling CERROR TERROR = New Cerror (); terror.ModulenAme = "scheMaset"; Terror.FunctionName = "get"; terror.errorMessage = " Index Out of Bounds! "; This.merrors .addoneError (TEERROR);} Return ElementData [INDEX - 1];

Public Boolean Set (INDEX, SCHEMA Aschema) {if (Index> ElementCount) {@@ 错 处理 处理 c CERROR TERROR = New Cerror (); Terror.ModulenAMe = "Schemaset"; terror.functionName = "set"; Terror. ErrorMessage = "INDEX OUT OF Bounds!"; this.merrors .addoneError (TEERROR);

Return false;} ElementData [index - 1] = aschema; returnography;} public boolean set (Schemaset ASET) {this.clear (); return this.add (ASET);

Public int size () {return elementcount;}

private void ensureCapacityHelper (int minCapacity) {int oldCapacity = elementData.length; if (minCapacity> oldCapacity) {Object oldData [] = elementData; int newCapacity = (capacityIncrement> 0) (oldCapacity capacityIncrement):? (oldCapacity * 2); IF (newcapacity

/ * * * / Package com.vschema;

Import com.schema.lascriptionschema; import com.utility.schemaset; import com.utility.sysconst;

Public class lascriptionSet Extends Schemaset {@Method Public Boolean Add (Laascriptionschema Aschema) {Return Super.Add (Aschema);

Public Boolean Add (LaascriptionSet ASET) {Return Super.Add (ASET);

Public Boolean Remove (lascriptionschema aschema) {return super.remove (aschema);}

Public lascriptionschema get (int index) {lascriptionschema tschema = (lascriptionschema) super.getobj (index); return tschema;}

Public Boolean Set (int index, lascriptionschema aschema) {return super.set (index, aschema);

Public Boolean Set (LaascriptionSet ASET) {Return Super.Set (ASET);

/ ** * data package, press the XML format package, see

/ ** * Data Unpack * @Param: Afterpacking String * @Return: Boolean ** / Public Boolean Decode (String Str) {INT NBEGINPOS = 0; Int NendPos = Str.Indexof ('^'); this. Clear ();

while (! nEndPos = -1) {LAAscriptionSchema aSchema = new LAAscriptionSchema (); if (aSchema.decode (str.substring (nBeginPos, nEndPos)) == false) {// @@ error handling this.mErrors.copyAllErrors (aSchema .mErrors); return false;} this.add (aSchema); nBeginPos = nEndPos 1; nEndPos = str.indexOf ( '^', nEndPos 1);} LAAscriptionSchema tSchema = new LAAscriptionSchema (); if (tSchema.decode (Str.Substring (NBEGINPOS)) == false) {@@ error handling this.merrors.copyallerro (tschema.merrors); return false;} this.add (tschema);

Return True;}

}


New Post(0)