Package de.mhus.lib

Examples of de.mhus.lib.MException


    JsonNode array = node.get(config.getName());
    if (array == null) return;
   
    int pos = findPosOf((ArrayNode)array,(JsonConfig)config);
    if (pos < 0)
      throw new MException("could not find child");
    ((ArrayNode)array).remove( pos );
  }
View Full Code Here


    parent.removeConfig(this);
    parent = null;
  }
 
  public IConfig setConfig(String key, HashConfig child) throws MException {
    if (child.parent != null) throw new MException("Config already linked");
    LinkedList<HashConfig> list = children.get(key);
    if (list == null) {
      list = new LinkedList<HashConfig>();
      children.put(key, list);
    }
View Full Code Here

  // TODO move in childAll list
  @Override
  public int moveConfig(IConfig config, int newPos) throws MException {

    if (!(config instanceof HashConfig))
      throw new MException("not a hashconfig");

    LinkedList<HashConfig> list = children.get(config.getName());
    if (list == null || list.size() == 0 || !list.contains(config))
      throw new MException("config not in my list");
   
    if (list.size() == 1) {
      if (newPos == MOVE_FIRST || newPos == MOVE_LAST || newPos == 0)
        return 0;
      throw new MException("out of range");
    }
   
    if (newPos == MOVE_FIRST) {
      list.remove(config);
      list.add(0, (HashConfig) config);
      return 0;
    }
   
    if(newPos == MOVE_LAST) {
      list.remove(config);
      list.add((HashConfig) config);
      return list.size()-1;
    }
   
    if (newPos == MOVE_DOWN) {
      int pos = list.indexOf(config);
      if (pos == list.size()-1)
        throw new MException("out of range");       
      list.remove(config);
      list.add(pos+1,(HashConfig) config);
      return pos+1;
    }
   
    if (newPos == MOVE_UP) {
      int pos = list.indexOf(config);
      if (pos == 0)
        throw new MException("out of range");       
      list.remove(config);
      list.add(pos-1,(HashConfig) config);
      return pos-1;
    }
   
    if (newPos < 0 || newPos >= list.size())
      throw new MException("out of range");     

    list.remove(config);
    list.add(newPos,(HashConfig) config);
   
    return newPos;
View Full Code Here

    setString("columns", "8");
  }

  @Override
  public void inject(DefComponent parent) throws MException {
    throw new MException("can't link root into another container");
  }
View Full Code Here

      else
      if (value instanceof Number)
        index = ((Number)value).intValue();

      Object[] values=ret.getEnumConstants();
      if (index < 0 || index >= values.length) throw new MException("index not found in enum",ret.getName());
     
      value = values[index];
     
    }
   
View Full Code Here

      else
      if (value instanceof Number)
        index = ((Number)value).intValue();

      Object[] values=ret.getEnumConstants();
      if (index < 0 || index >= values.length) throw new MException("index not found in enum",ret.getName());
     
      value = values[index];
     
    }
   
View Full Code Here

      log.t("save config",this);
      FileOutputStream os = new FileOutputStream(file);
      write(os);
      os.close();
    } catch (Exception e) {
      throw new MException(e);
    }
  }
View Full Code Here

TOP

Related Classes of de.mhus.lib.MException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.