(InputStream is)
| 1016 | } |
| 1017 | |
| 1018 | private void loadProvidersFromStream(InputStream is) |
| 1019 | throws IOException { |
| 1020 | if (is != null) { |
| 1021 | LineInputStream lis = new LineInputStream(is); |
| 1022 | String currLine; |
| 1023 | |
| 1024 | // load and process one line at a time using LineInputStream |
| 1025 | while ((currLine = lis.readLine()) != null) { |
| 1026 | |
| 1027 | if (currLine.startsWith("#")) |
| 1028 | continue; |
| 1029 | if (currLine.trim().length() == 0) |
| 1030 | continue; // skip blank line |
| 1031 | Provider.Type type = null; |
| 1032 | String protocol = null, className = null; |
| 1033 | String vendor = null, version = null; |
| 1034 | |
| 1035 | // separate line into key-value tuples |
| 1036 | StringTokenizer tuples = new StringTokenizer(currLine,";"); |
| 1037 | while (tuples.hasMoreTokens()) { |
| 1038 | String currTuple = tuples.nextToken().trim(); |
| 1039 | |
| 1040 | // set the value of each attribute based on its key |
| 1041 | int sep = currTuple.indexOf("="); |
| 1042 | if (currTuple.startsWith("protocol=")) { |
| 1043 | protocol = currTuple.substring(sep+1); |
| 1044 | } else if (currTuple.startsWith("type=")) { |
| 1045 | String strType = currTuple.substring(sep+1); |
| 1046 | if (strType.equalsIgnoreCase("store")) { |
| 1047 | type = Provider.Type.STORE; |
| 1048 | } else if (strType.equalsIgnoreCase("transport")) { |
| 1049 | type = Provider.Type.TRANSPORT; |
| 1050 | } |
| 1051 | } else if (currTuple.startsWith("class=")) { |
| 1052 | className = currTuple.substring(sep+1); |
| 1053 | } else if (currTuple.startsWith("vendor=")) { |
| 1054 | vendor = currTuple.substring(sep+1); |
| 1055 | } else if (currTuple.startsWith("version=")) { |
| 1056 | version = currTuple.substring(sep+1); |
| 1057 | } |
| 1058 | } |
| 1059 | |
| 1060 | // check if a valid Provider; else, continue |
| 1061 | if (type == null || protocol == null || className == null |
| 1062 | || protocol.length() <= 0 || className.length() <= 0) { |
| 1063 | |
| 1064 | logger.log(Level.CONFIG, "Bad provider entry: {0}", |
| 1065 | currLine); |
| 1066 | continue; |
| 1067 | } |
| 1068 | Provider provider = new Provider(type, protocol, className, |
| 1069 | vendor, version); |
| 1070 | |
| 1071 | // add the newly-created Provider to the lookup tables |
| 1072 | addProvider(provider); |
| 1073 | } |
| 1074 | } |
| 1075 | } |
no test coverage detected