1 package org.sapia.regis; 2 3 import java.io.Serializable ; 4 import java.util.Collections ; 5 import java.util.HashMap ; 6 import java.util.Map ; 7 8 54 public class Query implements Serializable { 55 56 static final long serialVersionUID = 1L; 57 58 private Path _path; 59 private Map _criteria; 60 61 66 public Query setPath(Path path){ 67 _path = path; 68 return this; 69 } 70 71 75 public Query setPath(String path){ 76 _path = Path.parse(path); 77 return this; 78 } 79 80 84 public Path getPath(){ 85 return _path; 86 } 87 88 99 public Query addCrit(String name, String value){ 100 crit().put(name, value); 101 return this; 102 } 103 104 107 public Map getCriteria(){ 108 return _criteria == null ? Collections.EMPTY_MAP : _criteria; 109 } 110 111 114 public static Query create(){ 115 return new Query(); 116 } 117 118 121 public static Query create(String path){ 122 return create(Path.parse(path)); 123 } 124 125 129 public static Query create(Path path){ 130 Query q = new Query(); 131 q.setPath(path); 132 return q; 133 } 134 135 private Map crit(){ 136 if(_criteria == null) _criteria = new HashMap (); 137 return _criteria; 138 } 139 } 140 | Popular Tags |