1 8 9 package net.sourceforge.chaperon.model.lexicon; 10 11 import net.sourceforge.chaperon.model.Violations; 12 13 import java.util.Enumeration ; 14 import java.util.Vector ; 15 16 22 public class Lexicon 23 { 24 private Vector lexemes = new Vector (); 25 private String location = null; 26 27 32 public void addLexeme(Lexeme lexeme) 33 { 34 lexemes.addElement(lexeme); 35 } 36 37 42 public void removeLexeme(Lexeme lexeme) 43 { 44 lexemes.removeElement(lexeme); 45 } 46 47 54 public Lexeme getLexeme(int index) 55 { 56 return (Lexeme)lexemes.elementAt(index); 57 } 58 59 64 public int getLexemeCount() 65 { 66 return lexemes.size(); 67 } 68 69 74 public void setLocation(String location) 75 { 76 this.location = location; 77 } 78 79 84 public String getLocation() 85 { 86 return location; 87 } 88 89 94 public Violations validate() 95 { 96 Violations violations = new Violations(); 97 98 if (lexemes.size()==0) 99 violations.addViolation("Lexicon contains not lexemes", location); 100 101 for (Enumeration en = lexemes.elements(); en.hasMoreElements();) 102 violations.addViolations(((Lexeme)en.nextElement()).validate()); 103 104 return violations; 105 } 106 107 114 public Object clone() throws CloneNotSupportedException 115 { 116 Lexicon clone = new Lexicon(); 117 118 for (int i = 0; i<lexemes.size(); i++) 119 clone.lexemes.addElement(((Lexeme)lexemes.elementAt(i)).clone()); 120 121 clone.location = location; 122 123 return clone; 124 } 125 } 126 | Popular Tags |