Package org.dmd.dmc

Examples of org.dmd.dmc.DmcValueException


      eventName = value.substring(0, spacepos);
      int lbpos = value.indexOf("(", spacepos+1);
      int rbpos = value.indexOf(")", spacepos+1);
     
      if (lbpos == -1)
        throw(new DmcValueException("The argument vector must start with a ("));
      if (rbpos == -1)
        throw(new DmcValueException("The argument vector must end with a )"));
     
      argVector   = value.substring(lbpos,rbpos+1);
      imports   = new TreeSet<String>();
     
      if (value.length() > (rbpos+1)){
        // the remainder should be space separated fully qualified class names
        String remainder = value.substring(rbpos+1);
       
        String[] classes = remainder.split(" ");
        for(int i=0; i<classes.length; i++){
          if (classes[i].length() > 0){
            imports.add(classes[i]);
          }
        }
      }
    }
   
    if (!eventName.endsWith("Event"))
      throw(new DmcValueException("The event name must end with `Event`)"));
     
  }
View Full Code Here


  public RequestWithOptions typeCheck(Object value) throws DmcValueException {
    if (value instanceof RequestWithOptions)
      return((RequestWithOptions)value);
    if (value instanceof String)
      return(new RequestWithOptions((String)value));
    throw(new DmcValueException("Object of class: " + value.getClass().getName() + " passed where object compatible with RequestWithOptions or String expected."));
  }
View Full Code Here

    String value = v.trim();
    int  spacepos = value.indexOf(" ");
    int lbpos = value.indexOf("(");
   
    if (lbpos == -1)
      throw(new DmcValueException("You must specify the argument vector, even if it's empty i.e ()"));

    int rbpos = value.indexOf(")", lbpos+1);
   
    if (rbpos == -1)
      throw(new DmcValueException("Missing ) for the argument vector: " + v));
     
    if (spacepos == -1)
      throw(new DmcValueException("Missing return type: " + v));
   
    returnType  = value.substring(0,spacepos);
   
    if (spacepos+1 == lbpos)
      throw(new DmcValueException("Missing method name: " + v));
   
    if (spacepos > lbpos)
      throw(new DmcValueException("Missing return type: " + v));
     
    methodName = value.substring(spacepos+1, lbpos).trim();
   
    if (methodName.length() == 0)
      throw(new DmcValueException("Missing method name: " + v));

    argVector   = value.substring(lbpos,rbpos+1);
   
    comment = "";
    if (value.length() > (rbpos+1)){
View Full Code Here

  public MethodWithArgs typeCheck(Object value) throws DmcValueException {
    if (value instanceof MethodWithArgs)
      return((MethodWithArgs)value);
    if (value instanceof String)
      return(new MethodWithArgs((String)value));
    throw(new DmcValueException("Object of class: " + value.getClass().getName() + " passed where object compatible with MethodWithArgs or String expected."));
  }
View Full Code Here

  public GetWithOptions typeCheck(Object value) throws DmcValueException {
    if (value instanceof GetWithOptions)
      return((GetWithOptions)value);
    if (value instanceof String)
      return(new GetWithOptions((String)value));
    throw(new DmcValueException("Object of class: " + value.getClass().getName() + " passed where object compatible with GetWithOptions or String expected."));
  }
View Full Code Here

  public EditField(String v) throws DmcValueException{
    String value = v.replaceAll("\t", " ").trim();
    int spacepos = value.indexOf(" ");
   
    if (spacepos == -1){
      throw(new DmcValueException("Missing field editor: " + v + " - should be of the form: [attribute name] [field editor] <RO|MUST> <: label> <: tip>"));
    }
    else{
      int colonpos = value.indexOf(":");
     
      if (colonpos == -1){
View Full Code Here

        if (vals[i].equals("MUST")){
          must = true;
          haveOption = true;
          continue;
        }
        throw(new DmcValueException("Unknown field option: " + vals[i] + " - should be of the form: [attribute name] [field editor] <RO|MUST> <: label> <: tip>"));
      }
      throw(new DmcValueException("Extraneous option: " + vals[i] + " - should be of the form: [attribute name] [field editor] <RO|MUST> <: label> <: tip>"));
    }
  }
View Full Code Here

    boolean wantLabel   = false;
    boolean wantTip    = false;
    int colonCount = 0;
   
    if (tokens.size() == 1)
      throw(new DmcValueException("Missing label - value should be of the form: [attribute name] [field editor] <RO|MUST> <: label> <: tip>"));

    for(int i=0; i<tokens.size(); i++){
      if (tokens.get(i).equals(":")){
        colonCount++;
        if (colonCount == 1)
          wantLabel = true;
        else if (colonCount == 2)
          wantTip = true;
        else if (colonCount > 2)
          throw(new DmcValueException("Extraneous colons - value should be of the form: [attribute name] [field editor] <RO|MUST> <: label> <: tip>"));
        continue;
      }
      if (wantLabel){
        label = tokens.get(i);
        if (label.length() == 0)
          throw(new DmcValueException("Missing label - should be of the form: [attribute name] [field editor] <RO|MUST> <: label> <: tip>"));
        wantLabel = false;
        continue;
      }
      if (wantTip){
        tip = tokens.get(i);
        if (tip.length() == 0)
          throw(new DmcValueException("Missing tool tip - should be of the form: [attribute name] [field editor] <RO|MUST> <: label> <: tip>"));
        wantTip = false;
        continue;
      }
      String garbage = tokens.get(i);
     
      throw(new DmcValueException("Extraneous tokens/space: *" + garbage + "* [attribute name] [field editor] <RO|MUST> <: label> <: tip>"));
    }
   
    if (wantLabel)
      throw(new DmcValueException("Missing label - should be of the form: [attribute name] [field editor] <RO|MUST> <: label> <: tip>"));
    if (wantTip)
      throw(new DmcValueException("Missing tool tip - should be of the form: [attribute name] [field editor] <RO|MUST> <: label> <: tip>"));
     
  }
View Full Code Here

 
  public RequestTypeWithOptions(String v) throws DmcValueException {
    ArrayList<String>  tokens = CheapSplitter.split(v.replaceAll("\t", " ").trim(), ' ', false, true);
   
    if (tokens.size() < 2){
      throw(new DmcValueException("Too few tokens. Value should be of the form: <request type> <function name> [className] [DMPERRORS RPCERRORS CENTRALDMPERRORS CENTRALRPCERRORS  CENTRALERRORS]"));
    }
   
    requestType = tokens.get(0);
   
    if (requestType.endsWith("Request")){
      int pos = requestType.indexOf("Request");
      requestType = requestType.substring(0, pos);
    }
    functionName = tokens.get(1);
   
    int optionStart = 2;
   
    if (requestType.equals("Set") || requestType.equals("Create")){
      optionStart = 3;
      if (tokens.size() < 3)
        throw(new DmcValueException("Too few tokens for a " + requestType + "Request. Value should be of the form: <request type> <function name> <className> [DMPERRORS RPCERRORS CENTRALDMPERRORS CENTRALRPCERRORS  CENTRALERRORS]"));       
      className = tokens.get(2);
     
      if (RequestOptionEnum.get(className) != null)
        throw(new DmcValueException("Missing class name for " + requestType + "Request. Value should be of the form: <request type> <function name> <className> [DMPERRORS RPCERRORS CENTRALDMPERRORS CENTRALRPCERRORS  CENTRALERRORS]"));       
     
    }
   
    if (tokens.size() > optionStart){
      options = new HashSet<RequestOptionEnum>();
      for(int i=optionStart; i<tokens.size(); i++){
        RequestOptionEnum val = RequestOptionEnum.get(tokens.get(i));
        if (val == null)
          throw(new DmcValueException(tokens.get(i) + " is not a valid option."));
        if ( (val == RequestOptionEnum.CACHE) || (val == RequestOptionEnum.EVENTS)){
          if (!requestType.equals("Get"))
            throw(new DmcValueException("The " + val + " option is only valid with GetRequests"));
        }
        options.add(val);
      }
     
      if ((options.size()==1) && options.contains(RequestOptionEnum.DMPERRORS)){
View Full Code Here

        else if (value instanceof String){
            rc = new RuleDefinitionREF();
            rc.setName(new StringName((String)value));
        }
        else
            throw(new DmcValueException("Object of class:" + value.getClass().getName() + " passed where a RuleDefinitionREF/DMO or DmcObjectName expected."));
        return(rc);
    }
View Full Code Here

TOP

Related Classes of org.dmd.dmc.DmcValueException

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.