1 2 package SOFA.SOFAnode.Made.CodeGen; 3 4 8 public class GenObjectList extends java.util.ArrayList { 9 10 public static class ExistException extends CodeGenException { 11 public ExistException() { super(); }; 12 public ExistException(String s) { super(s); }; 13 } 14 15 19 public GeneratedObject getObject(int index) { 20 return (GeneratedObject) get(index); 21 } 22 23 28 public int indexOfObject(String key) { 29 for (int i=0; i<size(); i++) { 30 if (getObject(i).compareKey(key)) 31 return i; 32 } 33 return -1; 34 } 35 36 41 public GeneratedObject searchObject(String key) { 42 for (int i=0; i<size(); i++) { 43 if (getObject(i).compareKey(key)) 44 return getObject(i); 45 } 46 return null; 47 } 48 49 53 public boolean containsObject(String key) { 54 for (int i=0;i<size();i++) { 55 if (getObject(i).compareKey(key)) 56 return true; 57 } 58 return false; 59 } 60 61 67 public void addObject(GeneratedObject obj) throws ExistException { 68 if (!containsObject(obj.key)) 69 add(obj); 70 else 71 throw new ExistException(Res.res.getString("MSG_ObjIsInList")); 72 } 73 } 74 | Popular Tags |