Assigns an option. @param options options @param entry current parameter @param enforce force assignment @return success flag @throws HTTPException HTTP exception
(final Options options, final Entry<String, String[]> entry,
final boolean enforce)
| 136 | * @throws HTTPException HTTP exception |
| 137 | */ |
| 138 | static boolean assign(final Options options, final Entry<String, String[]> entry, |
| 139 | final boolean enforce) throws HTTPException { |
| 140 | |
| 141 | String key = entry.getKey(); |
| 142 | if(options instanceof MainOptions) key = key.toUpperCase(Locale.ENGLISH); |
| 143 | if(options.option(key) == null) { |
| 144 | if(enforce) throw HTTPStatus.UNKNOWN_PARAM_X.get(key); |
| 145 | return false; |
| 146 | } |
| 147 | |
| 148 | try { |
| 149 | options.assign(key, entry.getValue()[0]); |
| 150 | return true; |
| 151 | } catch(final BaseXException ex) { |
| 152 | throw HTTPStatus.BAD_REQUEST_X.get(ex); |
| 153 | } |
| 154 | } |
| 155 | } |