1 package org.apache.lucene.util; 2 3 18 19 import java.io.ObjectStreamException ; 20 import java.io.Serializable ; 21 import java.io.StreamCorruptedException ; 22 import java.util.HashMap ; 23 import java.util.Map ; 24 25 28 public abstract class Parameter implements Serializable 29 { 30 static Map allParameters = new HashMap (); 31 32 private String name; 33 34 private Parameter() { 35 } 37 38 protected Parameter(String name) { 39 this.name = name; 41 String key = makeKey(name); 42 43 if(allParameters.containsKey(key)) 44 throw new IllegalArgumentException ("Parameter name " + key + " already used!"); 45 46 allParameters.put(key, this); 47 } 48 49 private String makeKey(String name){ 50 return getClass() + " " + name; 51 } 52 53 public String toString() { 54 return name; 55 } 56 57 64 protected Object readResolve() throws ObjectStreamException { 65 Object par = allParameters.get(makeKey(name)); 66 67 if(par == null) 68 throw new StreamCorruptedException ("Unknown parameter value: " + name); 69 70 return par; 71 } 72 73 } 74 | Popular Tags |