1 package org.jicengine.operation; 2 3 4 14 15 public abstract class AbstractContext implements Context { 16 17 String name; 18 19 protected AbstractContext() 20 { 21 name = "unknown"; 22 } 23 24 protected AbstractContext(String name) 25 { 26 this.name = name; 27 } 28 29 public String getName() 30 { 31 return this.name; 32 } 33 34 public String toString() 35 { 36 return "{" + getName() + "}"; 37 } 38 39 protected static String getName(Context context, String defaultName) 40 { 41 if( context != null && context instanceof AbstractContext ){ 42 return ((AbstractContext)context).getName(); 43 } 44 else { 45 return defaultName; 46 } 47 } 48 49 public Context replicate() 50 { 51 java.util.Map objects = new java.util.HashMap (); 52 copyObjectsTo(objects); 53 return new SimpleContext(getName(), objects); 54 } 55 56 protected abstract void copyObjectsTo(java.util.Map map); 57 58 } 59 | Popular Tags |