Package org.apache.imperius.spl.parser.util

Examples of org.apache.imperius.spl.parser.util.TypeInfoImpl


    public boolean validate() throws SPLException
    {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");

        Iterator expIterator = this._expressions.iterator();
        TypeInfo currentDataType = new TypeInfoImpl();
        while (expIterator.hasNext())
        {
            Expression exp = (Expression) expIterator.next();
            TypeInfo type = exp.getType();
            if (!TypeResolver.isNumeric(type))
            {
                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
               
                return false;
            }
            if (currentDataType.getType() == TypeConstants.INVALID)
            {
                currentDataType = type;
            }
            _dataType = TypeResolver.binaryNumericPromotionResolver(
                    currentDataType, type);
View Full Code Here


        passedParams.add(n1);
        passedParams.add(n2);
        passedParams.add(n3);
        passedParams.add(n4);
        ArrayList formalParams=new ArrayList();
        formalParams.add(new TypeInfoImpl(TypeConstants.byteType));
        formalParams.add(new TypeInfoImpl(TypeConstants.floatType));
        formalParams.add(new TypeInfoImpl(TypeConstants.intType));
        formalParams.add(new TypeInfoImpl(TypeConstants.longType));
       
       
       
       
        try {
          TypeInfo flt = new TypeInfoImpl(TypeConstants.floatType);
          TypeInfo dbl = new TypeInfoImpl(TypeConstants.doubleType);
          TypeInfo intt = new TypeInfoImpl(TypeConstants.intType);
          TypeInfo lg = new TypeInfoImpl(TypeConstants.longType);
          TypeInfo str = new TypeInfoImpl(TypeConstants.stringType);
          TypeInfo bo   = new TypeInfoImpl(TypeConstants.booleanType);
          TypeInfo cal = new TypeInfoImpl(TypeConstants.dateTime);
          TypeInfo bt = new TypeInfoImpl(TypeConstants.byteType);
         
          //System.out.println("TypeResolver.resolveType(flt, dbl).getType()="+TypeResolver.resolveType(flt, dbl).getType());
          //System.out.println("TypeConstants.doubleType="+TypeConstants.doubleType);
            assertTrue(TypeResolver.resolveType(flt, dbl).getType()==TypeConstants.doubleType);
            assertTrue(TypeResolver.resolveType(num)==TypeConstants.doubleType);
View Full Code Here

  {
    logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "insertVariableSymbol");

    if(!_symbolMap.containsKey(name))
    { 
      TypeInfo tp = new TypeInfoImpl(type,referenceTypeName,isArray);
      Symbol cimSym = new PropertySymbol(name,tp,isKey,isClassProp);
      _symbolMap.put(name, cimSym);
    }
    else
    {
View Full Code Here

      MacroDefinition macroDef) throws SPLException
  {
    logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "insertMacroSymbol");

    int type = TypeConstants.getActualType(retType);
    TypeInfo returnType = new TypeInfoImpl(type,null,isArray);
    if(!_symbolMap.containsKey(name))
    { 
      Symbol cimSym = new MacroSymbol(name,returnType,argTypeList,macroDef);
      _symbolMap.put(name, cimSym);
    }
View Full Code Here

    return null;
  }

  public TypeInfo getType() throws SPLException {
    // TODO Auto-generated method stub
    return new TypeInfoImpl(TypeConstants.booleanType,null,false);
  }
View Full Code Here

    return null;
  }

  public TypeInfo getType() throws SPLException {
    // TODO Auto-generated method stub
    return new TypeInfoImpl(TypeConstants.booleanType,null,false);
  }
View Full Code Here

      Symbol propSymbol = (Symbol)symTab.getSymbol(targetClassName + "." + targetClassPropertyName);
//      Collection c = symTab.getSymbol(targetClassName + "." + targetClassPropertyName);
//      Iterator it = c.iterator();
//      Symbol propSymbol = (Symbol) it.next();
     
      this._dataType=new TypeInfoImpl(propSymbol.getType());
      this._dataType.setIsArray(true);
      expressionForTarget = (Expression)paramList.get(6); // 6th param is an expression involving properties of the targetclass
      if(expressionForTarget.validate())
      {
        if(expressionForTarget.getType().getType() != TypeConstants.booleanType) // this expression is used to filter instances hence needs to be boolean
       

          logger.severe(Thread.currentThread().getName()+" "+"6th param to collect needs to be a boolean expression");

          throw new IllegalExpressionTypeException(
              "sixth "
                  + Messages
                      .getString("SPL_COLLECT_OPERATION_EXP_EXCEPTION3_MSG"));

        }
        if(!noPostCollectOperation) // if an expression exists that follows collect
       

          // REMOVED BY NRJ
          //System.out.println("Post collect expression exists");   
          postCollectOperation.validate(this.targetClassName); // validate the expression
          if(postCollectOperation.Array2Exists() || postCollectOperation.isMethodOrParamExists())  {
            this._dataType=new TypeInfoImpl(postCollectOperation.getType());
          }
          else{
            this._dataType.setIsArray(false);
          }
        } 
View Full Code Here

    private void _validate() throws SPLException
    {
        boolean isArray = false;
        if (!_identTupleList.isEmpty())
        {
            TypeInfo returnType = new TypeInfoImpl(TypeConstants.referenceType,
                    _className, isArray);

            Iterator identTupleIt = _identTupleList.iterator();
            int i = 0;
            while (identTupleIt.hasNext())
            {
                if (returnType.getType() == TypeConstants.referenceType)
                {
                    String referenceTypeName = returnType
                            .getReferenceTypeName();
                    IdentPrimaryTuple ipt = (IdentPrimaryTuple) identTupleIt
                            .next();
                    if (i++ == 0)
                    {
View Full Code Here

        return returnValue;
    }

  public TypeInfo validate(String classTypeOrVariableName) throws SPLException
  {
    TypeInfo typeInfo = new TypeInfoImpl();
    _classType = classTypeOrVariableName;
    // ensure symbol table is populated
    _populateSymbolTable(_classType);

    // xiping's addition to support Java overloading, 06/19/09
    // start
    Object obj = null;
   
    try {
      obj = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier);
    } catch(SPLException splex) {
      try
      {
                obj = _symbolTable.getSymbol(classTypeOrVariableName + "." + getAccessorMethodName(_identifier, "get"));
            }
            catch(SPLException splex1)
            {
                try
                {
                    obj = _symbolTable.getSymbol(classTypeOrVariableName + "." + getAccessorMethodName(_identifier, "is"));
                }
                catch(SPLException splex2)
                {
                    throw new SPLException(
              Messages
                  .getString(
                      "SPL_SYMBOL_DOES_NOT_EXIST_EXCEPTION_MSG",
                      new Object[] { classTypeOrVariableName + "."
                          + _identifier }));
                }
            }
        }
   
    Symbol sym = null;
    if (obj instanceof Vector) { // MethodSymbol
      Collection c = (Collection) obj;
      for (Iterator it = c.iterator(); it.hasNext();) {
        sym = (Symbol) it.next();
        List aList = ((MethodSymbol)sym).getArgumentList();
     
        if (aList.size() != _paramList.size()) {
          continue;
        }
       
        boolean typeNotEqual = false;
        for (int i = 0; i < aList.size(); i++) {
          Expression exp = (Expression)_paramList.get(i);
          Argument arg = (Argument)aList.get(i);
          TypeInfo expDataType = exp.getType();
          TypeInfo argDataType = arg.getType();
//          if (expDataType.getIsArray() != argDataType.getIsArray() ||
//              expDataType.getType() != argDataType.getType()) {
          if (expDataType.getType() != argDataType.getType()) {
            typeNotEqual = true;
            break;
          }
        }
       
        if (typeNotEqual) {
          continue;
        }

        break;
      }
    } else { // PropertySymbol
      sym = (Symbol) obj;
    }

        if(_isMethod)
        {
            if(sym instanceof MethodSymbol)
            {
                typeInfo = _validateActualParameters(sym,classTypeOrVariableName);
               
            }
            else
            {
                throw new SPLException("Symbol " + _identifier + "is not a method");
            }
        }
        else
        {
            TypeInfo tp = sym.getType();
            boolean isArray = sym.isArray();
            if(_arrExp != null) // expression is like A.b[2] which means
            { // the result is not an array
                isArray = false;
            }
            String resultClass = null;
            if(TypeResolver.isReference(tp))
            {
                resultClass = sym.getReferenceTypeName();
                typeInfo.setReferenceTypeName(resultClass);
                typeInfo.setType(tp.getType());
                typeInfo.setIsArray(isArray);
            }
            else
            {
                typeInfo.setType(tp.getType());
                typeInfo.setIsArray(isArray);
            }
           
        }
   
    return typeInfo;
View Full Code Here

    }

  private TypeInfo _validateActualParameters(Symbol sym,
      String classType) throws SPLException
  {
    TypeInfo returnTypeInfo = new TypeInfoImpl();
    String returnClassName = null;
    AnchorMethodInvokeAction.validateActualParameters(_symbolTable,
          classType, _identifier, _paramList);
    TypeInfo returnType = sym.getType();
    boolean isArray = sym.isArray();
    if(TypeResolver.isReference(returnType))
    {
      returnClassName = sym.getReferenceTypeName();
      returnTypeInfo.setIsArray(isArray);
      returnTypeInfo.setReferenceTypeName(returnClassName);
      returnTypeInfo.setType(returnType.getType());
     
    }
    else
    {
      returnTypeInfo.setIsArray(isArray);
      returnTypeInfo.setType(returnType.getType());
    }
    return returnTypeInfo;
   
     
   
View Full Code Here

TOP

Related Classes of org.apache.imperius.spl.parser.util.TypeInfoImpl

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.