1 26 27 package org.objectweb.openccm.corba.trader; 28 29 import org.omg.CosTrading.FollowOption; 31 32 40 public abstract class QueryPoliciesHelper { 41 42 47 private static java.util.Map query_policies = null; 48 49 static { 51 java.util.HashMap hm = new java.util.HashMap (); 52 org.omg.CORBA.TypeCode ul_tc = TraderTypeCodeUtils.getTypeCode("unsigned long"); 53 org.omg.CORBA.TypeCode bool_tc = TraderTypeCodeUtils.getTypeCode("boolean"); 54 org.omg.CORBA.TypeCode fo_tc = org.omg.CosTrading.FollowOptionHelper.type(); 55 org.omg.CORBA.TypeCode tn_tc = org.omg.CosTrading.TraderNameHelper.type(); 56 org.omg.CORBA.TypeCode os_tc = org.omg.CosTrading.AdminPackage.OctetSeqHelper.type(); 57 58 hm.put("search_card", ul_tc); 59 hm.put("match_card", ul_tc); 60 hm.put("return_card", ul_tc); 61 hm.put("hop_count", ul_tc); 62 hm.put("link_follow_rule", fo_tc); 63 hm.put("starting_trader", tn_tc); 64 hm.put("request_id", os_tc); 65 hm.put("exact_type_match", bool_tc); 66 hm.put("use_modifiable_properties", bool_tc); 67 hm.put("use_dynamic_properties", bool_tc); 68 hm.put("use_proxy_offers", bool_tc); 69 QueryPoliciesHelper.query_policies = hm; 70 } 71 72 79 public static org.omg.CORBA.TypeCode 80 getQueryPolicyType(String policy_name) 81 { 82 return (org.omg.CORBA.TypeCode )QueryPoliciesHelper.query_policies.get(policy_name.toLowerCase()); 83 } 84 85 92 public static boolean 93 exist(String policy_name) 94 { 95 return QueryPoliciesHelper.query_policies.containsKey(policy_name.toLowerCase()); 96 } 97 98 112 public static org.omg.CosTrading.Policy 113 construct_policy(String name, String value) 114 { 115 org.omg.CORBA.TypeCode tc = QueryPoliciesHelper.getQueryPolicyType(name); 116 if (tc == null) return null; 117 org.omg.CORBA.Any any = null; 118 if (name.equals("link_follow_rule")) { 119 any = org.objectweb.openccm.corba.TheORB.getORB().create_any(); 120 FollowOption opt = null; 121 if (value.equals("local_only")) opt = FollowOption.local_only; 122 else if (value.equals("if_no_local")) opt = FollowOption.if_no_local; 123 else opt = FollowOption.always; 124 org.omg.CosTrading.FollowOptionHelper.insert(any, opt); 125 } else { 126 any = TraderTypeCodeUtils.insertInAny(tc, value); 127 } 128 if (any == null) return null; 129 return new org.omg.CosTrading.Policy(name, any); 130 } 131 } 132 | Popular Tags |