@Override public String put(String key, String value) throws IllegalArgumentException { if (key == null || key.isEmpty() || key.contains("\n") || key.trim().isEmpty()) { throw new IllegalArgumentException(table.getTableName() + ": put: key is null"); } if (value == null || value.isEmpty() || value.trim().isEmpty() || value.contains("\n") || value.contains(" ")) { throw new IllegalArgumentException(table.getTableName() + ": put: value is null"); } String result; try { result = table.put(key, value); } catch (InvalidWorkingException e) { throw new IllegalArgumentException(e.getMessage()); } if (values.containsKey(key) && value.equals(values.get(key))) { changes.remove(key); } else { changes.put(key, value); } return result; }
@Override public void doCommand(String[] arguments, Container storage, Directory directory) throws InvalidWorkingException { if (storage == null) { throw new InvalidWorkingException(getName() + ": Command do not get storage to work with"); } try { String value = storage.remove(arguments[0]); if (value == null) { System.out.println("not found"); } else { System.out.println("removed"); } } catch (InvalidWorkingException e) { System.out.println(e.getMessage()); } }