1 22 23 package org.objectweb.petals.component.common.util; 24 25 import java.net.URI ; 26 import java.net.URISyntaxException ; 27 import java.util.Map ; 28 29 import org.objectweb.petals.tools.jbicommon.descriptor.Extensions; 30 import org.objectweb.petals.tools.jbicommon.descriptor.PetalsExtension; 31 32 37 public final class PetalsExtensionsUtil { 38 39 42 public static final String ADDRESS = "address"; 43 44 public static final String WSDL_LOCATION = "wsdl"; 45 46 49 private static final String KEY_VALUE_NS = "http://petals.objectweb.org/extensions/key-value/"; 50 51 private PetalsExtensionsUtil() { 52 53 } 54 55 65 @SuppressWarnings ("unchecked") 66 public static String extractValueFromKeyValueExtension( 67 Extensions extensions, String key) { 68 String value = null; 69 if (extensions != null) { 70 try { 71 URI uri = new URI (KEY_VALUE_NS); 72 PetalsExtension petalsExtension = extensions 73 .getPetalsExtensions().get(uri); 74 if (petalsExtension != null) { 75 Map <String , String > keyValue = (Map <String , String >) petalsExtension 76 .getExtensionObject(); 77 value = keyValue.get(key); 78 } 79 } catch (URISyntaxException e) { 80 e.printStackTrace(); 83 } 84 } 85 86 return value; 87 } 88 89 101 public static boolean hasKeyValueExtension(Extensions extensions, String key) { 102 return (extractValueFromKeyValueExtension(extensions, key) != null); 103 } 104 105 } 106 | Popular Tags |