Package com.rimfaxe.webserver.compiler

Examples of com.rimfaxe.webserver.compiler.JspToJavaException


      }
  }

  // If mandatory attribute is missing then the exception is thrown
  if (!valid)
            throw new JspToJavaException(start, "Mandatory Attribute type="+typeOfTag+" name="+missingAttribute);

  // Check to see if there are any more attributes for the specified tag.
        int attrLeftLength = temp.size();
  if (attrLeftLength == 0)
      return;

  // Now check to see if the rest of the attributes are valid too.
  String attribute = null;

  for (int j = 0; j < attrLeftLength; j++) {
      valid = false;
      attribute = (String) temp.elementAt(j);
      for (int i = 0; i < validAttributes.length; i++) {
          if (attribute.equals(validAttributes[i].name)) {
        valid = true;
        break;
    }
      }
      if (!valid)
                throw new JspToJavaException(start, "Invalid Attribute type="+typeOfTag+" name="+missingAttribute);
    
  }
    }
View Full Code Here


    String value = attrs.getValue(i);

    if ("language".equals(attr))
                {
        if (languageSeen)
                        throw new JspToJavaException(n.getStart(), "Multiple languages");
         
        languageSeen = true;
        if (!"java".equalsIgnoreCase(value))
          throw new JspToJavaException(n.getStart(), "Nonjava language");
        pageInfo.setLanguage(value);
    }
                else if ("extends".equals(attr))
                {
        if (extendsSeen)
          throw new JspToJavaException(n.getStart(), "Multiple extends");
        extendsSeen = true;
        pageInfo.setExtends(value);
        /*
         * If page superclass is top level class (i.e. not in a
         * pkg) explicitly import it. If this is not done, the
         * compiler will assume the extended class is in the same
         * pkg as the generated servlet.
         */
        if (value.indexOf('.') < 0)
      n.addImport(value);
    }
                else if ("contentType".equals(attr))
                {
        if (contentTypeSeen)
                        throw new JspToJavaException(n.getStart(), "Multiple contenttypes");
         
        contentTypeSeen = true;
        pageInfo.setContentType(value);
    }
                else if ("session".equals(attr))
                {
        if (sessionSeen)
                        throw new JspToJavaException(n.getStart(), "Multiple sessions");
         
        sessionSeen = true;
        if ("true".equalsIgnoreCase(value))
      pageInfo.setSession(true);
        else if ("false".equalsIgnoreCase(value))
      pageInfo.setSession(false);
        else
                        throw new JspToJavaException(n.getStart(), "Invalid session");
                       
     
    }
                else if ("buffer".equals(attr))
                {
        if (bufferSeen)
                        throw new JspToJavaException(n.getStart(), "Multiple buffers");
         
        bufferSeen = true;

        if ("none".equalsIgnoreCase(value))
      pageInfo.setBuffer(0);
        else
                    {
      if (value == null || !value.endsWith("kb"))
                            throw new JspToJavaException(n.getStart(), "Invalid buffer");
         

      try
                        {
          Integer k = new Integer(value.substring(0, value.length()-2));
          pageInfo.setBuffer(k.intValue()*1024);
      }
                        catch (NumberFormatException e)
                        {
                           System.out.println("NumberFormatException in Validator");
                           throw new JspToJavaException(n.getStart(), "Invalid buffer");
       
      }
        }
    }
                else if ("autoFlush".equals(attr))
                {
        if (autoFlushSeen)
                        throw new JspToJavaException(n.getStart(), "Multiple autoflush");
         
        autoFlushSeen = true;
        if ("true".equalsIgnoreCase(value))
      pageInfo.setAutoFlush(true);
        else if ("false".equalsIgnoreCase(value))
      pageInfo.setAutoFlush(false);
        else
                        throw new JspToJavaException(n.getStart(), "Autoflush invalid");
         
    }
                else if ("isthreadSafe".equals(attr))
                {
        if (isThreadSafeSeen)
                        throw new JspToJavaException(n.getStart(), "Multiple isThreadsafe");
     
        isThreadSafeSeen = true;
        if ("true".equalsIgnoreCase(value))
      pageInfo.setThreadSafe(true);
        else if ("false".equalsIgnoreCase(value))
      pageInfo.setThreadSafe(false);
        else
                        throw new JspToJavaException(n.getStart(), "isThreadSafe invalid");
     
    }
                else if ("isErrorPage".equals(attr))
                {
        if (isErrorPageSeen)
                        throw new JspToJavaException(n.getStart(), "Multiple isErrorPage");
     
        isErrorPageSeen = true;
        if ("true".equalsIgnoreCase(value))
      pageInfo.setIsErrorPage(true);
        else if ("false".equalsIgnoreCase(value))
      pageInfo.setIsErrorPage(false);
        else
                        throw new JspToJavaException(n.getStart(), "isErrorPage invalid");
     
    }
                else if ("errorPage".equals(attr))
                {
        if (errorPageSeen)
                        throw new JspToJavaException(n.getStart(), "Multiple errorpage");
     
        errorPageSeen = true;
        pageInfo.setErrorPage(value);
    }
                else if ("info".equals(attr))
                {
        if (infoSeen)
                        throw new JspToJavaException(n.getStart(), "Multiple info");
     
        infoSeen = true;
    }
                else if ("pageEncoding".equals(attr))
                {
        if (pageEncodingSeen)
                        throw new JspToJavaException(n.getStart(), "Multiple page encodings");
     
        pageEncodingSeen = true;
        pageInfo.setPageEncoding(value);
    }
      }

      // Check for bad combinations
      if (pageInfo.getBuffer() == 0 && !pageInfo.isAutoFlush())
                throw new JspToJavaException(n.getStart(), "Bad combo");
   

      // Attributes for imports for this node have been processed by
      // the parsers, just add them to pageInfo.
      pageInfo.addImports(n.getImports());
View Full Code Here

      String param = n.getAttributeValue("param");
      String value = n.getAttributeValue("value");

      if ("*".equals(property)) {
    if (param != null || value != null)
                    throw new JspToJavaException(n.getStart(), "Invalid SetProperty");
       
   
      }
            else if (param != null && value != null)
            {
                throw new JspToJavaException(n.getStart(), "Invalid SetProperty");
   
      }
      n.setValue(getJspAttribute("value", value, n.isXmlSyntax()));
  }
View Full Code Here

      String className = n.getAttributeValue ("class");
      String type = n.getAttributeValue ("type");
      BeanRepository beanInfo = pageInfo.getBeanRepository();

      if (className == null && type == null)
                throw new JspToJavaException(n.getStart(), "Missing type in UseBean");
           

      if (beanInfo.checkVariable(name))
                throw new JspToJavaException(n.getStart(), "Duplicate UseBean");
   

      if ("session".equals(scope) && !pageInfo.isSession())
                throw new JspToJavaException(n.getStart(), "UseBean : no session");
   

      Node.JspAttribute jattr
    = getJspAttribute("beanName", n.getAttributeValue("beanName"),
          n.isXmlSyntax());
      n.setBeanName(jattr);
      if (className != null && jattr != null)
                throw new JspToJavaException(n.getStart(), "UseBean error, not both");
   

      if (className == null)
    className = type;

            //System.out.println("Bean : "+name+"    Class="+className);
      if (scope == null || scope.equals("page"))
            {
    beanInfo.addPageBean(name, className);
      }
            else if (scope.equals("request"))
            {
    beanInfo.addRequestBean(name, className);
      }
            else if (scope.equals("session"))
            {
    beanInfo.addSessionBean(name,className);
      }
            else if (scope.equals("application"))
            {
    beanInfo.addApplicationBean(name,className);
      }
            else
            {
                throw new JspToJavaException(n.getStart(), "UseBean error, bad scope");
               
            }
      visitBody(n);
  }
View Full Code Here

      JspUtil.checkAttributes("Plugin", n.getAttributes(),
            plugInAttrs, n.getStart());

      String type = n.getAttributeValue("type");
      if (type == null)
                throw new JspToJavaException(n.getStart(), "Plugin error, no type");
   
      if (!type.equals("bean") && !type.equals("applet"))
                throw new JspToJavaException(n.getStart(), "Plugin error, bad type");
   
      if (n.getAttributeValue("code") == null)
                throw new JspToJavaException(n.getStart(), "Plugin error, no code");
   

      n.setHeight(getJspAttribute("height", n.getAttributeValue("height"),
              n.isXmlSyntax()));
      n.setWidth(getJspAttribute("width", n.getAttributeValue("width"),
View Full Code Here

           
           
      TagInfo tagInfo = tagLibInfo.getTag(n.getShortName());
      if (tagInfo == null)
            {  
                throw new JspToJavaException(n.getStart(), "TagInfo error, missing tag info")
      }
           

      /*
       * Make sure all required attributes are present
       */
      TagAttributeInfo[] tldAttrs = tagInfo.getAttributes();
      Attributes attrs = n.getAttributes();
      for (int i=0; i<tldAttrs.length; i++)
            {
    if (tldAttrs[i].isRequired() && attrs.getValue(tldAttrs[i].getName()) == null)
                {
                    throw new JspToJavaException(n.getStart(), "TagInfo error, missing attribute name="+tldAttrs[i].getName()+" shortname="+n.getShortName())
                   
    }
      }

      /*
       * Make sure there are no invalid attributes
       */
      Hashtable tagDataAttrs = new Hashtable(attrs.getLength());
      Node.JspAttribute[] jspAttrs
    = new Node.JspAttribute[attrs.getLength()];
      for (int i=0; i<attrs.getLength(); i++) {
    boolean found = false;
    for (int j=0; j<tldAttrs.length; j++) {
        if (attrs.getQName(i).equals(tldAttrs[j].getName())) {
      if (tldAttrs[j].canBeRequestTime()) {
          jspAttrs[i]
        = getJspAttribute(attrs.getQName(i),
              attrs.getValue(i),
              n.isXmlSyntax());
      } else {
          jspAttrs[i]
        = new Node.JspAttribute(attrs.getQName(i),
              attrs.getValue(i),
              false);
      }
      if (jspAttrs[i].isExpression()) {
          tagDataAttrs.put(attrs.getQName(i),
               TagData.REQUEST_TIME_VALUE);
      } else {
          tagDataAttrs.put(attrs.getQName(i),
               attrs.getValue(i));
      }
      found = true;
      break;
        }
    }
    if (!found)
                {
                    throw new JspToJavaException(n.getStart(), "TagInfo error, bad attribute, name="+attrs.getQName(i))
    }
      }

      TagData tagData = new TagData(tagDataAttrs);
      n.setTagData(tagData);
View Full Code Here

      TagLibraryInfo tagLibInfo = (TagLibraryInfo)
    pageInfo.getTagLibraries().get(n.getPrefix());
      TagInfo tagInfo = tagLibInfo.getTag(n.getShortName());
      if (tagInfo == null)
            {
                throw new JspToJavaException(n.getStart(), "Missing TagInfo, name="+n.getName());
      }

      if (!tagInfo.isValid(n.getTagData()))
            {
                throw new JspToJavaException(n.getStart(), "TagInfo, missing attributes");
      }

      visitBody(n);
  }
View Full Code Here

TOP

Related Classes of com.rimfaxe.webserver.compiler.JspToJavaException

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.